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
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 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# Append the model's answer to the messages list
|
| 38 |
-
return {"messages":
|
| 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():
|