devchavda11 commited on
Commit
863fe0f
·
verified ·
1 Parent(s): 2131100

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +9 -5
src/streamlit_app.py CHANGED
@@ -104,20 +104,24 @@ if "current_chat_id" in st.session_state:
104
  with st.chat_message("assistant"):
105
  response_placeholder = st.empty()
106
  full_response = ""
107
-
 
108
  for message, metadata in workflow.stream(
109
  {"messages": [system, HumanMessage(user_input)]},
110
  config={"configurable": {"thread_id": st.session_state.current_chat_id}},
111
  stream_mode="messages",
112
  ):
 
113
  if isinstance(message, AIMessage):
114
  full_response += message.content or ""
 
 
115
  elif isinstance(message, ToolMessage):
116
  st.info("Using Appropriate tool")
117
- tool_name = message.tool_calls[0]['name']
118
  if(tool_name == "read_file" or tool_name == "write_file"):
119
- create_download_link(message.content)
 
120
 
121
 
122
- response_placeholder.markdown(full_response + "|")
123
- st.rerun()
 
104
  with st.chat_message("assistant"):
105
  response_placeholder = st.empty()
106
  full_response = ""
107
+ tool_name = ""
108
+ tool_download_msg = ""
109
  for message, metadata in workflow.stream(
110
  {"messages": [system, HumanMessage(user_input)]},
111
  config={"configurable": {"thread_id": st.session_state.current_chat_id}},
112
  stream_mode="messages",
113
  ):
114
+ tool_link = ""
115
  if isinstance(message, AIMessage):
116
  full_response += message.content or ""
117
+ if(message.tool_calls):
118
+ tool_name = message.tool_calls[0]['name']
119
  elif isinstance(message, ToolMessage):
120
  st.info("Using Appropriate tool")
121
+
122
  if(tool_name == "read_file" or tool_name == "write_file"):
123
+ tool_download_msg += message.content
124
+ tool_link = create_download_link(tool_download_msg)
125
 
126
 
127
+ response_placeholder.markdown(full_response + "|")