feat: stream LLM responses and improve agent UI
This commit is contained in:
@@ -45,14 +45,9 @@ def agent_runner_loop(client, system_prompt, user_input, handler, tools_schema,
|
||||
]
|
||||
for turn in range(max_turns):
|
||||
yield f"**LLM Running (Turn {turn+1}) ...**\n\n"
|
||||
response = client.chat(messages=messages, tools=tools_schema)
|
||||
|
||||
if response.thinking: yield '<thinking>' + response.thinking + '</thinking>\n\n'
|
||||
showcontent = response.content
|
||||
if '</summary>' in showcontent: showcontent = showcontent.replace('</summary>', '</summary>\n\n')
|
||||
if '</file_content>' in showcontent:
|
||||
showcontent = re.sub(r'<file_content>\s*(.*?)\s*</file_content>', r'\n````\n<file_content>\n\1\n</file_content>\n````', showcontent, flags=re.DOTALL)
|
||||
yield showcontent + '\n\n'
|
||||
response_gen = client.chat(messages=messages, tools=tools_schema)
|
||||
response = yield from response_gen
|
||||
yield '\n\n'
|
||||
|
||||
if not response.tool_calls:
|
||||
tool_name, args = 'no_tool', {}
|
||||
|
||||
Reference in New Issue
Block a user