Update app.py
Browse files
app.py
CHANGED
|
@@ -4,20 +4,40 @@ import requests
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 10 |
|
| 11 |
# --- Basic Agent Definition ---
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
-
class
|
| 14 |
def __init__(self):
|
| 15 |
-
print("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def __call__(self, question: str) -> str:
|
| 17 |
-
print(f"
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 23 |
"""
|
|
@@ -40,7 +60,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 40 |
|
| 41 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 42 |
try:
|
| 43 |
-
agent =
|
| 44 |
except Exception as e:
|
| 45 |
print(f"Error instantiating agent: {e}")
|
| 46 |
return f"Error initializing agent: {e}", None
|
|
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
|
| 7 |
+
from base_agent import BaseAgent
|
| 8 |
+
from router import RouterAgent
|
| 9 |
+
from research_agent import ResearchAgent
|
| 10 |
+
|
| 11 |
# (Keep Constants as is)
|
| 12 |
# --- Constants ---
|
| 13 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 14 |
|
| 15 |
# --- Basic Agent Definition ---
|
| 16 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 17 |
+
class MultiAgents:
|
| 18 |
def __init__(self):
|
| 19 |
+
print("Initializing MultiAgents.")
|
| 20 |
+
|
| 21 |
+
self.orchestrator = RouterAgent()
|
| 22 |
+
self.research_agent = ResearchAgent()
|
| 23 |
+
|
| 24 |
+
# Register agents with detailed descriptions to help the LLM make better routing decisions
|
| 25 |
+
self.orchestrator.register_agent(
|
| 26 |
+
"research_question",
|
| 27 |
+
self.research_agent,
|
| 28 |
+
"Handles general factual questions requiring web search or knowledge retrieval. Good for questions about people, events, organizations, or facts that require research."
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
print("MultiAgent successfully initialized")
|
| 32 |
+
|
| 33 |
def __call__(self, question: str) -> str:
|
| 34 |
+
print(f"MultiAgent received question (first 50 chars): {question[:50]}...")
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
#fixed_answer = "This is a default answer."
|
| 38 |
+
#print(f"Agent returning fixed answer: {fixed_answer}")
|
| 39 |
+
#return fixed_answer
|
| 40 |
+
return self.orchestrator(question)
|
| 41 |
|
| 42 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 43 |
"""
|
|
|
|
| 60 |
|
| 61 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 62 |
try:
|
| 63 |
+
agent = MultiAgents()
|
| 64 |
except Exception as e:
|
| 65 |
print(f"Error instantiating agent: {e}")
|
| 66 |
return f"Error initializing agent: {e}", None
|