Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
|
@@ -50,20 +52,50 @@ custom_role_conversions=None,
|
|
| 50 |
# Import tool from Hub
|
| 51 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer],
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
| 62 |
planning_interval=None,
|
| 63 |
name=None,
|
| 64 |
description=None,
|
| 65 |
-
prompt_templates=prompt_templates
|
| 66 |
)
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
GradioUI(agent).launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 4 |
import datetime
|
| 5 |
import requests
|
|
|
|
| 52 |
# Import tool from Hub
|
| 53 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 54 |
|
| 55 |
+
print(f"Current working directory: {os.getcwd()}")
|
| 56 |
+
print(f"Files in current directory: {os.listdir('.')}")
|
| 57 |
+
print(f"Does prompts.yaml exist? {os.path.exists('prompts.yaml')}")
|
| 58 |
+
|
| 59 |
+
try:
|
| 60 |
+
with open("prompts.yaml", 'r') as stream:
|
| 61 |
+
prompt_templates = yaml.safe_load(stream)
|
| 62 |
+
print("--- LOADED PROMPT TEMPLATES ---")
|
| 63 |
+
print(f"Type: {type(prompt_templates)}")
|
| 64 |
+
if isinstance(prompt_templates, dict):
|
| 65 |
+
print(f"Keys: {prompt_templates.keys()}")
|
| 66 |
+
else:
|
| 67 |
+
print(f"Content: {prompt_templates}")
|
| 68 |
+
print("--- END LOADED PROMPT TEMPLATES ---")
|
| 69 |
+
except Exception as e:
|
| 70 |
+
print(f"!!! ERROR LOADING prompts.yaml: {e} !!!")
|
| 71 |
+
prompt_templates = {} # Assign empty dict on error to potentially see a different error later
|
| 72 |
+
|
| 73 |
agent = CodeAgent(
|
| 74 |
model=model,
|
| 75 |
+
tools=[final_answer],
|
| 76 |
max_steps=6,
|
| 77 |
verbosity_level=1,
|
| 78 |
grammar=None,
|
| 79 |
planning_interval=None,
|
| 80 |
name=None,
|
| 81 |
description=None,
|
| 82 |
+
prompt_templates=prompt_templates # Pass the potentially loaded dict
|
| 83 |
)
|
| 84 |
|
| 85 |
+
#with open("prompts.yaml", 'r') as stream:
|
| 86 |
+
# prompt_templates = yaml.safe_load(stream)
|
| 87 |
+
#
|
| 88 |
+
#agent = CodeAgent(
|
| 89 |
+
# model=model,
|
| 90 |
+
# tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 91 |
+
# max_steps=6,
|
| 92 |
+
# verbosity_level=1,
|
| 93 |
+
# grammar=None,
|
| 94 |
+
# planning_interval=None,
|
| 95 |
+
# name=None,
|
| 96 |
+
# description=None,
|
| 97 |
+
# prompt_templates=prompt_templates
|
| 98 |
+
#)
|
| 99 |
+
|
| 100 |
|
| 101 |
GradioUI(agent).launch()
|