Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -58,16 +58,17 @@ def handle_query(query):
|
|
58 |
)
|
59 |
]
|
60 |
text_qa_template = ChatPromptTemplate.from_messages(chat_text_qa_msgs)
|
61 |
-
with st.
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
71 |
|
72 |
|
73 |
# Streamlit app initialization
|
|
|
58 |
)
|
59 |
]
|
60 |
text_qa_template = ChatPromptTemplate.from_messages(chat_text_qa_msgs)
|
61 |
+
with st.chat_message("assistant"):
|
62 |
+
with st.spinner("Thinking..."):
|
63 |
+
query_engine = index.as_query_engine(text_qa_template=text_qa_template)
|
64 |
+
answer = query_engine.query(query)
|
65 |
+
|
66 |
+
if hasattr(answer, 'response'):
|
67 |
+
return answer.response
|
68 |
+
elif isinstance(answer, dict) and 'response' in answer:
|
69 |
+
return answer['response']
|
70 |
+
else:
|
71 |
+
return "Sorry, I couldn't find an answer."
|
72 |
|
73 |
|
74 |
# Streamlit app initialization
|