Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -89,34 +89,11 @@ rag_chain = RemoteRunnable("http://69.61.24.171:8000/rag_chain/")
|
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
-
msgs = StreamlitChatMessageHistory(key="langchain_messages")
|
| 93 |
|
| 94 |
# --- Main Content ---
|
| 95 |
st.markdown("## 🔍 Chatbot For AI Engineer test:")
|
| 96 |
|
| 97 |
-
if len(msgs.messages) == 0:
|
| 98 |
-
msgs.add_ai_message("Hi! How can I assist you today?")
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
for msg in msgs.messages:
|
| 102 |
-
st.chat_message(msg.type).write(msg.content)
|
| 103 |
-
|
| 104 |
-
if prompt := st.chat_input():
|
| 105 |
-
st.chat_message("human").write(prompt)
|
| 106 |
-
|
| 107 |
-
with st.chat_message("assistant"):
|
| 108 |
-
message_placeholder = st.empty()
|
| 109 |
-
full_response = ""
|
| 110 |
-
|
| 111 |
-
try:
|
| 112 |
-
_chat_history = st.session_state.langchain_messages[1:40]
|
| 113 |
-
_chat_history_tranform = list(
|
| 114 |
-
chunked([msg.content for msg in _chat_history], n=2)
|
| 115 |
-
)
|
| 116 |
-
|
| 117 |
-
response = rag_chain.stream(
|
| 118 |
-
{"question": prompt, "chat_history": _chat_history_tranform}
|
| 119 |
-
)
|
| 120 |
|
| 121 |
for res in response:
|
| 122 |
full_response += res or ""
|
|
|
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
+
#msgs = StreamlitChatMessageHistory(key="langchain_messages")
|
| 93 |
|
| 94 |
# --- Main Content ---
|
| 95 |
st.markdown("## 🔍 Chatbot For AI Engineer test:")
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
for res in response:
|
| 99 |
full_response += res or ""
|