Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,14 +63,31 @@ def generate_prompts_for_object(object_name):
|
|
| 63 |
"future": f"Show a futuristic version of a {object_name}, by predicting advanced features and futuristic design."
|
| 64 |
}
|
| 65 |
|
| 66 |
-
|
| 67 |
image_generation_tool = Tool.from_space(
|
| 68 |
"KingNish/Realtime-FLUX",
|
| 69 |
api_name="/predict", # Optional if there's only one endpoint
|
| 70 |
name="image_generator",
|
| 71 |
description="Generate an image from a prompt"
|
| 72 |
)
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
# =========================================================
|
| 76 |
# Tool and Agent Initialization
|
|
|
|
| 63 |
"future": f"Show a futuristic version of a {object_name}, by predicting advanced features and futuristic design."
|
| 64 |
}
|
| 65 |
|
| 66 |
+
'''
|
| 67 |
image_generation_tool = Tool.from_space(
|
| 68 |
"KingNish/Realtime-FLUX",
|
| 69 |
api_name="/predict", # Optional if there's only one endpoint
|
| 70 |
name="image_generator",
|
| 71 |
description="Generate an image from a prompt"
|
| 72 |
)
|
| 73 |
+
'''
|
| 74 |
+
import requests
|
| 75 |
+
from smolagents import Tool
|
| 76 |
+
|
| 77 |
+
def flux_proxy(user_prompt: str):
|
| 78 |
+
# Call the Hugging Face Space API directly
|
| 79 |
+
url = "https://black-forest-labs-flux-1-schnell.hf.space/run/infer"
|
| 80 |
+
headers = {"Authorization": f"Bearer {token}"}
|
| 81 |
+
response = requests.post(url, headers=headers, json={"data": [user_prompt]})
|
| 82 |
+
response.raise_for_status()
|
| 83 |
+
output_url = response.json()["data"][0] # Usually a URL or base64 image
|
| 84 |
+
return output_url # Adjust this based on your agent's expectations
|
| 85 |
+
|
| 86 |
+
image_generation_tool = Tool.from_function(
|
| 87 |
+
fn=flux_proxy,
|
| 88 |
+
name="image_generator",
|
| 89 |
+
description="Generate an image from a prompt"
|
| 90 |
+
)
|
| 91 |
|
| 92 |
# =========================================================
|
| 93 |
# Tool and Agent Initialization
|