Golfn commited on
Commit
3420ed3
·
1 Parent(s): 6113f9a

modify prompt

Browse files
Files changed (1) hide show
  1. Alfred_Agent.py +20 -16
Alfred_Agent.py CHANGED
@@ -62,26 +62,30 @@ tools = [
62
  chat_with_tools = llm.bind_tools(tools)
63
 
64
  #setting up prompt
65
- ai_message = SystemMessage(content="""You are a helpful assistant tasked with answering questions using a set of tools and reference materials.
66
- You may be provided with a reference set of questions and their corresponding answers from a retriever.
67
- If the current question is the same as or semantically equivalent to a question in the reference set, or if the reference answer clearly applies to the current question, use that answer as your final answer.
68
- Otherwise, reason through the question as needed and report your thoughts before providing the final answer.
69
 
70
- Finish your answer with the following template:
71
- FINAL ANSWER: [YOUR FINAL ANSWER].
72
 
73
- YOUR FINAL ANSWER should be:
74
- - A number without commas or units (unless explicitly requested),
75
- - Or a string without articles or abbreviations, with digits written in plain text unless specified otherwise,
76
- - Or a comma separated list, applying the above rules to each item and ensuring exactly one space after each comma.
77
 
78
- If the question is identical or functionally equivalent to a reference question, respond with:
79
- FINAL ANSWER: [the answer to the reference question].
 
 
 
 
 
 
 
 
 
80
  """)
81
 
82
 
83
 
84
 
 
85
  # Generate the AgentState and Agent graph
86
  from langgraph.graph import MessagesState #the same as AgentState
87
  # class AgentState(TypedDict):
@@ -128,9 +132,9 @@ builder.add_conditional_edges(
128
  builder.add_edge("tools", "assistant")
129
  alfred = builder.compile()
130
 
131
- messages = [HumanMessage(content="When was a picture of St. Thomas Aquinas first added to the Wikipedia page on the Principle of double effect?")]
132
- #messages = [HumanMessage(content="What the remainder of 30 divided by 7?")]
133
- response = alfred.invoke({"messages": messages})
134
 
135
 
136
- print(response['messages'][-1].content)
 
62
  chat_with_tools = llm.bind_tools(tools)
63
 
64
  #setting up prompt
65
+ ai_message = SystemMessage(content="""You are a helpful assistant tasked with answering questions using a set of tools and reference materials.
 
 
 
66
 
67
+ You may be provided with a reference set of questions and answers from a retriever.
68
+ If the current question is identical to or semantically equivalent to a reference question, or if a reference answer clearly applies, use that reference answer directly.
69
 
70
+ Otherwise, reason through the question as needed to determine the correct answer.
 
 
 
71
 
72
+ Always end your response using this format:
73
+ FINAL ANSWER: [YOUR FINAL ANSWER]
74
+
75
+ Formatting rules:
76
+ - If the answer is a number, do not use commas or units (unless specifically requested).
77
+ - If the answer is a string, do not use articles, abbreviations, or short forms. Write digits in full unless specified otherwise.
78
+ - If the answer is a comma-separated list, apply the above rules to each item and include exactly one space after each comma.
79
+ - If the question matches a reference question, reply with:
80
+ FINAL ANSWER: [the answer to the reference question].
81
+
82
+ Do not include any explanation or extra text outside the FINAL ANSWER line.
83
  """)
84
 
85
 
86
 
87
 
88
+
89
  # Generate the AgentState and Agent graph
90
  from langgraph.graph import MessagesState #the same as AgentState
91
  # class AgentState(TypedDict):
 
132
  builder.add_edge("tools", "assistant")
133
  alfred = builder.compile()
134
 
135
+ # messages = [HumanMessage(content="When was a picture of St. Thomas Aquinas first added to the Wikipedia page on the Principle of double effect?")]
136
+ # #messages = [HumanMessage(content="What the remainder of 30 divided by 7?")]
137
+ # response = alfred.invoke({"messages": messages})
138
 
139
 
140
+ # print(response['messages'][-1].content)