Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -121,20 +121,24 @@ response_container = st.container()
|
|
121 |
# container for text box
|
122 |
container = st.container()
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
with container:
|
125 |
with st.form(key='my_form', clear_on_submit=True):
|
126 |
user_input = st.text_area("You:", key='input', height=100)
|
127 |
submit_button = st.form_submit_button(label='Send')
|
128 |
|
129 |
if submit_button and user_input:
|
130 |
-
|
131 |
-
if "__end__" in output:
|
132 |
-
continue
|
133 |
-
# stream() yields dictionaries with output keyed by node name
|
134 |
-
for key, value in output.items():
|
135 |
-
st.session_state['messages'].append({"role": "assistant", "content": value.content})
|
136 |
-
st.session_state['past'].append(user_input)
|
137 |
-
st.session_state['generated'].append(value.content)
|
138 |
|
139 |
if st.session_state['generated']:
|
140 |
with response_container:
|
|
|
121 |
# container for text box
|
122 |
container = st.container()
|
123 |
|
124 |
+
@st.cache_resource
|
125 |
+
def query(payload):
|
126 |
+
for output in graph.stream([HumanMessage(content=payload], config=config):
|
127 |
+
if "__end__" in output:
|
128 |
+
continue
|
129 |
+
# stream() yields dictionaries with output keyed by node name
|
130 |
+
for key, value in output.items():
|
131 |
+
st.session_state['messages'].append({"role": "assistant", "content": value.content})
|
132 |
+
st.session_state['past'].append(user_input)
|
133 |
+
st.session_state['generated'].append(value.content)
|
134 |
+
|
135 |
with container:
|
136 |
with st.form(key='my_form', clear_on_submit=True):
|
137 |
user_input = st.text_area("You:", key='input', height=100)
|
138 |
submit_button = st.form_submit_button(label='Send')
|
139 |
|
140 |
if submit_button and user_input:
|
141 |
+
query(user_input)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
if st.session_state['generated']:
|
144 |
with response_container:
|