Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,7 +21,21 @@ from huggingface_hub import login
|
|
| 21 |
login(hf_token)
|
| 22 |
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
@tool
|
| 27 |
def web_search(query:str)-> str:
|
|
@@ -73,7 +87,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 73 |
|
| 74 |
agent = CodeAgent(
|
| 75 |
model=model,
|
| 76 |
-
tools=[final_answer, web_search], ## add your tools here (don't remove final answer)
|
| 77 |
max_steps=6,
|
| 78 |
verbosity_level=1,
|
| 79 |
grammar=None,
|
|
|
|
| 21 |
login(hf_token)
|
| 22 |
|
| 23 |
|
| 24 |
+
@tool
|
| 25 |
+
def generate_image(prompt: str) -> str:
|
| 26 |
+
"""A tool that generates an image based on the given prompt.
|
| 27 |
+
|
| 28 |
+
Args:
|
| 29 |
+
prompt: A text description of the image to generate.
|
| 30 |
+
|
| 31 |
+
Returns:
|
| 32 |
+
The URL or path to the generated image.
|
| 33 |
+
"""
|
| 34 |
+
try:
|
| 35 |
+
image_url = image_generation_tool(prompt)
|
| 36 |
+
return image_url
|
| 37 |
+
except Exception as e:
|
| 38 |
+
return f"Error generating image: {str(e)}"
|
| 39 |
|
| 40 |
@tool
|
| 41 |
def web_search(query:str)-> str:
|
|
|
|
| 87 |
|
| 88 |
agent = CodeAgent(
|
| 89 |
model=model,
|
| 90 |
+
tools=[final_answer, web_search, generate_image], ## add your tools here (don't remove final answer)
|
| 91 |
max_steps=6,
|
| 92 |
verbosity_level=1,
|
| 93 |
grammar=None,
|