Spaces:
Sleeping
Sleeping
apahilaj
commited on
Commit
·
e44f1b6
1
Parent(s):
14af323
memory.history
Browse files
app.py
CHANGED
@@ -61,12 +61,12 @@ def load_db(file, k):
|
|
61 |
def chat(input_text, pdf_file):
|
62 |
qa = load_db(pdf_file, 3)
|
63 |
|
64 |
-
if not memory.
|
65 |
# If no previous conversation, start with a greeting
|
66 |
response = qa.invoke({"question": "Hi, how can I help you today?", "chat_history": []})
|
67 |
memory.update(response["chat_history"])
|
68 |
|
69 |
-
response = qa.invoke({"question": input_text, "chat_history": memory.
|
70 |
|
71 |
# Extracting the helpful answer from the response
|
72 |
match = re.search(r'Helpful Answer:(.*)', response['answer'])
|
@@ -80,5 +80,6 @@ def chat(input_text, pdf_file):
|
|
80 |
|
81 |
return helpful_answer
|
82 |
|
|
|
83 |
iface = gr.Interface(fn=chat, inputs=["text", "file"], outputs="text")
|
84 |
iface.launch(share=True)
|
|
|
61 |
def chat(input_text, pdf_file):
|
62 |
qa = load_db(pdf_file, 3)
|
63 |
|
64 |
+
if not memory.history:
|
65 |
# If no previous conversation, start with a greeting
|
66 |
response = qa.invoke({"question": "Hi, how can I help you today?", "chat_history": []})
|
67 |
memory.update(response["chat_history"])
|
68 |
|
69 |
+
response = qa.invoke({"question": input_text, "chat_history": memory.history})
|
70 |
|
71 |
# Extracting the helpful answer from the response
|
72 |
match = re.search(r'Helpful Answer:(.*)', response['answer'])
|
|
|
80 |
|
81 |
return helpful_answer
|
82 |
|
83 |
+
|
84 |
iface = gr.Interface(fn=chat, inputs=["text", "file"], outputs="text")
|
85 |
iface.launch(share=True)
|