Spaces:
Sleeping
Sleeping
Qscar KIM commited on
Commit ·
75135a5
1
Parent(s): dda8828
update codes
Browse files
app.py
CHANGED
|
@@ -5,28 +5,11 @@ import inspect
|
|
| 5 |
import pandas as pd
|
| 6 |
import time
|
| 7 |
|
| 8 |
-
from smolagents import CodeAgent, ApiModel,
|
| 9 |
-
from langchain_community.tools import DuckDuckGoSearchRun
|
| 10 |
|
| 11 |
# --- Constants ---
|
| 12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 13 |
|
| 14 |
-
class WebSearchTool(Tool):
|
| 15 |
-
name = "web_search"
|
| 16 |
-
description = "Use this tool to search the internet for up-to-date facts, data, or general information."
|
| 17 |
-
inputs = {"query": {"type": "string", "description": "The search query"}}
|
| 18 |
-
output_type = "string"
|
| 19 |
-
|
| 20 |
-
def __init__(self):
|
| 21 |
-
super().__init__()
|
| 22 |
-
self.search = DuckDuckGoSearchRun()
|
| 23 |
-
|
| 24 |
-
def forward(self, query: str) -> str:
|
| 25 |
-
try:
|
| 26 |
-
return self.search.run(query)
|
| 27 |
-
except Exception as e:
|
| 28 |
-
return f"Search failed: {str(e)}"
|
| 29 |
-
|
| 30 |
# --- Basic Agent Definition ---
|
| 31 |
# ----- THIS IS WHERE YOU CAN BUILD WHAT YOU WANT ------
|
| 32 |
class BasicAgent:
|
|
@@ -35,7 +18,8 @@ class BasicAgent:
|
|
| 35 |
model_id="Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 36 |
)
|
| 37 |
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
self.real_agent = CodeAgent(
|
| 41 |
tools=[search_tool],
|
|
|
|
| 5 |
import pandas as pd
|
| 6 |
import time
|
| 7 |
|
| 8 |
+
from smolagents import CodeAgent, ApiModel, DuckDuckGoSearchTool
|
|
|
|
| 9 |
|
| 10 |
# --- Constants ---
|
| 11 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# --- Basic Agent Definition ---
|
| 14 |
# ----- THIS IS WHERE YOU CAN BUILD WHAT YOU WANT ------
|
| 15 |
class BasicAgent:
|
|
|
|
| 18 |
model_id="Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 19 |
)
|
| 20 |
|
| 21 |
+
# langchain 패키지 의존성을 없애기 위해 smolagents 내장 검색 도구 사용
|
| 22 |
+
search_tool = DuckDuckGoSearchTool()
|
| 23 |
|
| 24 |
self.real_agent = CodeAgent(
|
| 25 |
tools=[search_tool],
|