Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,12 +18,13 @@ class BasicAgent:
|
|
| 18 |
def __init__(self):
|
| 19 |
print("BasicAgent initialized.")
|
| 20 |
self.agent_graph = build_graph()
|
| 21 |
-
def __call__(self,
|
| 22 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 23 |
|
| 24 |
messages = [HumanMessage(content=f"Can you answer this question please ? {question}")]
|
| 25 |
|
| 26 |
-
|
|
|
|
| 27 |
messages = self.agent_graph.invoke(
|
| 28 |
input={"messages": messages, "question": question, "input_file": file_name},
|
| 29 |
config={
|
|
@@ -106,12 +107,14 @@ def try_one_question( profile: gr.OAuthProfile | None):
|
|
| 106 |
for item in questions_data:
|
| 107 |
task_id = item.get("task_id")
|
| 108 |
question_text = item.get("question")
|
|
|
|
| 109 |
print(f"question: {question_text}")
|
|
|
|
| 110 |
if not task_id or question_text is None:
|
| 111 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 112 |
continue
|
| 113 |
try:
|
| 114 |
-
submitted_answer = agent(question_text)
|
| 115 |
print(f"SUBMITTED_ANSWER : {submitted_answer}")
|
| 116 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 117 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
|
|
|
| 18 |
def __init__(self):
|
| 19 |
print("BasicAgent initialized.")
|
| 20 |
self.agent_graph = build_graph()
|
| 21 |
+
def __call__(self, input: str) -> str:
|
| 22 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 23 |
|
| 24 |
messages = [HumanMessage(content=f"Can you answer this question please ? {question}")]
|
| 25 |
|
| 26 |
+
question = input.get("question", "No question provided")
|
| 27 |
+
file_name = input.get("file_name", "")
|
| 28 |
messages = self.agent_graph.invoke(
|
| 29 |
input={"messages": messages, "question": question, "input_file": file_name},
|
| 30 |
config={
|
|
|
|
| 107 |
for item in questions_data:
|
| 108 |
task_id = item.get("task_id")
|
| 109 |
question_text = item.get("question")
|
| 110 |
+
question_file = item.get("file_name")
|
| 111 |
print(f"question: {question_text}")
|
| 112 |
+
print(f"file_name: {question_file}")
|
| 113 |
if not task_id or question_text is None:
|
| 114 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 115 |
continue
|
| 116 |
try:
|
| 117 |
+
submitted_answer = agent(input={"question": question_text, "file_name": question_file})
|
| 118 |
print(f"SUBMITTED_ANSWER : {submitted_answer}")
|
| 119 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 120 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|