Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,10 @@
|
|
| 1 |
import os
|
| 2 |
-
import openai
|
| 3 |
import gradio as gr
|
| 4 |
import requests
|
| 5 |
import inspect
|
| 6 |
import pandas as pd
|
| 7 |
-
|
| 8 |
-
from
|
| 9 |
-
from langchain_core.tools import tool
|
| 10 |
|
| 11 |
# (Keep Constants as is)
|
| 12 |
# --- Constants ---
|
|
@@ -17,15 +15,20 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 17 |
class BasicAgent:
|
| 18 |
def __init__(self):
|
| 19 |
model = OpenAIServerModel(model_id="deepseek-chat",api_key="sk-04da63f756c9468182d278f52e33ad15", api_base="https://api.deepseek.com")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
self.agent = CodeAgent(
|
| 21 |
-
model=model,
|
| 22 |
-
tools=[
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
)
|
| 25 |
-
|
| 26 |
def __call__(self, question: str) -> str:
|
| 27 |
-
|
| 28 |
-
return answer
|
| 29 |
|
| 30 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 31 |
"""
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
|
| 7 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, OpenAIServerModel, WikipediaSearchTool
|
|
|
|
| 8 |
|
| 9 |
# (Keep Constants as is)
|
| 10 |
# --- Constants ---
|
|
|
|
| 15 |
class BasicAgent:
|
| 16 |
def __init__(self):
|
| 17 |
model = OpenAIServerModel(model_id="deepseek-chat",api_key="sk-04da63f756c9468182d278f52e33ad15", api_base="https://api.deepseek.com")
|
| 18 |
+
|
| 19 |
+
search_tool = DuckDuckGoSearchTool()
|
| 20 |
+
wiki_search = WikipediaSearchTool()
|
| 21 |
+
|
| 22 |
self.agent = CodeAgent(
|
| 23 |
+
model = model,
|
| 24 |
+
tools=[
|
| 25 |
+
search_tool,
|
| 26 |
+
wiki_search,
|
| 27 |
+
]
|
| 28 |
)
|
| 29 |
+
|
| 30 |
def __call__(self, question: str) -> str:
|
| 31 |
+
return self.agent.run(question) # type: ignore
|
|
|
|
| 32 |
|
| 33 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 34 |
"""
|