Spaces:
Sleeping
Sleeping
BasicCodeAgent
Browse files
app.py
CHANGED
|
@@ -21,7 +21,8 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 21 |
model = InferenceClientModel() #Default
|
| 22 |
|
| 23 |
#Agent
|
| 24 |
-
code_agent = CodeAgent(tools=[
|
|
|
|
| 25 |
|
| 26 |
class BasicAgent:
|
| 27 |
def __init__(self):
|
|
@@ -33,6 +34,15 @@ class BasicAgent:
|
|
| 33 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 34 |
return fixed_answer
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 37 |
"""
|
| 38 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
@@ -55,7 +65,8 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 55 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 56 |
try:
|
| 57 |
#agent = BasicAgent()
|
| 58 |
-
agent =
|
|
|
|
| 59 |
except Exception as e:
|
| 60 |
print(f"Error instantiating agent: {e}")
|
| 61 |
return f"Error initializing agent: {e}", None
|
|
|
|
| 21 |
model = InferenceClientModel() #Default
|
| 22 |
|
| 23 |
#Agent
|
| 24 |
+
code_agent = CodeAgent(tools=[], model=model)
|
| 25 |
+
#code_agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
|
| 26 |
|
| 27 |
class BasicAgent:
|
| 28 |
def __init__(self):
|
|
|
|
| 34 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 35 |
return fixed_answer
|
| 36 |
|
| 37 |
+
class BasicCodeAgent:
|
| 38 |
+
def __init__(self):
|
| 39 |
+
print("BasicCodeAgent initialized.")
|
| 40 |
+
def __call__(self, question: str) -> str:
|
| 41 |
+
print(f"BasicCodeAgent received question (first 50 chars): {question[:50]}...")
|
| 42 |
+
fixed_answer = "This is a default answer."
|
| 43 |
+
print(f"BasicCodeAgent returning fixed answer: {fixed_answer}")
|
| 44 |
+
return fixed_answer
|
| 45 |
+
|
| 46 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 47 |
"""
|
| 48 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
|
|
| 65 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 66 |
try:
|
| 67 |
#agent = BasicAgent()
|
| 68 |
+
agent = BasicCodeAgent()
|
| 69 |
+
|
| 70 |
except Exception as e:
|
| 71 |
print(f"Error instantiating agent: {e}")
|
| 72 |
return f"Error initializing agent: {e}", None
|