Spaces:
Sleeping
Sleeping
update image code
Browse files
app.py
CHANGED
|
@@ -16,18 +16,11 @@ from Gradio_UI import GradioUI
|
|
| 16 |
|
| 17 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 18 |
@tool
|
| 19 |
-
def inference_image_tool(prompt:str, model:str = "black-forest-labs/FLUX.1-dev")->
|
| 20 |
-
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 21 |
-
"""Generate an image from a text prompt using Hugging Face Inference Providers."
|
| 22 |
-
Args:
|
| 23 |
-
prompt: Text prompt for the image.
|
| 24 |
-
model: HF model id (e.g. black-forest-labs/FLUX.1-dev).
|
| 25 |
-
"""
|
| 26 |
token = os.getenv("HF_TOKEN")
|
| 27 |
if not token:
|
| 28 |
raise RuntimeError("HF_TOKEN is missing. Add it in Space Settings → Secrets.")
|
| 29 |
-
|
| 30 |
-
client = InferenceClient('auto', api_key=token)
|
| 31 |
return client.text_to_image(prompt, model=model)
|
| 32 |
|
| 33 |
|
|
|
|
| 16 |
|
| 17 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 18 |
@tool
|
| 19 |
+
def inference_image_tool(prompt: str, model: str = "black-forest-labs/FLUX.1-dev") -> "Image.Image":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
token = os.getenv("HF_TOKEN")
|
| 21 |
if not token:
|
| 22 |
raise RuntimeError("HF_TOKEN is missing. Add it in Space Settings → Secrets.")
|
| 23 |
+
client = InferenceClient(provider="auto", api_key=token)
|
|
|
|
| 24 |
return client.text_to_image(prompt, model=model)
|
| 25 |
|
| 26 |
|