Spaces:
Sleeping
Sleeping
alejandro
commited on
Commit
·
e37ebd7
1
Parent(s):
b0cfa99
feat: add streaming
Browse files- src/app.py +3 -5
src/app.py
CHANGED
@@ -63,7 +63,7 @@ def get_response(user_query, chat_history, db):
|
|
63 |
| StrOutputParser()
|
64 |
)
|
65 |
|
66 |
-
return chain.
|
67 |
"question": user_query
|
68 |
})
|
69 |
|
@@ -110,13 +110,11 @@ if user_query is not None and user_query != "":
|
|
110 |
st.markdown(user_query)
|
111 |
|
112 |
with st.chat_message("AI"):
|
113 |
-
response = get_response(
|
114 |
user_query,
|
115 |
st.session_state.chat_history,
|
116 |
st.session_state.db
|
117 |
-
)
|
118 |
-
print(f"Response generated: {response}")
|
119 |
-
st.markdown(response)
|
120 |
|
121 |
st.session_state.chat_history.append(AIMessage(content=response))
|
122 |
|
|
|
63 |
| StrOutputParser()
|
64 |
)
|
65 |
|
66 |
+
return chain.stream({
|
67 |
"question": user_query
|
68 |
})
|
69 |
|
|
|
110 |
st.markdown(user_query)
|
111 |
|
112 |
with st.chat_message("AI"):
|
113 |
+
response = st.write_stream(get_response(
|
114 |
user_query,
|
115 |
st.session_state.chat_history,
|
116 |
st.session_state.db
|
117 |
+
))
|
|
|
|
|
118 |
|
119 |
st.session_state.chat_history.append(AIMessage(content=response))
|
120 |
|