Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,14 +11,25 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 11 |
# --- Basic Agent Definition ---
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
class BasicAgent:
|
|
|
|
|
|
|
| 14 |
def __init__(self):
|
| 15 |
print("BasicAgent initialized.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def __call__(self, question: str) -> str:
|
| 17 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 20 |
return fixed_answer
|
| 21 |
|
|
|
|
| 22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 23 |
"""
|
| 24 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
|
|
| 11 |
# --- Basic Agent Definition ---
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
class BasicAgent:
|
| 14 |
+
"""A langgraph agent."""
|
| 15 |
+
global llm
|
| 16 |
def __init__(self):
|
| 17 |
print("BasicAgent initialized.")
|
| 18 |
+
|
| 19 |
+
llm = ga.connect_models()
|
| 20 |
+
self.agent = ga.create_agent_workflow()
|
| 21 |
+
|
| 22 |
+
|
| 23 |
def __call__(self, question: str) -> str:
|
| 24 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 25 |
+
result = self.agent.invoke({
|
| 26 |
+
"question": question
|
| 27 |
+
})
|
| 28 |
+
fixed_answer = result.get("final_answer", "No answer generated")
|
| 29 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 30 |
return fixed_answer
|
| 31 |
|
| 32 |
+
|
| 33 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 34 |
"""
|
| 35 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|