alexzhuzhou commited on
Commit
7316fdd
·
1 Parent(s): 8c42033
Files changed (1) hide show
  1. app.py +5 -12
app.py CHANGED
@@ -4,6 +4,7 @@ from makechain import get_chain
4
  from langchain.vectorstores.pinecone import Pinecone
5
  from langchain.embeddings.openai import OpenAIEmbeddings
6
  import os
 
7
  PINECONE_INDEX_NAME = os.environ.get("PINECONE_INDEX_NAME")
8
  PINECONE_ENVIRONMENT = os.environ.get("PINECONE_ENVIRONMENT")
9
  PINECONE_API_KEY = os.environ.get("PINECONE_API_KEY")
@@ -34,11 +35,12 @@ vectorStore = Pinecone(
34
  # create chain
35
  qa_chain = get_chain(vectorStore)
36
 
 
37
  def main():
38
  global query
39
 
40
- user_query= st.text_input("Enter your question here")
41
- if user_query != ":q" or user_query != "":
42
  # Pass the query to the ChatGPT function
43
  query = user_query.strip().replace('\n', ' ')
44
  response = qa_chain(
@@ -50,17 +52,8 @@ def main():
50
  st.write("Sources: ")
51
  st.write(f"{response['sources']}")
52
 
 
53
  try:
54
  main()
55
  except Exception as e:
56
  st.write("An error occurred while running the application: ", e)
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
 
4
  from langchain.vectorstores.pinecone import Pinecone
5
  from langchain.embeddings.openai import OpenAIEmbeddings
6
  import os
7
+
8
  PINECONE_INDEX_NAME = os.environ.get("PINECONE_INDEX_NAME")
9
  PINECONE_ENVIRONMENT = os.environ.get("PINECONE_ENVIRONMENT")
10
  PINECONE_API_KEY = os.environ.get("PINECONE_API_KEY")
 
35
  # create chain
36
  qa_chain = get_chain(vectorStore)
37
 
38
+
39
  def main():
40
  global query
41
 
42
+ user_query = st.text_input("Enter your question here")
43
+ if user_query != ":q" and user_query != "":
44
  # Pass the query to the ChatGPT function
45
  query = user_query.strip().replace('\n', ' ')
46
  response = qa_chain(
 
52
  st.write("Sources: ")
53
  st.write(f"{response['sources']}")
54
 
55
+
56
  try:
57
  main()
58
  except Exception as e:
59
  st.write("An error occurred while running the application: ", e)