Ali2206 commited on
Commit
8d8b790
·
verified ·
1 Parent(s): 7174942

Update src/txagent/txagent.py

Browse files
Files changed (1) hide show
  1. src/txagent/txagent.py +11 -4
src/txagent/txagent.py CHANGED
@@ -12,6 +12,10 @@ from tooluniverse import ToolUniverse
12
  from gradio import ChatMessage
13
  from .toolrag import ToolRAGModel
14
  import torch
 
 
 
 
15
 
16
  from .utils import NoRepeatSentenceProcessor, ReasoningTraceChecker, tool_result_format
17
 
@@ -922,8 +926,11 @@ Generate **one summarized sentence** about "function calls' responses" with nece
922
  if each.metadata is not None:
923
  each.metadata['status'] = 'done'
924
  if '[FinalAnswer]' in last_thought or '"name": "Finish",' in last_outputs_str:
925
- final_thought, final_answer = last_thought.split(
926
- '[FinalAnswer]')
 
 
 
927
  history.append(
928
  ChatMessage(role="assistant",
929
  content=final_thought.strip())
@@ -931,8 +938,8 @@ Generate **one summarized sentence** about "function calls' responses" with nece
931
  yield history
932
  history.append(
933
  ChatMessage(
934
- role="assistant", content="**Answer**:\n"+final_answer.strip())
935
  )
936
  yield history
937
  else:
938
- return None
 
12
  from gradio import ChatMessage
13
  from .toolrag import ToolRAGModel
14
  import torch
15
+ # near the top of txagent.py
16
+ import logging
17
+ logger = logging.getLogger(__name__)
18
+ logging.basicConfig(level=logging.INFO)
19
 
20
  from .utils import NoRepeatSentenceProcessor, ReasoningTraceChecker, tool_result_format
21
 
 
926
  if each.metadata is not None:
927
  each.metadata['status'] = 'done'
928
  if '[FinalAnswer]' in last_thought or '"name": "Finish",' in last_outputs_str:
929
+ if '[FinalAnswer]' in last_thought:
930
+ final_thought, final_answer = last_thought.split('[FinalAnswer]', 1)
931
+ else:
932
+ final_thought = ""
933
+ final_answer = last_thought
934
  history.append(
935
  ChatMessage(role="assistant",
936
  content=final_thought.strip())
 
938
  yield history
939
  history.append(
940
  ChatMessage(
941
+ role="assistant", content="**Answer**:\n" + final_answer.strip())
942
  )
943
  yield history
944
  else:
945
+ return None