Spaces:
Sleeping
Sleeping
Update agent/nodes.py
Browse files- 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
|
| 926 |
-
|
| 927 |
-
If the Initial Answer
|
| 928 |
-
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 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",
|