Spaces:
Runtime error
Runtime error
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -64,6 +64,19 @@ def query_databank(filename: str) -> str:
|
|
| 64 |
content = load_from_databank(filename)
|
| 65 |
return content if content else "File not found."
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
# --- AGENT LOGIC (Aussie Domain Router) ---
|
| 68 |
|
| 69 |
def aussie_router(user_input, history):
|
|
|
|
| 64 |
content = load_from_databank(filename)
|
| 65 |
return content if content else "File not found."
|
| 66 |
|
| 67 |
+
@mcp.tool()
|
| 68 |
+
def generate_image(prompt: str) -> str:
|
| 69 |
+
"""Generate an image using a text-to-image model on Hugging Face."""
|
| 70 |
+
try:
|
| 71 |
+
# Using a popular model like FLUX or SDXL via InferenceClient
|
| 72 |
+
image = client.text_to_image(prompt, model="black-forest-labs/FLUX.1-schnell")
|
| 73 |
+
os.makedirs("exports/images", exist_ok=True)
|
| 74 |
+
image_path = f"exports/images/{hash(prompt)}.png"
|
| 75 |
+
image.save(image_path)
|
| 76 |
+
return f"Image generated and saved to {image_path}"
|
| 77 |
+
except Exception as e:
|
| 78 |
+
return f"Error generating image: {str(e)}"
|
| 79 |
+
|
| 80 |
# --- AGENT LOGIC (Aussie Domain Router) ---
|
| 81 |
|
| 82 |
def aussie_router(user_input, history):
|