tobyvertommen Claude Sonnet 4.6 commited on
Commit
5762615
·
1 Parent(s): b363f5d

Fix: pass system prompt via SystemMessage instead of state_modifier

Browse files

state_modifier not supported in installed LangGraph version.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -8,6 +8,7 @@ from langchain_community.tools import DuckDuckGoSearchRun, WikipediaQueryRun
8
  from langchain_community.utilities import WikipediaAPIWrapper
9
  from langchain_experimental.tools import PythonREPLTool
10
  from langchain.tools import tool
 
11
 
12
  # --- Constants ---
13
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
@@ -48,14 +49,14 @@ class BasicAgent:
48
  PythonREPLTool(),
49
  fetch_task_file,
50
  ]
51
- self.agent = create_react_agent(llm, tools, state_modifier=SYSTEM_PROMPT)
52
  print("BasicAgent initialized with LangGraph + Groq (llama-3.1-70b-versatile).")
53
 
54
  def __call__(self, question: str, task_id: str = "") -> str:
55
  full_question = f"[Task ID: {task_id}]\n\n{question}" if task_id else question
56
  print(f"Running agent on task {task_id}: {question[:80]}...")
57
  result = self.agent.invoke(
58
- {"messages": [("user", full_question)]},
59
  {"recursion_limit": 50},
60
  )
61
  raw_answer = result["messages"][-1].content
 
8
  from langchain_community.utilities import WikipediaAPIWrapper
9
  from langchain_experimental.tools import PythonREPLTool
10
  from langchain.tools import tool
11
+ from langchain_core.messages import SystemMessage, HumanMessage
12
 
13
  # --- Constants ---
14
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
49
  PythonREPLTool(),
50
  fetch_task_file,
51
  ]
52
+ self.agent = create_react_agent(llm, tools)
53
  print("BasicAgent initialized with LangGraph + Groq (llama-3.1-70b-versatile).")
54
 
55
  def __call__(self, question: str, task_id: str = "") -> str:
56
  full_question = f"[Task ID: {task_id}]\n\n{question}" if task_id else question
57
  print(f"Running agent on task {task_id}: {question[:80]}...")
58
  result = self.agent.invoke(
59
+ {"messages": [SystemMessage(content=SYSTEM_PROMPT), HumanMessage(content=full_question)]},
60
  {"recursion_limit": 50},
61
  )
62
  raw_answer = result["messages"][-1].content