Spaces:
Running
Running
Download modules_image-gen.js from broadfield/huggingbot-modules: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/spaces/broadfield/huggingbot-modules/resolve/main/modules_image-gen.js
- Command line
-
hf download hf://spaces/broadfield/huggingbot-modules/modules_image-gen.js
-
curl -L -o modules_image-gen.js https://huggingface.co/spaces/broadfield/huggingbot-modules/resolve/main/modules_image-gen.js
1.35 kB
| (function(MS) { | |
| MS.register("image-gen", { | |
| name: "Image Generation", | |
| description: "Generate images from text prompts using Pollinations AI (free).", | |
| tools: [{ | |
| type: "function", | |
| function: { | |
| name: "generate_image", | |
| description: "Generate an image from a text description using Pollinations AI.", | |
| parameters: { | |
| type: "object", | |
| properties: { | |
| prompt: { type: "string", description: "Text description of the image to generate" }, | |
| width: { type: "number", description: "Width in pixels (default: 512)", default: 512 }, | |
| height: { type: "number", description: "Height in pixels (default: 512)", default: 512 } | |
| }, | |
| required: ["prompt"] | |
| } | |
| } | |
| }], | |
| handleToolCall: async function(tn, args) { | |
| if (tn !== "generate_image") return null; | |
| var w = Math.min(Math.max(parseInt(args.width) || 512, 128), 1024); | |
| var h = Math.min(Math.max(parseInt(args.height) || 512, 128), 1024); | |
| var url = "https://image.pollinations.ai/prompt/" + encodeURIComponent(args.prompt) + "?width=" + w + "&height=" + h + "&nologo=true"; | |
| return "\n\n**Prompt:** " + args.prompt + "\n**Size:** " + w + "×" + h + "\n\n_Generated via Pollinations AI_"; | |
| } | |
| }); | |
| })(ModuleSystem); |