Ali2206 commited on
Commit
d6f220b
·
verified ·
1 Parent(s): 25e0d34

Update src/txagent/txagent.py

Browse files
Files changed (1) hide show
  1. src/txagent/txagent.py +7 -0
src/txagent/txagent.py CHANGED
@@ -640,6 +640,7 @@ Summarize the function calls' responses in one sentence with all necessary infor
640
  try:
641
  while next_round and current_round < max_round:
642
  current_round += 1
 
643
  if last_outputs:
644
  function_call_messages, picked_tools_prompt, special_tool_call, current_gradio_history = yield from self.run_function_call_stream(
645
  last_outputs, return_message=True,
@@ -651,6 +652,7 @@ Summarize the function calls' responses in one sentence with all necessary infor
651
  history.extend(current_gradio_history)
652
 
653
  if special_tool_call == 'Finish':
 
654
  yield history
655
  next_round = False
656
  conversation.extend(function_call_messages)
@@ -659,6 +661,7 @@ Summarize the function calls' responses in one sentence with all necessary infor
659
  elif special_tool_call in ['RequireClarification', 'DirectResponse']:
660
  last_msg = history[-1] if history else ChatMessage(role="assistant", content="Response needed.")
661
  history.append(ChatMessage(role="assistant", content=last_msg.content))
 
662
  yield history
663
  next_round = False
664
  return last_msg.content
@@ -674,6 +677,7 @@ Summarize the function calls' responses in one sentence with all necessary infor
674
  else:
675
  next_round = False
676
  conversation.append({"role": "assistant", "content": ''.join(last_outputs)})
 
677
  return ''.join(last_outputs).replace("</s>", "")
678
 
679
  last_outputs = []
@@ -711,6 +715,7 @@ Summarize the function calls' responses in one sentence with all necessary infor
711
  history.append(ChatMessage(role="assistant", content=final_thought.strip()))
712
  yield history
713
  history.append(ChatMessage(role="assistant", content="**🧠 Final Analysis:**\n" + final_answer.strip()))
 
714
  yield history
715
  else:
716
  history.append(ChatMessage(role="assistant", content=last_thought))
@@ -727,6 +732,7 @@ Summarize the function calls' responses in one sentence with all necessary infor
727
  history.append(ChatMessage(role="assistant", content=final_thought.strip()))
728
  yield history
729
  history.append(ChatMessage(role="assistant", content="**🧠 Final Analysis:**\n" + final_answer.strip()))
 
730
  yield history
731
  else:
732
  yield "Reasoning rounds exceeded limit."
@@ -744,5 +750,6 @@ Summarize the function calls' responses in one sentence with all necessary infor
744
  history.append(ChatMessage(role="assistant", content=final_thought.strip()))
745
  yield history
746
  history.append(ChatMessage(role="assistant", content="**🧠 Final Analysis:**\n" + final_answer.strip()))
 
747
  yield history
748
  return error_msg
 
640
  try:
641
  while next_round and current_round < max_round:
642
  current_round += 1
643
+ logger.debug("Starting round %d/%d", current_round, max_round)
644
  if last_outputs:
645
  function_call_messages, picked_tools_prompt, special_tool_call, current_gradio_history = yield from self.run_function_call_stream(
646
  last_outputs, return_message=True,
 
652
  history.extend(current_gradio_history)
653
 
654
  if special_tool_call == 'Finish':
655
+ logger.info("Finish tool called, ending chat")
656
  yield history
657
  next_round = False
658
  conversation.extend(function_call_messages)
 
661
  elif special_tool_call in ['RequireClarification', 'DirectResponse']:
662
  last_msg = history[-1] if history else ChatMessage(role="assistant", content="Response needed.")
663
  history.append(ChatMessage(role="assistant", content=last_msg.content))
664
+ logger.info("Special tool %s called, ending chat", special_tool_call)
665
  yield history
666
  next_round = False
667
  return last_msg.content
 
677
  else:
678
  next_round = False
679
  conversation.append({"role": "assistant", "content": ''.join(last_outputs)})
680
+ logger.info("No function call messages, ending chat")
681
  return ''.join(last_outputs).replace("</s>", "")
682
 
683
  last_outputs = []
 
715
  history.append(ChatMessage(role="assistant", content=final_thought.strip()))
716
  yield history
717
  history.append(ChatMessage(role="assistant", content="**🧠 Final Analysis:**\n" + final_answer.strip()))
718
+ logger.info("Final answer provided: %s", final_answer[:100])
719
  yield history
720
  else:
721
  history.append(ChatMessage(role="assistant", content=last_thought))
 
732
  history.append(ChatMessage(role="assistant", content=final_thought.strip()))
733
  yield history
734
  history.append(ChatMessage(role="assistant", content="**🧠 Final Analysis:**\n" + final_answer.strip()))
735
+ logger.info("Forced final answer: %s", final_answer[:100])
736
  yield history
737
  else:
738
  yield "Reasoning rounds exceeded limit."
 
750
  history.append(ChatMessage(role="assistant", content=final_thought.strip()))
751
  yield history
752
  history.append(ChatMessage(role="assistant", content="**🧠 Final Analysis:**\n" + final_answer.strip()))
753
+ logger.info("Forced final answer after error: %s", final_answer[:100])
754
  yield history
755
  return error_msg