Commit
·
95be932
1
Parent(s):
13dbebe
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,18 +29,26 @@ class ChatWrapper:
|
|
| 29 |
api_key = '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'
|
| 30 |
chain = self.set_openai_api_key(api_key)
|
| 31 |
try:
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
except Exception as e:
|
| 45 |
raise e
|
| 46 |
finally:
|
|
|
|
| 29 |
api_key = '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'
|
| 30 |
chain = self.set_openai_api_key(api_key)
|
| 31 |
try:
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
with open("vectorstore.pkl", "rb") as f:
|
| 38 |
+
vectorstore = pickle.load(f)
|
| 39 |
+
|
| 40 |
+
qa_chain = get_chain(vectorstore)
|
| 41 |
+
chat_history = []
|
| 42 |
+
print("Chat with your docs!")
|
| 43 |
+
while True:
|
| 44 |
+
print("Human:")
|
| 45 |
+
question = input()
|
| 46 |
+
result = qa_chain({"question": question, "chat_history": chat_history})
|
| 47 |
+
chat_history.append((question, result["answer"]))
|
| 48 |
+
print("AI:")
|
| 49 |
+
print(result["answer"])
|
| 50 |
+
chatResult = (output, history)
|
| 51 |
+
|
| 52 |
except Exception as e:
|
| 53 |
raise e
|
| 54 |
finally:
|