Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import os
|
| 2 |
-
os.system("pip install 'smolagents[openai]'")
|
| 3 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool, OpenAIServerModel
|
| 4 |
import datetime
|
| 5 |
import requests
|
|
@@ -59,7 +59,7 @@ def search_duckduckgo(query: str, num_results: int = 3) -> str:
|
|
| 59 |
search_tool = DuckDuckGoSearchTool()
|
| 60 |
results = search_tool(query)
|
| 61 |
|
| 62 |
-
print("DEBUG - Raw results from DuckDuckGo:\n", results)
|
| 63 |
|
| 64 |
if not results or "## Search Results" not in results:
|
| 65 |
return f"No relevant results found for '{query}'."
|
|
@@ -74,9 +74,9 @@ def search_duckduckgo(query: str, num_results: int = 3) -> str:
|
|
| 74 |
title = result_lines[i][1:title_end] # Extract title
|
| 75 |
link = result_lines[i][title_end+2:].strip() # Extract link
|
| 76 |
|
| 77 |
-
|
| 78 |
if link.endswith(")"):
|
| 79 |
-
link = link[:-1]
|
| 80 |
|
| 81 |
# Ensure the link is valid
|
| 82 |
if not link.startswith("http"):
|
|
@@ -112,12 +112,12 @@ model = OpenAIServerModel(
|
|
| 112 |
)
|
| 113 |
|
| 114 |
# Import tool from Hub
|
| 115 |
-
HF_API_KEY = os.getenv("HF_TOKEN")
|
| 116 |
|
| 117 |
image_generation_tool = load_tool(
|
| 118 |
"agents-course/text-to-image",
|
| 119 |
trust_remote_code=True,
|
| 120 |
-
token=HF_API_KEY
|
| 121 |
)
|
| 122 |
|
| 123 |
with open("prompts.yaml", 'r') as stream:
|
|
|
|
| 1 |
import os
|
| 2 |
+
os.system("pip install 'smolagents[openai]'")
|
| 3 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool, OpenAIServerModel
|
| 4 |
import datetime
|
| 5 |
import requests
|
|
|
|
| 59 |
search_tool = DuckDuckGoSearchTool()
|
| 60 |
results = search_tool(query)
|
| 61 |
|
| 62 |
+
print("DEBUG - Raw results from DuckDuckGo:\n", results)
|
| 63 |
|
| 64 |
if not results or "## Search Results" not in results:
|
| 65 |
return f"No relevant results found for '{query}'."
|
|
|
|
| 74 |
title = result_lines[i][1:title_end] # Extract title
|
| 75 |
link = result_lines[i][title_end+2:].strip() # Extract link
|
| 76 |
|
| 77 |
+
|
| 78 |
if link.endswith(")"):
|
| 79 |
+
link = link[:-1]
|
| 80 |
|
| 81 |
# Ensure the link is valid
|
| 82 |
if not link.startswith("http"):
|
|
|
|
| 112 |
)
|
| 113 |
|
| 114 |
# Import tool from Hub
|
| 115 |
+
HF_API_KEY = os.getenv("HF_TOKEN")
|
| 116 |
|
| 117 |
image_generation_tool = load_tool(
|
| 118 |
"agents-course/text-to-image",
|
| 119 |
trust_remote_code=True,
|
| 120 |
+
token=HF_API_KEY
|
| 121 |
)
|
| 122 |
|
| 123 |
with open("prompts.yaml", 'r') as stream:
|