Enable chat mode for bot interactions and ensure bot responses are consistently converted to strings.

main
lasseedfast 8 months ago
parent ae87ea1c63
commit 638e2a00d3
  1. 14
      streamlit_chatbot.py

@ -401,7 +401,7 @@ class Bot(BaseClass):
DON'T come up with your own tools, only use the ones provided.
""",
# system_message='Use one of the provided tools to help the answering bot to answer the user. Do not answer directly. Use the "tool_calls" field in your answer.',
chat=False,
chat=True,
model="tools",
)
if len(tools_names) > 1 and "conversational_response_tool" in tools_names:
@ -996,7 +996,7 @@ class StreamlitBot(Bot):
else:
bot_response = self.write_normal(response_text)
bot_responses.append(bot_response)
bot_responses.append(str(bot_response))
if chunks:
sources = "###### Sources:\n"
@ -1010,12 +1010,12 @@ class StreamlitBot(Bot):
sources += f"[{group['article_number']}] **{title}** :gray[*{j}* ({d})] \n"
st.markdown(sources)
bot_response += f"\n\n{sources}"
bot_responses.append(bot_response)
bot_responses.append(str(bot_response))
elif function_name == "fetch_notes_tool":
notes = getattr(self, function_name)()
response_text = self.generate_from_notes(user_input, notes)
bot_responses.append(st.write_stream(response_text).strip('"'))
bot_responses.append(str(st.write_stream(response_text).strip('"')))
elif function_name == "conversational_response_tool":
response_text = getattr(self, function_name)(user_input)
@ -1066,7 +1066,7 @@ class StreamlitBot(Bot):
for mode, text in chunks_iter:
yield (mode, text)
bot_response = st.write_stream(full_gen()).strip('"')
bot_response = st.write_stream(full_gen())
def write_normal(self, response_text):
chunks_iter = iter(response_text) # convert generator to iterator
@ -1079,7 +1079,7 @@ class StreamlitBot(Bot):
else:
yield chunk
bot_response = st.write_stream(full_gen()).strip('"')
bot_response = st.write_stream(full_gen())
return bot_response
def generate_from_notes(self, user_input, notes):
@ -1281,7 +1281,7 @@ class HostBot(StreamlitBot):
Choose one or many tools to use in order to assist the host in asking relevant questions.
Often "conversational_response_tool" is enough, but sometimes project notes are needed.
Make sure to read the description of the tools carefully!""",
chat=False,
chat=True,
model="tools",
)

Loading…
Cancel
Save