ProfessorLeVesseur commited on
Commit
141bf65
1 Parent(s): f3e227d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -29
app.py CHANGED
@@ -3,44 +3,20 @@ import openai
3
  import random
4
 
5
 
6
-
7
-
8
-
9
  # Fetch the OpenAI API key from Streamlit secrets
10
- openai_api_key = st.secrets["openai_api_key"]
11
-
12
- openai_api_key = "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"
13
- # Initialize the OpenAI service with API key
14
- openai.api_key = openai_api_key
15
 
16
  # # Fetch Pinecone API key and environment from Streamlit secrets
17
- # PINECONE_API_KEY = st.secrets["PINECONE_API_KEY"]
18
  # # pinecone_api_key = '555c0e70-331d-4b43-aac7-5b3aac5078d6'
19
- # pinecone_environment = st.secrets["pinecone_environment"]
20
 
21
  # # AUTHENTICATE/INITIALIZE PINCONE SERVICE
22
  from pinecone import Pinecone
23
- # # pc = Pinecone(api_key=PINECONE_API_KEY)
24
- # pc = Pinecone (api_key= 'YOUR_API_KEY')
25
-
26
  PINECONE_API_KEY = "555c0e70-331d-4b43-aac7-5b3aac5078d6"
27
  pc = Pinecone(api_key=PINECONE_API_KEY)
28
 
29
- # Hardcode the OpenAI API key
30
- OPENAI_API_KEY = "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"
31
-
32
- # import os
33
- # Retrieve OpenAI API key from environment variables
34
- openai_api_key = os.getenv('OPENAI_API_KEY')
35
- # Initialize the OpenAI service with API key
36
- openai.api_key = openai_api_key
37
-
38
- # AUTHENTICATE/INITIALIZE PINCONE SERVICE
39
- from pinecone import Pinecone
40
- pc = Pinecone()
41
-
42
-
43
-
44
 
45
  # # Define the name of the Pinecone index
46
  index_name = 'mimtssinkqa'
@@ -60,7 +36,7 @@ def ask_with_memory(vector_store, query, chat_history=[]):
60
 
61
  from langchain.prompts import ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate
62
 
63
- llm = ChatOpenAI(model_name='gpt-3.5-turbo', temperature=0.5)
64
 
65
  retriever = vector_store.as_retriever(search_type='similarity', search_kwargs={'k': 3})
66
 
 
3
  import random
4
 
5
 
 
 
 
6
  # Fetch the OpenAI API key from Streamlit secrets
7
+ OPENAI_API_KEY = st.secrets["OPENAI_API_KEY"]
8
+ # Retrieve the OpenAI API Key from secrets
9
+ openai.api_key = st.secrets["OPENAI_API_KEY"]
 
 
10
 
11
  # # Fetch Pinecone API key and environment from Streamlit secrets
12
+ PINECONE_API_KEY = st.secrets["PINECONE_API_KEY"]
13
  # # pinecone_api_key = '555c0e70-331d-4b43-aac7-5b3aac5078d6'
 
14
 
15
  # # AUTHENTICATE/INITIALIZE PINCONE SERVICE
16
  from pinecone import Pinecone
 
 
 
17
  PINECONE_API_KEY = "555c0e70-331d-4b43-aac7-5b3aac5078d6"
18
  pc = Pinecone(api_key=PINECONE_API_KEY)
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  # # Define the name of the Pinecone index
22
  index_name = 'mimtssinkqa'
 
36
 
37
  from langchain.prompts import ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate
38
 
39
+ llm = ChatOpenAI(model_name='gpt-3.5-turbo', temperature=0.5, openai_api_key=openai_api_key)
40
 
41
  retriever = vector_store.as_retriever(search_type='similarity', search_kwargs={'k': 3})
42