Update app.py
Browse files
app.py
CHANGED
|
@@ -4,46 +4,29 @@ import gradio as gr
|
|
| 4 |
import requests
|
| 5 |
import inspect
|
| 6 |
import pandas as pd
|
| 7 |
-
from smolagents import
|
|
|
|
| 8 |
# (Keep Constants as is)
|
| 9 |
# --- Constants ---
|
| 10 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 11 |
|
| 12 |
-
|
| 13 |
# --- Basic Agent Definition ---
|
| 14 |
-
|
| 15 |
class BasicAgent:
|
| 16 |
def __init__(self):
|
| 17 |
-
print("BasicAgent initialized.")
|
| 18 |
|
| 19 |
-
model =
|
| 20 |
-
model_id="
|
| 21 |
-
|
| 22 |
-
api_base="https://api.deepseek.com",
|
| 23 |
-
temperature=0.5,
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
search_tool = DuckDuckGoSearchTool()
|
| 27 |
-
wiki_search = WikipediaSearchTool()
|
| 28 |
-
|
| 29 |
self.agent = CodeAgent(
|
| 30 |
-
model
|
| 31 |
-
tools=[
|
|
|
|
| 32 |
)
|
|
|
|
| 33 |
def __call__(self, question: str) -> str:
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
Args:
|
| 38 |
-
question: 用户提出的问题或请求字符串
|
| 39 |
-
|
| 40 |
-
Returns:
|
| 41 |
-
str: Agent 生成的回答
|
| 42 |
-
"""
|
| 43 |
-
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 44 |
-
fixed_answer = self.agent.run(question)
|
| 45 |
-
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 46 |
-
return fixed_answer
|
| 47 |
|
| 48 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 49 |
"""
|
|
|
|
| 4 |
import requests
|
| 5 |
import inspect
|
| 6 |
import pandas as pd
|
| 7 |
+
from smolagents import LiteLLMModel, DuckDuckGoSearchTool, CodeAgent, WikipediaSearchTool
|
| 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 |
class BasicAgent:
|
| 16 |
def __init__(self):
|
|
|
|
| 17 |
|
| 18 |
+
model = LiteLLMModel(
|
| 19 |
+
model_id="gemini/gemini-2.5-flash-preview-04-17",
|
| 20 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
self.agent = CodeAgent(
|
| 22 |
+
model=model,
|
| 23 |
+
tools=[DuckDuckGoSearchTool(), WikipediaSearchTool()],
|
| 24 |
+
add_base_tools=True,
|
| 25 |
)
|
| 26 |
+
print("BasicAgent initialized.")
|
| 27 |
def __call__(self, question: str) -> str:
|
| 28 |
+
answer = self.agent.run(question)
|
| 29 |
+
return answer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 32 |
"""
|