Update src/txagent/txagent.py
Browse files- src/txagent/txagent.py +1 -4
src/txagent/txagent.py
CHANGED
@@ -317,7 +317,6 @@ class TxAgent:
|
|
317 |
)
|
318 |
sub_agent_task = "Sub TxAgent plan: " + \
|
319 |
str(solution_plan)
|
320 |
-
# When streaming, yield responses as they arrive.
|
321 |
call_result = yield from self.run_gradio_chat(
|
322 |
full_message, history=[], temperature=temperature,
|
323 |
max_new_tokens=1024, max_token=99999,
|
@@ -325,7 +324,7 @@ class TxAgent:
|
|
325 |
conversation=None,
|
326 |
sub_agent_task=sub_agent_task)
|
327 |
|
328 |
-
if call_result is not None:
|
329 |
call_result = call_result.split('[FinalAnswer]')[-1]
|
330 |
else:
|
331 |
call_result = "⚠️ No content returned from sub-agent."
|
@@ -345,7 +344,6 @@ class TxAgent:
|
|
345 |
if function_call_json[i]["name"] == 'Tool_RAG':
|
346 |
gradio_history.append(ChatMessage(role="assistant", content=str(call_result), metadata={
|
347 |
"title": "🧰 "+function_call_json[i]['name'], "log": str(function_call_json[i]['arguments'])}))
|
348 |
-
|
349 |
else:
|
350 |
gradio_history.append(ChatMessage(role="assistant", content=str(call_result), metadata={
|
351 |
"title": "⚒️ "+function_call_json[i]['name'], "log": str(function_call_json[i]['arguments'])}))
|
@@ -361,7 +359,6 @@ class TxAgent:
|
|
361 |
"tool_calls": json.dumps(function_call_json)
|
362 |
}] + call_results
|
363 |
|
364 |
-
# Yield the final result.
|
365 |
if return_gradio_history:
|
366 |
return revised_messages, existing_tools_prompt, special_tool_call, gradio_history
|
367 |
else:
|
|
|
317 |
)
|
318 |
sub_agent_task = "Sub TxAgent plan: " + \
|
319 |
str(solution_plan)
|
|
|
320 |
call_result = yield from self.run_gradio_chat(
|
321 |
full_message, history=[], temperature=temperature,
|
322 |
max_new_tokens=1024, max_token=99999,
|
|
|
324 |
conversation=None,
|
325 |
sub_agent_task=sub_agent_task)
|
326 |
|
327 |
+
if call_result is not None and isinstance(call_result, str):
|
328 |
call_result = call_result.split('[FinalAnswer]')[-1]
|
329 |
else:
|
330 |
call_result = "⚠️ No content returned from sub-agent."
|
|
|
344 |
if function_call_json[i]["name"] == 'Tool_RAG':
|
345 |
gradio_history.append(ChatMessage(role="assistant", content=str(call_result), metadata={
|
346 |
"title": "🧰 "+function_call_json[i]['name'], "log": str(function_call_json[i]['arguments'])}))
|
|
|
347 |
else:
|
348 |
gradio_history.append(ChatMessage(role="assistant", content=str(call_result), metadata={
|
349 |
"title": "⚒️ "+function_call_json[i]['name'], "log": str(function_call_json[i]['arguments'])}))
|
|
|
359 |
"tool_calls": json.dumps(function_call_json)
|
360 |
}] + call_results
|
361 |
|
|
|
362 |
if return_gradio_history:
|
363 |
return revised_messages, existing_tools_prompt, special_tool_call, gradio_history
|
364 |
else:
|