Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
-
import numpy as np
|
| 4 |
import os
|
| 5 |
import requests
|
| 6 |
import json
|
|
@@ -99,6 +98,8 @@ function_map = {
|
|
| 99 |
# --- Conversation memory: Use Streamlit session state
|
| 100 |
if "messages" not in st.session_state:
|
| 101 |
st.session_state.messages = []
|
|
|
|
|
|
|
| 102 |
|
| 103 |
# If CSV is loaded, update the system prompt with current columns
|
| 104 |
if df is not None:
|
|
@@ -136,10 +137,8 @@ for i, msg in enumerate(st.session_state.messages[1:]): # Skip system message f
|
|
| 136 |
|
| 137 |
# --- User input box at bottom (like ChatGPT)
|
| 138 |
if df is not None:
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
user_input = st.text_input("Your message:", key="user_input")
|
| 142 |
-
send = st.button("Send", key="send_btn")
|
| 143 |
else:
|
| 144 |
user_input = None
|
| 145 |
send = False
|
|
@@ -207,6 +206,7 @@ if send and user_input and user_input.strip():
|
|
| 207 |
# No function call: Just add model's reply
|
| 208 |
st.session_state.messages.append({"role": "assistant", "content": msg["content"]})
|
| 209 |
|
| 210 |
-
# Clear input after sending
|
| 211 |
-
st.session_state.
|
| 212 |
-
# The UI will update
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
|
|
|
| 3 |
import os
|
| 4 |
import requests
|
| 5 |
import json
|
|
|
|
| 98 |
# --- Conversation memory: Use Streamlit session state
|
| 99 |
if "messages" not in st.session_state:
|
| 100 |
st.session_state.messages = []
|
| 101 |
+
if "temp_input" not in st.session_state:
|
| 102 |
+
st.session_state.temp_input = ""
|
| 103 |
|
| 104 |
# If CSV is loaded, update the system prompt with current columns
|
| 105 |
if df is not None:
|
|
|
|
| 137 |
|
| 138 |
# --- User input box at bottom (like ChatGPT)
|
| 139 |
if df is not None:
|
| 140 |
+
user_input = st.text_input("Your message:", value=st.session_state.temp_input, key="temp_input")
|
| 141 |
+
send = st.button("Send")
|
|
|
|
|
|
|
| 142 |
else:
|
| 143 |
user_input = None
|
| 144 |
send = False
|
|
|
|
| 206 |
# No function call: Just add model's reply
|
| 207 |
st.session_state.messages.append({"role": "assistant", "content": msg["content"]})
|
| 208 |
|
| 209 |
+
# Clear input after sending (no session state error!)
|
| 210 |
+
st.session_state.temp_input = ""
|
| 211 |
+
# The UI will update automatically
|
| 212 |
+
|