Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
|
@@ -12,12 +14,28 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
class BasicAgent:
|
| 14 |
def __init__(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
print("BasicAgent initialized.")
|
|
|
|
| 16 |
def __call__(self, question: str) -> str:
|
| 17 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 18 |
-
|
| 19 |
-
print(f"Agent returning
|
| 20 |
-
return
|
| 21 |
|
| 22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 23 |
"""
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from smolagents import InferenceClientModel, DuckDuckGoSearchTool, CodeAgent
|
| 7 |
+
|
| 8 |
|
| 9 |
# (Keep Constants as is)
|
| 10 |
# --- Constants ---
|
|
|
|
| 14 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 15 |
class BasicAgent:
|
| 16 |
def __init__(self):
|
| 17 |
+
model_id = "meta-llama/Llama-3-70B-Instruct"
|
| 18 |
+
|
| 19 |
+
self.model = InferenceClientModel(
|
| 20 |
+
model_id=model_id,
|
| 21 |
+
provider="hf-inference",
|
| 22 |
+
token=os.getenv("HF_API_KEY")
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
search_tool = DuckDuckGoSearchTool()
|
| 26 |
+
|
| 27 |
+
self.agent = CodeAgent(
|
| 28 |
+
model=self.model,
|
| 29 |
+
tools=[search_tool]
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
print("BasicAgent initialized.")
|
| 33 |
+
|
| 34 |
def __call__(self, question: str) -> str:
|
| 35 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 36 |
+
answer = self.agent.run(question)
|
| 37 |
+
print(f"Agent returning the answer: {answer}")
|
| 38 |
+
return answer
|
| 39 |
|
| 40 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 41 |
"""
|