Refactor answer_message function to clean up final response handling by removing redundant print statement and trimming the response content for better formatting.
Browse files
agent.py
CHANGED
|
@@ -132,10 +132,9 @@ def answer_message(state: AgentState) -> AgentState:
|
|
| 132 |
|
| 133 |
final_response = model_with_tools.invoke(messages)
|
| 134 |
|
| 135 |
-
# Step 3: Pass results back to model for final response
|
| 136 |
-
print(f"Messages: {messages}")
|
| 137 |
# final_response = model_with_tools.invoke(messages)
|
| 138 |
print(f"Final response: {final_response}")
|
|
|
|
| 139 |
|
| 140 |
# Append the model's answer to the messages list
|
| 141 |
return {"messages": [final_response]}
|
|
|
|
| 132 |
|
| 133 |
final_response = model_with_tools.invoke(messages)
|
| 134 |
|
|
|
|
|
|
|
| 135 |
# final_response = model_with_tools.invoke(messages)
|
| 136 |
print(f"Final response: {final_response}")
|
| 137 |
+
final_response.content.split('</think>')[1].trim()
|
| 138 |
|
| 139 |
# Append the model's answer to the messages list
|
| 140 |
return {"messages": [final_response]}
|