ProfessorLeVesseur commited on
Commit
d81ac57
1 Parent(s): 2e4aaee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -9,16 +9,17 @@ openai_api_key = st.secrets["openai_api_key"]
9
  openai.api_key = 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
- # pinecone_environment = st.secrets["pinecone_environment"]
15
 
16
  # AUTHENTICATE/INITIALIZE PINCONE SERVICE
17
  from pinecone import Pinecone
18
- pc = Pinecone(api_key=pinecone_api_key)
19
  # pc = Pinecone (api_key= 'YOUR_API_KEY')
 
20
 
21
- # Define the name of the Pinecone index
22
  index_name = 'mimtssinkqa'
23
 
24
  # Initialize the OpenAI embeddings object
@@ -26,8 +27,10 @@ from langchain_openai import OpenAIEmbeddings
26
  embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
27
 
28
  # LOAD VECTOR STORE FROM EXISTING INDEX
29
- from langchain_community.vectorstores import Pinecone
30
- vector_store = Pinecone.from_existing_index(index_name='mimtssinkqa', embedding=embeddings)
 
 
31
 
32
  def ask_with_memory(vector_store, query, chat_history=[]):
33
  from langchain_openai import ChatOpenAI
 
9
  openai.api_key = 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
+ pinecone_environment = st.secrets["pinecone_environment"]
15
 
16
  # AUTHENTICATE/INITIALIZE PINCONE SERVICE
17
  from pinecone import Pinecone
18
+ # pc = Pinecone(api_key=pinecone_api_key)
19
  # pc = Pinecone (api_key= 'YOUR_API_KEY')
20
+ Pinecone(api_key=pinecone_api_key, environment=pinecone_environment)
21
 
22
+ # # Define the name of the Pinecone index
23
  index_name = 'mimtssinkqa'
24
 
25
  # Initialize the OpenAI embeddings object
 
27
  embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
28
 
29
  # LOAD VECTOR STORE FROM EXISTING INDEX
30
+ # from langchain_community.vectorstores import Pinecone
31
+ from langchain_community.vectorstores import Pinecone as PineconeStore
32
+ # vector_store = Pinecone.from_existing_index(index_name='mimtssinkqa', embedding=embeddings)
33
+ vector_store = PineconeStore.from_existing_index(index_name=index_name, embedding=embeddings)
34
 
35
  def ask_with_memory(vector_store, query, chat_history=[]):
36
  from langchain_openai import ChatOpenAI