Update agent.py
Browse files
agent.py
CHANGED
@@ -56,25 +56,33 @@ def build_agent():
|
|
56 |
|
57 |
tools = [use_wikipedia_tool, use_search_tool]
|
58 |
|
59 |
-
system_template = (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
"You are a helpful, friendly, and respectful AI assistant. "
|
61 |
"Always address the user politely and answer their questions in a positive manner.\n"
|
62 |
-
"
|
63 |
-
"Thought: [your reasoning here]\n"
|
64 |
-
"Action: [the action to take, should be one of [{tool_names}]]\n"
|
65 |
-
"Action Input: [the input to the action]\n"
|
66 |
-
"If you know the answer without using a tool, respond with:\n"
|
67 |
-
"Thought: [your reasoning here]\n"
|
68 |
"Final Answer: [your answer here]\n"
|
69 |
"Always ensure your responses are polite, accurate, and helpful."
|
70 |
)
|
71 |
-
system_prompt = SystemMessage(content=system_template.format(
|
72 |
-
tool_names=", ".join([tool.name for tool in tools])
|
73 |
-
))
|
74 |
|
75 |
def call_model(state: MessagesState):
|
76 |
"""Call the LLM with the given state."""
|
77 |
-
messages = state["messages"]
|
78 |
response = llm.invoke(messages)
|
79 |
return {"messages" : response}
|
80 |
|
|
|
56 |
|
57 |
tools = [use_wikipedia_tool, use_search_tool]
|
58 |
|
59 |
+
# system_template = (
|
60 |
+
# "You are a helpful, friendly, and respectful AI assistant. "
|
61 |
+
# "Always address the user politely and answer their questions in a positive manner.\n"
|
62 |
+
# "When reasoning, always use the following format:\n"
|
63 |
+
# "Thought: [your reasoning here]\n"
|
64 |
+
# "Action: [the action to take, should be one of [{tool_names}]]\n"
|
65 |
+
# "Action Input: [the input to the action]\n"
|
66 |
+
# "If you know the answer without using a tool, respond with:\n"
|
67 |
+
# "Thought: [your reasoning here]\n"
|
68 |
+
# "Final Answer: [your answer here]\n"
|
69 |
+
# "Always ensure your responses are polite, accurate, and helpful."
|
70 |
+
# )
|
71 |
+
# system_prompt = SystemMessage(content=system_template.format(
|
72 |
+
# tool_names=", ".join([tool.name for tool in tools])
|
73 |
+
# ))
|
74 |
+
|
75 |
+
system_template = (
|
76 |
"You are a helpful, friendly, and respectful AI assistant. "
|
77 |
"Always address the user politely and answer their questions in a positive manner.\n"
|
78 |
+
"If you know the answer then respond with:\n"
|
|
|
|
|
|
|
|
|
|
|
79 |
"Final Answer: [your answer here]\n"
|
80 |
"Always ensure your responses are polite, accurate, and helpful."
|
81 |
)
|
|
|
|
|
|
|
82 |
|
83 |
def call_model(state: MessagesState):
|
84 |
"""Call the LLM with the given state."""
|
85 |
+
messages = system_template + state["messages"]
|
86 |
response = llm.invoke(messages)
|
87 |
return {"messages" : response}
|
88 |
|