Update app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,7 @@ try:
|
|
| 15 |
from smolagents import CodeAgent, Tool, OpenAIServerModel
|
| 16 |
except ImportError:
|
| 17 |
logging.error("Failed to import smolagents. Please ensure it is installed.")
|
|
|
|
| 18 |
# Dummy classes for script parsing if smolagents is not installed
|
| 19 |
class CodeAgent:
|
| 20 |
pass
|
|
@@ -46,8 +47,8 @@ When you generate Python code to call a tool, you MUST print the result of the t
|
|
| 46 |
Available Tools:
|
| 47 |
1. `web_search(query: str) -> str`: Use this tool to search the internet for current information or information you do not possess. This tool is asynchronous, so your generated code MUST call it using `await`. Example: `search_results = await web_search(query="latest news on AI")\nprint(search_results)`
|
| 48 |
2. `calculator(expression: str) -> str`: Use this tool for any mathematical calculations. This tool is synchronous. Example: `result = calculator(expression="((1024 / 8) + 55 - 5) * 2")\nprint(result)`
|
| 49 |
-
3. `image_retriever(url: str) -> str`: Use this tool to retrieve an image from a
|
| 50 |
-
|
| 51 |
Follow this process for every question:
|
| 52 |
1. THOUGHT: Understand the user's question. Identify the core information needed.
|
| 53 |
2. THOUGHT: Decide if one of your available tools (`web_search`, `calculator`, `image_retriever`) can help obtain this information. If yes, state which tool you will use and what input you will provide to it. If no tool is needed, explain that you can answer directly.
|
|
@@ -484,7 +485,7 @@ def submit_answers(base_api_url: str, username: str, agent_code_url: str,
|
|
| 484 |
except requests.exceptions.JSONDecodeError:
|
| 485 |
error_detail += f" Raw Response: {e.response.text[:500]}"
|
| 486 |
logger.error(f"Submission Failed: {error_detail}")
|
| 487 |
-
return f"Submission Failed: {
|
| 488 |
except requests.exceptions.Timeout:
|
| 489 |
logger.error("Submission Failed: The request timed out.")
|
| 490 |
return "Submission Failed: The request timed out."
|
|
|
|
| 15 |
from smolagents import CodeAgent, Tool, OpenAIServerModel
|
| 16 |
except ImportError:
|
| 17 |
logging.error("Failed to import smolagents. Please ensure it is installed.")
|
| 18 |
+
|
| 19 |
# Dummy classes for script parsing if smolagents is not installed
|
| 20 |
class CodeAgent:
|
| 21 |
pass
|
|
|
|
| 47 |
Available Tools:
|
| 48 |
1. `web_search(query: str) -> str`: Use this tool to search the internet for current information or information you do not possess. This tool is asynchronous, so your generated code MUST call it using `await`. Example: `search_results = await web_search(query="latest news on AI")\nprint(search_results)`
|
| 49 |
2. `calculator(expression: str) -> str`: Use this tool for any mathematical calculations. This tool is synchronous. Example: `result = calculator(expression="((1024 / 8) + 55 - 5) * 2")\nprint(result)`
|
| 50 |
+
3. `image_retriever(url: str) -> str`: Use this tool to retrieve an image from a web URL. Input: a string URL. Output: a status message.
|
| 51 |
+
|
| 52 |
Follow this process for every question:
|
| 53 |
1. THOUGHT: Understand the user's question. Identify the core information needed.
|
| 54 |
2. THOUGHT: Decide if one of your available tools (`web_search`, `calculator`, `image_retriever`) can help obtain this information. If yes, state which tool you will use and what input you will provide to it. If no tool is needed, explain that you can answer directly.
|
|
|
|
| 485 |
except requests.exceptions.JSONDecodeError:
|
| 486 |
error_detail += f" Raw Response: {e.response.text[:500]}"
|
| 487 |
logger.error(f"Submission Failed: {error_detail}")
|
| 488 |
+
return f"Submission Failed: Network error - {e}"
|
| 489 |
except requests.exceptions.Timeout:
|
| 490 |
logger.error("Submission Failed: The request timed out.")
|
| 491 |
return "Submission Failed: The request timed out."
|