Basic agent structure
Browse files
app.py
CHANGED
|
@@ -59,7 +59,7 @@ class BasicAgent:
|
|
| 59 |
def __call__(self, question: str) -> Tuple[str, TypedDict]:
|
| 60 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 61 |
state = State(question=question, messages=[HumanMessage(content=question)])
|
| 62 |
-
fixed_answer = self.assistant(state)
|
| 63 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 64 |
return fixed_answer, state
|
| 65 |
|
|
@@ -163,7 +163,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 163 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 164 |
continue
|
| 165 |
try:
|
| 166 |
-
submitted_answer = agent(question_text)
|
| 167 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 168 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 169 |
except Exception as e:
|
|
@@ -225,13 +225,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 225 |
|
| 226 |
def check_agent(question: str):
|
| 227 |
agent = BasicAgent()
|
| 228 |
-
logs =
|
| 229 |
-
f"Received question: {question}",
|
| 230 |
-
"Calling tool: Search...",
|
| 231 |
-
"Tool returned results.",
|
| 232 |
-
"Reasoning based on tool output...",
|
| 233 |
-
]
|
| 234 |
-
final_answer = agent(question)
|
| 235 |
return final_answer, "\n".join(logs)
|
| 236 |
|
| 237 |
|
|
|
|
| 59 |
def __call__(self, question: str) -> Tuple[str, TypedDict]:
|
| 60 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 61 |
state = State(question=question, messages=[HumanMessage(content=question)])
|
| 62 |
+
fixed_answer = self.assistant(state)["messages"][0].content
|
| 63 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 64 |
return fixed_answer, state
|
| 65 |
|
|
|
|
| 163 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 164 |
continue
|
| 165 |
try:
|
| 166 |
+
submitted_answer, logs = agent(question_text)
|
| 167 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 168 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 169 |
except Exception as e:
|
|
|
|
| 225 |
|
| 226 |
def check_agent(question: str):
|
| 227 |
agent = BasicAgent()
|
| 228 |
+
final_answer, logs = agent(question)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
return final_answer, "\n".join(logs)
|
| 230 |
|
| 231 |
|