second try
#2
by
tongilcoto
- opened
- app.py +7 -1
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -95,9 +95,12 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 95 |
"""
|
| 96 |
|
| 97 |
print(f"Running agent on {len(questions_data)} questions...")
|
|
|
|
| 98 |
for item in questions_data:
|
| 99 |
task_id = item.get("task_id")
|
| 100 |
question_text = item.get("question")
|
|
|
|
|
|
|
| 101 |
if not task_id or question_text is None:
|
| 102 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 103 |
continue
|
|
@@ -114,7 +117,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 114 |
]
|
| 115 |
messages = [SystemMessage(content=prompt), HumanMessage(content=question_content)]
|
| 116 |
submitted_answer = agent.invoke({"messages": messages})
|
| 117 |
-
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
| 118 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 119 |
except Exception as e:
|
| 120 |
print(f"Error running agent on task {task_id}: {e}")
|
|
@@ -131,6 +134,9 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 131 |
|
| 132 |
# 5. Submit
|
| 133 |
print(f"Submitting {len(answers_payload)} answers to: {submit_url}")
|
|
|
|
|
|
|
|
|
|
| 134 |
try:
|
| 135 |
response = requests.post(submit_url, json=submission_data, timeout=60)
|
| 136 |
response.raise_for_status()
|
|
|
|
| 95 |
"""
|
| 96 |
|
| 97 |
print(f"Running agent on {len(questions_data)} questions...")
|
| 98 |
+
i = 1
|
| 99 |
for item in questions_data:
|
| 100 |
task_id = item.get("task_id")
|
| 101 |
question_text = item.get("question")
|
| 102 |
+
print(f"Question #{i}. Task id: {task_id}")
|
| 103 |
+
i += 1
|
| 104 |
if not task_id or question_text is None:
|
| 105 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 106 |
continue
|
|
|
|
| 117 |
]
|
| 118 |
messages = [SystemMessage(content=prompt), HumanMessage(content=question_content)]
|
| 119 |
submitted_answer = agent.invoke({"messages": messages})
|
| 120 |
+
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer['messages'][-1].content})
|
| 121 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
| 122 |
except Exception as e:
|
| 123 |
print(f"Error running agent on task {task_id}: {e}")
|
|
|
|
| 134 |
|
| 135 |
# 5. Submit
|
| 136 |
print(f"Submitting {len(answers_payload)} answers to: {submit_url}")
|
| 137 |
+
print("Payload:")
|
| 138 |
+
print(answers_payload)
|
| 139 |
+
print('------')
|
| 140 |
try:
|
| 141 |
response = requests.post(submit_url, json=submission_data, timeout=60)
|
| 142 |
response.raise_for_status()
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
gradio
|
|
|
|
| 2 |
requests
|
| 3 |
langchain
|
| 4 |
langchain-community
|
|
|
|
| 1 |
gradio
|
| 2 |
+
gradio[oauth]
|
| 3 |
requests
|
| 4 |
langchain
|
| 5 |
langchain-community
|