Commit 3b
Browse files
app.py
CHANGED
|
@@ -5,9 +5,9 @@ import inspect
|
|
| 5 |
import pandas as pd
|
| 6 |
|
| 7 |
from PIL import Image
|
| 8 |
-
from typing import Optional, Tuple
|
| 9 |
from smolagents import CodeAgent,DuckDuckGoSearchTool,FinalAnswerTool,InferenceClientModel,VisitWebpageTool,tool,AzureOpenAIServerModel
|
| 10 |
-
|
| 11 |
|
| 12 |
# (Keep Constants as is)
|
| 13 |
# --- Constants ---
|
|
@@ -15,6 +15,19 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 15 |
|
| 16 |
# --- Basic Agent Definition ---
|
| 17 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
class BasicAgent:
|
| 19 |
def __init__(self):
|
| 20 |
print("BasicAgent initializing...")
|
|
|
|
| 5 |
import pandas as pd
|
| 6 |
|
| 7 |
from PIL import Image
|
| 8 |
+
from typing import Optional, Tuple, Any
|
| 9 |
from smolagents import CodeAgent,DuckDuckGoSearchTool,FinalAnswerTool,InferenceClientModel,VisitWebpageTool,tool,AzureOpenAIServerModel
|
| 10 |
+
from smolagents.tools import Tool
|
| 11 |
|
| 12 |
# (Keep Constants as is)
|
| 13 |
# --- Constants ---
|
|
|
|
| 15 |
|
| 16 |
# --- Basic Agent Definition ---
|
| 17 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 18 |
+
class FinalAnswerTool(Tool):
|
| 19 |
+
name = "final_answer"
|
| 20 |
+
description = "Provides a final answer to the given problem."
|
| 21 |
+
inputs = {'answer': {'type': 'any', 'description': 'The final answer to the problem'}}
|
| 22 |
+
output_type = "any"
|
| 23 |
+
|
| 24 |
+
def forward(self, answer: Any) -> Any:
|
| 25 |
+
# ✅ This is what actually returns the value back to the agent
|
| 26 |
+
return answer
|
| 27 |
+
|
| 28 |
+
def __init__(self, *args, **kwargs):
|
| 29 |
+
super().__init__(*args, **kwargs)
|
| 30 |
+
|
| 31 |
class BasicAgent:
|
| 32 |
def __init__(self):
|
| 33 |
print("BasicAgent initializing...")
|