Spaces:
Sleeping
Sleeping
First try inference model
Browse files
app.py
CHANGED
|
@@ -3,20 +3,27 @@ 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
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
-
"""
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
+
from huggingface_hub import InferenceClient
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
+
def inference_image_tool(prompt:str, model:str = "black-forest-labs/FLUX.1-dev")-> str: #it's import to specify the return type
|
| 14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 15 |
+
"""Generate an image from a text prompt using Hugging Face Inference Providers."
|
| 16 |
Args:
|
| 17 |
+
prompt: Text prompt for the image.
|
| 18 |
+
model: HF model id (e.g. black-forest-labs/FLUX.1-dev).
|
| 19 |
"""
|
| 20 |
+
token = os.getenv("HF_TOKEN")
|
| 21 |
+
if not token:
|
| 22 |
+
raise RuntimeError("HF_TOKEN is missing. Add it in Space Settings → Secrets.")
|
| 23 |
+
|
| 24 |
+
client = InferenceClient('auto', api_key=token)
|
| 25 |
+
return client.text_to_image(prompt, model=model)
|
| 26 |
+
|
| 27 |
|
| 28 |
@tool
|
| 29 |
def get_current_time_in_timezone(timezone: str) -> str:
|