Added 30 seconds delay
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ import pandas as pd
|
|
| 7 |
import asyncio
|
| 8 |
import aiohttp
|
| 9 |
|
| 10 |
-
from smolagents import CodeAgent, LiteLLMModel,
|
| 11 |
|
| 12 |
# --- Constants ---
|
| 13 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
@@ -22,7 +22,7 @@ class BasicAgent:
|
|
| 22 |
|
| 23 |
# --- smolagents Initialization ---
|
| 24 |
try:
|
| 25 |
-
search_tool =
|
| 26 |
|
| 27 |
llm_model = LiteLLMModel(
|
| 28 |
model_id=MODEL_ID,
|
|
@@ -45,7 +45,11 @@ class BasicAgent:
|
|
| 45 |
def __call__(self, question: str) -> str:
|
| 46 |
print(f"\nAgent (smolagents) received question (first 100 chars): {question[:100]}...")
|
| 47 |
try:
|
| 48 |
-
prompt = f"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
response = self.agent_executor.run(question)
|
| 50 |
|
| 51 |
print(f"Agent (smolagents) returning answer (first 50 chars): {str(response)[:50]}...")
|
|
|
|
| 7 |
import asyncio
|
| 8 |
import aiohttp
|
| 9 |
|
| 10 |
+
from smolagents import CodeAgent, LiteLLMModel, WebSearchTool
|
| 11 |
|
| 12 |
# --- Constants ---
|
| 13 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
|
| 22 |
|
| 23 |
# --- smolagents Initialization ---
|
| 24 |
try:
|
| 25 |
+
search_tool = WebSearchTool()
|
| 26 |
|
| 27 |
llm_model = LiteLLMModel(
|
| 28 |
model_id=MODEL_ID,
|
|
|
|
| 45 |
def __call__(self, question: str) -> str:
|
| 46 |
print(f"\nAgent (smolagents) received question (first 100 chars): {question[:100]}...")
|
| 47 |
try:
|
| 48 |
+
prompt = f"""
|
| 49 |
+
If you call any API and it returns rate limit then attempt again but add 30 seconds delay.
|
| 50 |
+
Answer the following question without formatting, reasoning or explanation.
|
| 51 |
+
${question}
|
| 52 |
+
"""
|
| 53 |
response = self.agent_executor.run(question)
|
| 54 |
|
| 55 |
print(f"Agent (smolagents) returning answer (first 50 chars): {str(response)[:50]}...")
|