alisamak commited on
Commit
a813a8a
·
verified ·
1 Parent(s): 065eaa9

Update LG_agent.py

Browse files
Files changed (1) hide show
  1. LG_agent.py +15 -1
LG_agent.py CHANGED
@@ -41,8 +41,22 @@ class AgentState(TypedDict):
41
  # 3. Assistant node
42
 
43
  def assistant(state: AgentState):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  return {
45
- "messages": [chat_with_tools.invoke(state["messages"])],
46
  }
47
 
48
  # 4. Build the agent graph
 
41
  # 3. Assistant node
42
 
43
  def assistant(state: AgentState):
44
+ # Inject tools description to a system message
45
+ tool_descriptions = "\n".join([
46
+ f"{tool.name}{inspect.signature(tool.func)}:\n {tool.description.strip()}"
47
+ for tool in all_tools
48
+ ])
49
+
50
+ sys_msg = SystemMessage(
51
+ content=(
52
+ "You are a helpful AI assistant. You solve problems step by step and can use the following tools:\n"
53
+ f"{tool_descriptions}\n"
54
+ "Always plan your response, invoke tools explicitly if needed, and conclude with a direct answer."
55
+ )
56
+ )
57
+
58
  return {
59
+ "messages": [chat_with_tools.invoke([sys_msg] + state["messages"])],
60
  }
61
 
62
  # 4. Build the agent graph