Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,26 @@
|
|
| 1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
def cast_spell(mana:int)-> str: #it's import to specify the return type
|
|
@@ -61,7 +75,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 61 |
|
| 62 |
agent = CodeAgent(
|
| 63 |
model=model,
|
| 64 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 65 |
max_steps=6,
|
| 66 |
verbosity_level=1,
|
| 67 |
grammar=None,
|
|
|
|
| 1 |
+
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiClient, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from huggingface_hub import InferenceClient
|
| 8 |
+
from PIL import Image
|
| 9 |
+
import io
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
+
@tool
|
| 13 |
+
def generate_image(prompt: str) -> Image.Image:
|
| 14 |
+
"""
|
| 15 |
+
Generates an image based on a provided text prompt using an open-source model.
|
| 16 |
+
|
| 17 |
+
Args:
|
| 18 |
+
prompt: A detailed text description of the image to create.
|
| 19 |
+
"""
|
| 20 |
+
client = InferenceClient("black-forest-labs/FLUX.1-schnell")
|
| 21 |
+
image_bytes = client.text_to_image(prompt)
|
| 22 |
+
return Image.open(io.BytesIO(image_bytes))
|
| 23 |
+
|
| 24 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 25 |
@tool
|
| 26 |
def cast_spell(mana:int)-> str: #it's import to specify the return type
|
|
|
|
| 75 |
|
| 76 |
agent = CodeAgent(
|
| 77 |
model=model,
|
| 78 |
+
tools=[final_answer, get_current_time_in_timezone, cast_spell, generate_image], ## add your tools here (don't remove final answer)
|
| 79 |
max_steps=6,
|
| 80 |
verbosity_level=1,
|
| 81 |
grammar=None,
|