Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,7 +48,7 @@ def handle_query(message, history):
|
|
| 48 |
chat_text_qa_msgs = [
|
| 49 |
(
|
| 50 |
"user",
|
| 51 |
-
f"You are now the RedFerns Tech chatbot. Your aim is to provide answers to the user based on the conversation flow only.\n\nQuestion:\n{message
|
| 52 |
)
|
| 53 |
]
|
| 54 |
text_qa_template = ChatPromptTemplate.from_messages(chat_text_qa_msgs)
|
|
@@ -59,7 +59,7 @@ def handle_query(message, history):
|
|
| 59 |
|
| 60 |
# Use the Llama index to generate a response
|
| 61 |
query_engine = index.as_query_engine(text_qa_template=text_qa_template, context_str="")
|
| 62 |
-
answer = query_engine.query(message
|
| 63 |
|
| 64 |
if hasattr(answer, 'response'):
|
| 65 |
response = answer.response
|
|
@@ -69,10 +69,11 @@ def handle_query(message, history):
|
|
| 69 |
response = "Sorry, I couldn't find an answer."
|
| 70 |
|
| 71 |
# Update chat history with the current interaction
|
| 72 |
-
chat_history.append([message
|
| 73 |
|
| 74 |
return response
|
| 75 |
|
|
|
|
| 76 |
# Example usage: Process PDF ingestion from directory
|
| 77 |
print("Processing PDF ingestion from directory:", PDF_DIRECTORY)
|
| 78 |
data_ingestion_from_directory()
|
|
|
|
| 48 |
chat_text_qa_msgs = [
|
| 49 |
(
|
| 50 |
"user",
|
| 51 |
+
f"You are now the RedFerns Tech chatbot. Your aim is to provide answers to the user based on the conversation flow only.\n\nQuestion:\n{message}"
|
| 52 |
)
|
| 53 |
]
|
| 54 |
text_qa_template = ChatPromptTemplate.from_messages(chat_text_qa_msgs)
|
|
|
|
| 59 |
|
| 60 |
# Use the Llama index to generate a response
|
| 61 |
query_engine = index.as_query_engine(text_qa_template=text_qa_template, context_str="")
|
| 62 |
+
answer = query_engine.query(message)
|
| 63 |
|
| 64 |
if hasattr(answer, 'response'):
|
| 65 |
response = answer.response
|
|
|
|
| 69 |
response = "Sorry, I couldn't find an answer."
|
| 70 |
|
| 71 |
# Update chat history with the current interaction
|
| 72 |
+
chat_history.append([message, response])
|
| 73 |
|
| 74 |
return response
|
| 75 |
|
| 76 |
+
|
| 77 |
# Example usage: Process PDF ingestion from directory
|
| 78 |
print("Processing PDF ingestion from directory:", PDF_DIRECTORY)
|
| 79 |
data_ingestion_from_directory()
|