Spaces:
Sleeping
Sleeping
fixed import error
Browse files
agent.py
CHANGED
|
@@ -267,6 +267,8 @@ def prune_messages_for_llm(
|
|
| 267 |
|
| 268 |
def assistant(state: AgentState) -> Dict[str, Any]:
|
| 269 |
"""Assistant node that processes messages and decides on next action."""
|
|
|
|
|
|
|
| 270 |
print("Assistant Called...\n\n")
|
| 271 |
|
| 272 |
full_current_history = state["messages"]
|
|
@@ -305,7 +307,6 @@ def assistant(state: AgentState) -> Dict[str, Any]:
|
|
| 305 |
|
| 306 |
# Create a new response object if it's None
|
| 307 |
if response is None:
|
| 308 |
-
from langchain_core.messages import AIMessage
|
| 309 |
response = AIMessage(content="")
|
| 310 |
print("Created new AIMessage object for None response")
|
| 311 |
|
|
@@ -363,7 +364,6 @@ def assistant(state: AgentState) -> Dict[str, Any]:
|
|
| 363 |
except Exception as e:
|
| 364 |
print(f"Error in LLM invocation: {str(e)}")
|
| 365 |
# Create a fallback response in case of LLM errors
|
| 366 |
-
from langchain_core.messages import AIMessage
|
| 367 |
response = AIMessage(content=(
|
| 368 |
"Thought: I encountered an error in processing. Let me try to proceed with what I know.\n\n"
|
| 369 |
"Final Answer: Unable to complete the task due to an error in processing."
|
|
|
|
| 267 |
|
| 268 |
def assistant(state: AgentState) -> Dict[str, Any]:
|
| 269 |
"""Assistant node that processes messages and decides on next action."""
|
| 270 |
+
from langchain_core.messages import AIMessage # Add import at the start of the function
|
| 271 |
+
|
| 272 |
print("Assistant Called...\n\n")
|
| 273 |
|
| 274 |
full_current_history = state["messages"]
|
|
|
|
| 307 |
|
| 308 |
# Create a new response object if it's None
|
| 309 |
if response is None:
|
|
|
|
| 310 |
response = AIMessage(content="")
|
| 311 |
print("Created new AIMessage object for None response")
|
| 312 |
|
|
|
|
| 364 |
except Exception as e:
|
| 365 |
print(f"Error in LLM invocation: {str(e)}")
|
| 366 |
# Create a fallback response in case of LLM errors
|
|
|
|
| 367 |
response = AIMessage(content=(
|
| 368 |
"Thought: I encountered an error in processing. Let me try to proceed with what I know.\n\n"
|
| 369 |
"Final Answer: Unable to complete the task due to an error in processing."
|