Entz commited on
Commit
f243b87
·
verified ·
1 Parent(s): 710a86a

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -71,7 +71,8 @@ if "agent" not in st.session_state or st.session_state.get("current_model") != m
71
  if "memory" not in st.session_state:
72
  st.session_state.memory = AgentMemory()
73
  initial_message = BaseAgentOutputSchema(chat_message="Hello! I'm here to help with math problems. What can I assist you with today?")
74
- st.session_state.memory.add_message("assistant", initial_message)
 
75
  st.session_state.conversation = [("assistant", initial_message.chat_message)]
76
  st.session_state.agent = BaseAgent(config=BaseAgentConfig(
77
  client=client,
@@ -103,7 +104,7 @@ if user_input:
103
  # Add user message to conversation and memory
104
  st.session_state.conversation.append(("user", user_input))
105
  input_schema = BaseAgentInputSchema(chat_message=user_input)
106
- st.session_state.memory.add_message("user", input_schema)
107
 
108
  # Display user message immediately
109
  with st.chat_message("user"):
@@ -122,7 +123,7 @@ if user_input:
122
 
123
  # After streaming completes, add the final response to conversation and memory
124
  st.session_state.conversation.append(("assistant", current_response))
125
- st.session_state.memory.add_message("assistant", BaseAgentOutputSchema(chat_message=current_response))
126
 
127
  # Run the async function
128
  asyncio.run(stream_response())
 
71
  if "memory" not in st.session_state:
72
  st.session_state.memory = AgentMemory()
73
  initial_message = BaseAgentOutputSchema(chat_message="Hello! I'm here to help with math problems. What can I assist you with today?")
74
+ # Pass the chat_message string instead of the BaseAgentOutputSchema object
75
+ st.session_state.memory.add_message("assistant", initial_message.chat_message)
76
  st.session_state.conversation = [("assistant", initial_message.chat_message)]
77
  st.session_state.agent = BaseAgent(config=BaseAgentConfig(
78
  client=client,
 
104
  # Add user message to conversation and memory
105
  st.session_state.conversation.append(("user", user_input))
106
  input_schema = BaseAgentInputSchema(chat_message=user_input)
107
+ st.session_state.memory.add_message("user", input_schema.chat_message) # Pass the chat_message string
108
 
109
  # Display user message immediately
110
  with st.chat_message("user"):
 
123
 
124
  # After streaming completes, add the final response to conversation and memory
125
  st.session_state.conversation.append(("assistant", current_response))
126
+ st.session_state.memory.add_message("assistant", current_response) # Pass the string directly
127
 
128
  # Run the async function
129
  asyncio.run(stream_response())