Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,12 +38,16 @@ previous_response = ""
|
|
| 38 |
provided_docs = ""
|
| 39 |
def conversational_chat(query):
|
| 40 |
global previous_response, provided_docs
|
| 41 |
-
for i in st.session_state['history']:
|
| 42 |
if i is not None:
|
| 43 |
previous_response += f"Human: {i[0]}\n Chatbot: {i[1]}\n"
|
| 44 |
provided_docs = "".join(st.session_state["docs"])
|
| 45 |
result = llm_chain.predict(chat_history=previous_response, human_input=query, provided_docs=provided_docs)
|
| 46 |
st.session_state['history'].append((query, result))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
return result
|
| 48 |
|
| 49 |
st.title("CRETA 🤖")
|
|
|
|
| 38 |
provided_docs = ""
|
| 39 |
def conversational_chat(query):
|
| 40 |
global previous_response, provided_docs
|
| 41 |
+
for i in st.session_state['history'][-5:]:
|
| 42 |
if i is not None:
|
| 43 |
previous_response += f"Human: {i[0]}\n Chatbot: {i[1]}\n"
|
| 44 |
provided_docs = "".join(st.session_state["docs"])
|
| 45 |
result = llm_chain.predict(chat_history=previous_response, human_input=query, provided_docs=provided_docs)
|
| 46 |
st.session_state['history'].append((query, result))
|
| 47 |
+
|
| 48 |
+
# Keep only the last 5 history entries
|
| 49 |
+
st.session_state['history'] = st.session_state['history'][-5:]
|
| 50 |
+
|
| 51 |
return result
|
| 52 |
|
| 53 |
st.title("CRETA 🤖")
|