Paperbag commited on
Commit
2337449
·
1 Parent(s): 55f8ad2

Refine answer_message function in agent.py to improve response generation. Updated prompt structure to guide the model in providing concise answers without thought processes, ensuring clarity in responses.

Browse files
Files changed (1) hide show
  1. agent.py +16 -3
agent.py CHANGED
@@ -32,10 +32,23 @@ def read_message(state: AgentState) -> AgentState:
32
 
33
  def answer_message(state: AgentState) -> AgentState:
34
  messages = state["messages"]
35
- # Invoke the chat model with the conversation so far
36
- response = model.invoke(messages)
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  # Append the model's answer to the messages list
38
- return {"messages": messages + [response]}
39
 
40
 
41
  def build_graph():
 
32
 
33
  def answer_message(state: AgentState) -> AgentState:
34
  messages = state["messages"]
35
+ prompt = f"""
36
+ You are a GAIA question answering expert.
37
+ Your task is to provide an answer to a question.
38
+ Think carefully before answering the question.
39
+ Do not include any thought process before answering the question, and only response exactly what was being asked of you.
40
+ If you are not able to provide an answer, please state the limitation that you're facing instead.
41
+
42
+ Example question: How many hours are there in a day?
43
+ Response: 24
44
+
45
+ Here is the question:
46
+ {messages}
47
+
48
+ """
49
+ response = model.invoke(prompt)
50
  # Append the model's answer to the messages list
51
+ return {"messages": prompt + [response]}
52
 
53
 
54
  def build_graph():