Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,16 +29,20 @@ def main():
|
|
| 29 |
llm = Anthropic(temperature=0.0, model='claude-3-opus-20240229', api_key=api_key)
|
| 30 |
query_engine = PandasQueryEngine(df=df, llm=llm, verbose=True)
|
| 31 |
|
| 32 |
-
#
|
| 33 |
question = st.text_input("Ask a question about the data:")
|
| 34 |
-
|
| 35 |
-
if
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
if response.startswith('http'):
|
| 39 |
-
st.image(response, use_column_width=True)
|
| 40 |
-
else:
|
| 41 |
st.markdown(f"**Response:** {response}")
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
if __name__ == "__main__":
|
| 44 |
main()
|
|
|
|
| 29 |
llm = Anthropic(temperature=0.0, model='claude-3-opus-20240229', api_key=api_key)
|
| 30 |
query_engine = PandasQueryEngine(df=df, llm=llm, verbose=True)
|
| 31 |
|
| 32 |
+
# Continous chat
|
| 33 |
question = st.text_input("Ask a question about the data:")
|
| 34 |
+
while True:
|
| 35 |
+
if st.button("Submit") or st.session_state.is_enter_pressed:
|
| 36 |
+
if question:
|
| 37 |
+
response = query_engine.query(question)
|
|
|
|
|
|
|
|
|
|
| 38 |
st.markdown(f"**Response:** {response}")
|
| 39 |
|
| 40 |
+
# For continuous chat
|
| 41 |
+
st.text_input("Ask another question:", key="question")
|
| 42 |
+
st.session_state.is_enter_pressed = False
|
| 43 |
+
|
| 44 |
+
if st.session_state.is_enter_pressed:
|
| 45 |
+
break
|
| 46 |
+
|
| 47 |
if __name__ == "__main__":
|
| 48 |
main()
|