suriya7 commited on
Commit
bb31c00
1 Parent(s): 24092b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
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.spinner("Thinking..."):
62
- query_engine = index.as_query_engine(text_qa_template=text_qa_template)
63
- answer = query_engine.query(query)
64
-
65
- if hasattr(answer, 'response'):
66
- return answer.response
67
- elif isinstance(answer, dict) and 'response' in answer:
68
- return answer['response']
69
- else:
70
- return "Sorry, I couldn't find an answer."
 
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