Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,10 +75,20 @@ def main():
|
|
| 75 |
st.subheader('Chat Interface')
|
| 76 |
user_question = st.text_input('Ask a question:')
|
| 77 |
if st.button('Ask'):
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
for
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
else:
|
| 83 |
st.error("Failed to process CSV file. Please try again.")
|
| 84 |
|
|
|
|
| 75 |
st.subheader('Chat Interface')
|
| 76 |
user_question = st.text_input('Ask a question:')
|
| 77 |
if st.button('Ask'):
|
| 78 |
+
# Split the user question into smaller parts
|
| 79 |
+
questions = user_question.split('?')
|
| 80 |
+
for question in questions:
|
| 81 |
+
response = conversation_chain.invoke({'question': question.strip()})
|
| 82 |
+
if 'chat_history' in response:
|
| 83 |
+
chat_history = response['chat_history']
|
| 84 |
+
for message in chat_history:
|
| 85 |
+
if isinstance(message, dict) and 'role' in message and 'content' in message:
|
| 86 |
+
if message['role'] == 'user':
|
| 87 |
+
st.write(f"You: {message['content']}")
|
| 88 |
+
elif message['role'] == 'assistant':
|
| 89 |
+
st.write(f"Assistant: {message['content']}")
|
| 90 |
+
else:
|
| 91 |
+
st.error("Failed to get response. Please try again.")
|
| 92 |
else:
|
| 93 |
st.error("Failed to process CSV file. Please try again.")
|
| 94 |
|