Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,13 +33,12 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
| 33 |
|
| 34 |
# Streamlit interface
|
| 35 |
st.title("Chat with Codestral Model")
|
| 36 |
-
system_message = st.text_input("System message", value="You are an expert python coder with in
|
| 37 |
max_tokens = st.slider("Max new tokens", min_value=1, max_value=2048, value=2048, step=1)
|
| 38 |
temperature = st.slider("Temperature", min_value=0.0, max_value=1.0, value=0.6, step=0.1)
|
| 39 |
top_p = st.slider("Top-p (nucleus sampling)", min_value=0.1, max_value=1.0, value=0.95, step=0.05)
|
| 40 |
|
| 41 |
-
history
|
| 42 |
-
|
| 43 |
if "history" not in st.session_state:
|
| 44 |
st.session_state.history = []
|
| 45 |
|
|
@@ -52,7 +51,11 @@ def get_response():
|
|
| 52 |
for r in response_generator:
|
| 53 |
response = r
|
| 54 |
st.session_state.history[-1] = (user_input, response)
|
|
|
|
| 55 |
|
| 56 |
-
|
|
|
|
| 57 |
|
|
|
|
| 58 |
st.text_input("Your message:", key="user_input", on_change=get_response)
|
|
|
|
|
|
| 33 |
|
| 34 |
# Streamlit interface
|
| 35 |
st.title("Chat with Codestral Model")
|
| 36 |
+
system_message = st.text_input("System message", value="You are an expert python coder with in-depth knowledge of langchain.")
|
| 37 |
max_tokens = st.slider("Max new tokens", min_value=1, max_value=2048, value=2048, step=1)
|
| 38 |
temperature = st.slider("Temperature", min_value=0.0, max_value=1.0, value=0.6, step=0.1)
|
| 39 |
top_p = st.slider("Top-p (nucleus sampling)", min_value=0.1, max_value=1.0, value=0.95, step=0.05)
|
| 40 |
|
| 41 |
+
# Initialize history in session state
|
|
|
|
| 42 |
if "history" not in st.session_state:
|
| 43 |
st.session_state.history = []
|
| 44 |
|
|
|
|
| 51 |
for r in response_generator:
|
| 52 |
response = r
|
| 53 |
st.session_state.history[-1] = (user_input, response)
|
| 54 |
+
st.session_state.user_input = "" # Clear input after sending
|
| 55 |
|
| 56 |
+
# Display chat history
|
| 57 |
+
st.text_area("Chat History", value="\n".join([f"User: {h[0]}\nAssistant: {h[1]}" for h in st.session_state.history]), height=300, key="chat_history")
|
| 58 |
|
| 59 |
+
# User input
|
| 60 |
st.text_input("Your message:", key="user_input", on_change=get_response)
|
| 61 |
+
|