Spaces:
Sleeping
Sleeping
Enhance logging in AgentNode's __call__ method in graph.py to track state before and after processing, including detailed information about messages, question, and answer.
Browse files
graph.py
CHANGED
|
@@ -64,11 +64,30 @@ class AgentNode:
|
|
| 64 |
|
| 65 |
def __call__(self, state: AgentState) -> AgentState:
|
| 66 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
# Process the question through the agent
|
|
|
|
| 68 |
result = self.agent.run(state["question"])
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
# Update the state with the answer
|
| 71 |
state["answer"] = result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
return state
|
| 73 |
|
| 74 |
except Exception as e:
|
|
|
|
| 64 |
|
| 65 |
def __call__(self, state: AgentState) -> AgentState:
|
| 66 |
try:
|
| 67 |
+
# Log the current state before processing
|
| 68 |
+
logger.info("Current state before processing:")
|
| 69 |
+
logger.info(f"Messages: {state['messages']}")
|
| 70 |
+
logger.info(f"Question: {state['question']}")
|
| 71 |
+
logger.info(f"Answer: {state['answer']}")
|
| 72 |
+
|
| 73 |
# Process the question through the agent
|
| 74 |
+
logger.info("Calling agent.run()...")
|
| 75 |
result = self.agent.run(state["question"])
|
| 76 |
|
| 77 |
+
# Log the result details
|
| 78 |
+
logger.info("Agent run completed:")
|
| 79 |
+
logger.info(f"Result type: {type(result)}")
|
| 80 |
+
logger.info(f"Result value: {result}")
|
| 81 |
+
|
| 82 |
# Update the state with the answer
|
| 83 |
state["answer"] = result
|
| 84 |
+
|
| 85 |
+
# Log the updated state
|
| 86 |
+
logger.info("Updated state after processing:")
|
| 87 |
+
logger.info(f"Messages: {state['messages']}")
|
| 88 |
+
logger.info(f"Question: {state['question']}")
|
| 89 |
+
logger.info(f"Answer: {state['answer']}")
|
| 90 |
+
|
| 91 |
return state
|
| 92 |
|
| 93 |
except Exception as e:
|