init default CodeAgent
Browse files
app.py
CHANGED
@@ -4,20 +4,32 @@ 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 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
23 |
"""
|
@@ -40,7 +52,18 @@ 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 = BasicAgent()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
|
8 |
+
|
9 |
# (Keep Constants as is)
|
10 |
# --- Constants ---
|
11 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
12 |
|
13 |
# --- Basic Agent Definition ---
|
14 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
15 |
+
|
16 |
+
# class BasicAgent:
|
17 |
+
# def __init__(self):
|
18 |
+
# print("BasicAgent initialized.")
|
19 |
+
# def __call__(self, question: str) -> str:
|
20 |
+
# print(f"Agent received question (first 50 chars): {question[:50]}...")
|
21 |
+
# fixed_answer = "This is a default answer."
|
22 |
+
# print(f"Agent returning fixed answer: {fixed_answer}")
|
23 |
+
# return fixed_answer
|
24 |
+
|
25 |
+
model = HfApiModel(
|
26 |
+
max_tokens=2096,
|
27 |
+
temperature=0.5,
|
28 |
+
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
29 |
+
custom_role_conversions=None,
|
30 |
+
)
|
31 |
+
|
32 |
+
|
33 |
|
34 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
35 |
"""
|
|
|
52 |
|
53 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
54 |
try:
|
55 |
+
# agent = BasicAgent()
|
56 |
+
|
57 |
+
agent = CodeAgent(
|
58 |
+
model=model,
|
59 |
+
tools=[
|
60 |
+
DuckDuckGoSearchTool(),
|
61 |
+
], ## add or remove tools here
|
62 |
+
max_steps=6,
|
63 |
+
verbosity_level=1,
|
64 |
+
planning_interval=3,
|
65 |
+
)
|
66 |
+
|
67 |
except Exception as e:
|
68 |
print(f"Error instantiating agent: {e}")
|
69 |
return f"Error initializing agent: {e}", None
|