Spaces:
Sleeping
Sleeping
graph test
Browse files
app.py
CHANGED
|
@@ -137,20 +137,6 @@ class BasicAgent:
|
|
| 137 |
def final_answer(self, state: AnswerState) -> Dict[str, Any]:
|
| 138 |
print(f"[final_answer] Agent returning answer: {state['answer']}")
|
| 139 |
answer = state["answer"] if state["answer"] else "I don't know"
|
| 140 |
-
|
| 141 |
-
if not state["is_final_answer"]:
|
| 142 |
-
state["messages"].append(
|
| 143 |
-
ChatMessage(
|
| 144 |
-
role="user",
|
| 145 |
-
content="Based on the information provided, please provide a final answer, no tool calls allowed.",
|
| 146 |
-
)
|
| 147 |
-
)
|
| 148 |
-
response = self.model.invoke(state["messages"])
|
| 149 |
-
if "FINAL ANSWER:" in response.content:
|
| 150 |
-
answer = response.text().split("FINAL ANSWER:")[-1].strip()
|
| 151 |
-
print(f"Agent final answer: {answer}")
|
| 152 |
-
|
| 153 |
-
answer = state["answer"] if state["answer"] else "I don't know"
|
| 154 |
return {
|
| 155 |
"answer": answer,
|
| 156 |
"is_final_answer": True,
|
|
@@ -187,6 +173,21 @@ class BasicAgent:
|
|
| 187 |
print(
|
| 188 |
f"[exceeded_attempts] Exceeded max number of attempts ({state['attempt']})."
|
| 189 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
return {
|
| 191 |
"answer": "Exceeded max number of attempts.",
|
| 192 |
"is_final_answer": False,
|
|
|
|
| 137 |
def final_answer(self, state: AnswerState) -> Dict[str, Any]:
|
| 138 |
print(f"[final_answer] Agent returning answer: {state['answer']}")
|
| 139 |
answer = state["answer"] if state["answer"] else "I don't know"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
return {
|
| 141 |
"answer": answer,
|
| 142 |
"is_final_answer": True,
|
|
|
|
| 173 |
print(
|
| 174 |
f"[exceeded_attempts] Exceeded max number of attempts ({state['attempt']})."
|
| 175 |
)
|
| 176 |
+
state["messages"].append(
|
| 177 |
+
ChatMessage(
|
| 178 |
+
role="user",
|
| 179 |
+
content="Based on the information provided, please provide a final answer, no tool calls allowed.",
|
| 180 |
+
)
|
| 181 |
+
)
|
| 182 |
+
response = self.model.invoke(state["messages"])
|
| 183 |
+
if "FINAL ANSWER:" in response.content:
|
| 184 |
+
answer = response.text().split("FINAL ANSWER:")[-1].strip()
|
| 185 |
+
print(f"Agent final answer: {answer}")
|
| 186 |
+
|
| 187 |
+
return {
|
| 188 |
+
"answer": answer,
|
| 189 |
+
"is_final_answer": True,
|
| 190 |
+
}
|
| 191 |
return {
|
| 192 |
"answer": "Exceeded max number of attempts.",
|
| 193 |
"is_final_answer": False,
|