Recovered requirements. Removed unnecessary comments.
Browse files- app.py +4 -11
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -7,7 +7,7 @@ import pandas as pd
|
|
| 7 |
import asyncio
|
| 8 |
import aiohttp
|
| 9 |
|
| 10 |
-
from smolagents import CodeAgent, HfApiModel, DuckDuckGoSearchTool
|
| 11 |
|
| 12 |
# --- Constants ---
|
| 13 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
@@ -19,16 +19,9 @@ class BasicAgent:
|
|
| 19 |
print("BasicAgent initialized to use smolagents.")
|
| 20 |
|
| 21 |
# --- smolagents Initialization ---
|
| 22 |
-
try:
|
| 23 |
-
# Use the provided DuckDuckGoSearchTool from smolagents
|
| 24 |
-
# You might need to pass configuration to it if required by the library
|
| 25 |
-
# e.g., API keys if it were a different search tool. For DuckDuckGo, often no key is needed.
|
| 26 |
search_tool = DuckDuckGoSearchTool()
|
| 27 |
|
| 28 |
-
# Configure the LLM for smolagents
|
| 29 |
-
# HfApiModel is used for Hugging Face Inference API models
|
| 30 |
-
# Ensure you have your HUGGING_FACE_HUB_TOKEN environment variable set if using private/gated models
|
| 31 |
-
# or if the model requires it.
|
| 32 |
llm_model = HfApiModel(
|
| 33 |
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 34 |
)
|
|
@@ -45,7 +38,7 @@ class BasicAgent:
|
|
| 45 |
except Exception as e:
|
| 46 |
print(f"Error initializing smolagents: {e}")
|
| 47 |
raise
|
| 48 |
-
|
| 49 |
|
| 50 |
def __call__(self, question: str) -> str:
|
| 51 |
print(f"\nAgent (smolagents) received question (first 100 chars): {question[:100]}...")
|
|
@@ -53,7 +46,7 @@ class BasicAgent:
|
|
| 53 |
response = self.agent_executor.run(question)
|
| 54 |
|
| 55 |
print(f"Agent (smolagents) returning answer (first 50 chars): {str(response)[:50]}...")
|
| 56 |
-
return str(response)
|
| 57 |
except Exception as e:
|
| 58 |
print(f"Error during smolagents agent's __call__: {e}")
|
| 59 |
return f"Error: Could not process the question with smolagents. {e}"
|
|
|
|
| 7 |
import asyncio
|
| 8 |
import aiohttp
|
| 9 |
|
| 10 |
+
from smolagents import CodeAgent, HfApiModel, DuckDuckGoSearchTool
|
| 11 |
|
| 12 |
# --- Constants ---
|
| 13 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
|
| 19 |
print("BasicAgent initialized to use smolagents.")
|
| 20 |
|
| 21 |
# --- smolagents Initialization ---
|
| 22 |
+
try:
|
|
|
|
|
|
|
|
|
|
| 23 |
search_tool = DuckDuckGoSearchTool()
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
llm_model = HfApiModel(
|
| 26 |
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 27 |
)
|
|
|
|
| 38 |
except Exception as e:
|
| 39 |
print(f"Error initializing smolagents: {e}")
|
| 40 |
raise
|
| 41 |
+
|
| 42 |
|
| 43 |
def __call__(self, question: str) -> str:
|
| 44 |
print(f"\nAgent (smolagents) received question (first 100 chars): {question[:100]}...")
|
|
|
|
| 46 |
response = self.agent_executor.run(question)
|
| 47 |
|
| 48 |
print(f"Agent (smolagents) returning answer (first 50 chars): {str(response)[:50]}...")
|
| 49 |
+
return str(response)
|
| 50 |
except Exception as e:
|
| 51 |
print(f"Error during smolagents agent's __call__: {e}")
|
| 52 |
return f"Error: Could not process the question with smolagents. {e}"
|
requirements.txt
CHANGED
|
@@ -3,4 +3,5 @@ requests
|
|
| 3 |
torch
|
| 4 |
transformers
|
| 5 |
aiohttp
|
| 6 |
-
smolagents
|
|
|
|
|
|
| 3 |
torch
|
| 4 |
transformers
|
| 5 |
aiohttp
|
| 6 |
+
smolagents
|
| 7 |
+
duckduckgo-search
|