Hugescoot commited on
Commit
6ac16c4
·
verified ·
1 Parent(s): 0ad30f2

Update agent/nodes.py

Browse files
Files changed (1) hide show
  1. agent/nodes.py +14 -8
agent/nodes.py CHANGED
@@ -921,11 +921,14 @@ def AnswerRefinementNode(state: AgentState) -> AgentState:
921
  Original Question: {question}
922
  Initial Answer: {initial_answer}
923
  Extracted Context/Data: {extracted_data if extracted_data else "No specific data was extracted, the answer was generated based on general knowledge or initial processing."}
924
-
925
- Your task is to critically review the Initial Answer in the context of the Original Question and Extracted Context/Data.
926
- Refine the Initial Answer to ensure it is accurate, directly answers the question, and strictly follows the FINAL ANSWER formatting rules.
927
- If the Initial Answer seems correct and appropriately formatted, you can simply re-state it.
928
- If the Initial Answer is "unknown" or an error message, try to re-evaluate the question using the available context to provide a valid answer if possible.
 
 
 
929
 
930
  Strict FINAL ANSWER formatting rules:
931
  - A number OR
@@ -943,9 +946,12 @@ def AnswerRefinementNode(state: AgentState) -> AgentState:
943
  3. For comma-separated lists:
944
  - Apply the above rules to each element
945
  - Separate elements with commas only (no spaces unless part of the element)
946
-
947
- Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
948
- """
 
 
 
949
 
950
  response = client.chat.completions.create(
951
  model="gpt-4-turbo",
 
921
  Original Question: {question}
922
  Initial Answer: {initial_answer}
923
  Extracted Context/Data: {extracted_data if extracted_data else "No specific data was extracted, the answer was generated based on general knowledge or initial processing."}
924
+
925
+ Your task is to review and improve the Initial Answer ONLY if there are clear issues.
926
+
927
+ IMPORTANT: If the Initial Answer appears reasonable and addresses the question, KEEP IT AS IS.
928
+ Only change the answer if you can clearly identify one of these problems:
929
+ 1. Formatting issues (wrong format for the expected answer type)
930
+ 2. Clear factual errors that you can correct with the provided context
931
+ 3. The answer doesn't actually address the question asked
932
 
933
  Strict FINAL ANSWER formatting rules:
934
  - A number OR
 
946
  3. For comma-separated lists:
947
  - Apply the above rules to each element
948
  - Separate elements with commas only (no spaces unless part of the element)
949
+
950
+ If you cannot make a clear improvement, return the Initial Answer unchanged.
951
+
952
+ DO NOT change a reasonable answer to "unknown" unless the Initial Answer is clearly wrong or irrelevant.
953
+
954
+ {SYSTEM_PROMPT.strip()}"""
955
 
956
  response = client.chat.completions.create(
957
  model="gpt-4-turbo",