- BasicAgent.py +3 -3
- CustomAgent.py +3 -1
- utils.py +8 -1
BasicAgent.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
class BasicAgent:
|
| 2 |
def __init__(self):
|
|
|
|
| 3 |
print("BasicAgent initialized.")
|
| 4 |
def __call__(self, question: str) -> str:
|
| 5 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
return fixed_answer
|
|
|
|
| 1 |
class BasicAgent:
|
| 2 |
def __init__(self):
|
| 3 |
+
self.__fixed_answer = "This is a default answer."
|
| 4 |
print("BasicAgent initialized.")
|
| 5 |
def __call__(self, question: str) -> str:
|
| 6 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 7 |
+
print(f"Agent returning fixed answer: {self.__fixed_answer}")
|
| 8 |
+
return self.__fixed_answer
|
|
|
CustomAgent.py
CHANGED
|
@@ -2,4 +2,6 @@ from BasicAgent import BasicAgent
|
|
| 2 |
|
| 3 |
|
| 4 |
class CustomAgent(BasicAgent):
|
| 5 |
-
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
class CustomAgent(BasicAgent):
|
| 5 |
+
def __init__(self):
|
| 6 |
+
self.__fixed_answer = "This is a custom default answer."
|
| 7 |
+
print("CustomAgent initialized.")
|
utils.py
CHANGED
|
@@ -23,7 +23,7 @@ def get_agents(namespace: dict[str, type], parent_cls: object) -> dict[str, type
|
|
| 23 |
}
|
| 24 |
|
| 25 |
|
| 26 |
-
def run_and_submit_all(profile: gr.OAuthProfile | None,
|
| 27 |
"""
|
| 28 |
Fetches all questions, runs the agent on them, submits all answers,
|
| 29 |
and displays the results.
|
|
@@ -39,6 +39,13 @@ def run_and_submit_all(profile: gr.OAuthProfile | None, agent: BasicAgent) -> tu
|
|
| 39 |
questions_url = f"{api_url}/questions"
|
| 40 |
submit_url = f"{api_url}/submit"
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
# 1. Fetch Questions
|
| 43 |
print(f"Fetching questions from: {questions_url}")
|
| 44 |
try:
|
|
|
|
| 23 |
}
|
| 24 |
|
| 25 |
|
| 26 |
+
def run_and_submit_all(profile: gr.OAuthProfile | None, agent_cls: BasicAgent) -> tuple[str, Any]:
|
| 27 |
"""
|
| 28 |
Fetches all questions, runs the agent on them, submits all answers,
|
| 29 |
and displays the results.
|
|
|
|
| 39 |
questions_url = f"{api_url}/questions"
|
| 40 |
submit_url = f"{api_url}/submit"
|
| 41 |
|
| 42 |
+
# 1. Instantiate Agent
|
| 43 |
+
try:
|
| 44 |
+
agent = agent_cls()
|
| 45 |
+
except Exception as e:
|
| 46 |
+
print(f"Error instantiating agent: {e}")
|
| 47 |
+
return f"Error initializing agent: {e}", None
|
| 48 |
+
|
| 49 |
# 1. Fetch Questions
|
| 50 |
print(f"Fetching questions from: {questions_url}")
|
| 51 |
try:
|