Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,22 +7,6 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
-
from smolagents import Tool
|
| 11 |
-
from huggingface_hub import InferenceClient
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
class TextToImageTool(Tool):
|
| 15 |
-
description = "This tool creates an image according to a prompt, which is a text description."
|
| 16 |
-
name = "image_generator"
|
| 17 |
-
inputs = {"prompt": {"type": "string", "description": "The image generator prompt. Don't hesitate to add details in the prompt to make the image look better, like 'high-res, photorealistic', etc."}}
|
| 18 |
-
output_type = "image"
|
| 19 |
-
model_sdxl = "black-forest-labs/FLUX.1-schnell"
|
| 20 |
-
client = InferenceClient(model_sdxl)
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
def forward(self, prompt):
|
| 24 |
-
return self.client.text_to_image(prompt)
|
| 25 |
-
|
| 26 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 27 |
@tool
|
| 28 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
@@ -64,14 +48,14 @@ custom_role_conversions=None,
|
|
| 64 |
|
| 65 |
|
| 66 |
# Import tool from Hub
|
| 67 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 68 |
|
| 69 |
with open("prompts.yaml", 'r') as stream:
|
| 70 |
prompt_templates = yaml.safe_load(stream)
|
| 71 |
|
| 72 |
agent = CodeAgent(
|
| 73 |
model=model,
|
| 74 |
-
tools=[get_current_time_in_timezone,
|
| 75 |
max_steps=6,
|
| 76 |
verbosity_level=1,
|
| 77 |
grammar=None,
|
|
|
|
| 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 my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
# Import tool from Hub
|
| 51 |
+
#image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 52 |
|
| 53 |
with open("prompts.yaml", 'r') as stream:
|
| 54 |
prompt_templates = yaml.safe_load(stream)
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
+
tools=[get_current_time_in_timezone, final_answer], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|