Spaces:
Sleeping
Sleeping
| // ─── Media & visual tools — generate_image, create_gif, image_composite, convert_image, create_svg ─────────────────────────────────────────────────────────── | |
| // P3-4 split da toolDefinitions.ts — DO NOT edit toolDefinitions.ts directly | |
| // Tools (5): generate_image, create_gif, image_composite, convert_image, create_svg | |
| import type { ChatCompletionTool } from "openai/resources/chat/completions"; | |
| export const MEDIA_TOOLS: (ChatCompletionTool | undefined)[] = [ | |
| { | |
| type: "function", | |
| function: { | |
| name: "generate_image", | |
| description: "Genera un'immagine AI. Salvata AUTOMATICAMENTE nel VFS (in save_path o images/ai_<ts>.png). SPECIFICA SEMPRE width e height appropriati: icona=256×256, foto=512×512, banner=1024×256, sfondo=1024×768, storia=512×912.", | |
| parameters: { | |
| type: "object", | |
| properties: { | |
| prompt: { type: "string", description: "Descrizione dell'immagine (in inglese per migliori risultati)" }, | |
| width: { type: "number", description: "Larghezza px. Default 512. Scegli: icona→256, foto→512, banner→1024, sfondo→1024" }, | |
| height: { type: "number", description: "Altezza px. Default 512. Scegli: icona→256, foto→512, banner→256, sfondo→768, storia→912" }, | |
| save_path: { type: "string", description: "Path VFS dove salvare es. 'images/logo.png'. Auto-generato se omesso." }, | |
| model: { type: "string", enum: ["flux","flux-realism","flux-cablyai","turbo"], description: "Modello: flux (default), flux-realism (fotografico), turbo (veloce)" }, | |
| aspect_ratio: { type: "string", enum: ["1:1","16:9","9:16","4:3","3:4","banner","story","thumb","landscape","portrait"], description: "Proporzioni predefinite — sovrascrive width/height. 16:9=1920×1080, 9:16=1080×1920, banner=1200×400, thumb=1280×720" } | |
| }, | |
| required: ["prompt"] | |
| } | |
| } | |
| }, | |
| { | |
| type: "function", | |
| function: { | |
| name: "create_gif", | |
| description: "Crea una GIF animata da più immagini o frame (percorsi VFS o data URL). Supporta delay personalizzato, resize e loop.", | |
| parameters: { type: "object", properties: { frames: { type: "array", items: { type: "string" }, description: "Lista di percorsi VFS o data URL delle immagini (min 2 frame)" }, filename: { type: "string", description: "Nome file output (default: animation.gif)" }, delay: { type: "number", description: "Delay tra frame in millisecondi (default: 200)" }, width: { type: "number", description: "Larghezza output in px (default: larghezza primo frame)" }, height: { type: "number", description: "Altezza output in px (default: altezza primo frame)" }, loop: { type: "number", description: "Numero di ripetizioni — 0 = infinito (default: 0)" } }, required: ["frames"] } | |
| } | |
| }, | |
| { | |
| type: "function", | |
| function: { | |
| name: "image_composite", | |
| description: "Combina più immagini in un'unica immagine. Layout: horizontal (affiancate), vertical (impilate), grid (griglia), overlay (sovrapposti con posizione x/y). Controlla opacità, gap, sfondo.", | |
| parameters: { type: "object", properties: { layers: { type: "array", description: "Layer da comporre", items: { type: "object", properties: { path: { type: "string", description: "Path VFS o data URL" }, x: { type: "number" }, y: { type: "number" }, w: { type: "number", description: "Larghezza ridimensionata" }, h: { type: "number", description: "Altezza ridimensionata" }, opacity: { type: "number", description: "Opacità 0-1" } }, required: ["path"] } }, filename: { type: "string", description: "Nome file output (default: composite.png)" }, layout: { type: "string", enum: ["horizontal","vertical","grid","overlay"], description: "Disposizione (default: horizontal)" }, gap: { type: "number", description: "Spazio tra immagini in px (default: 10)" }, background: { type: "string", description: "Colore sfondo HEX o 'transparent' (default: #ffffff)" } }, required: ["layers"] } | |
| } | |
| }, | |
| { | |
| type: "function", | |
| function: { | |
| name: "convert_image", | |
| description: "Converte il formato di un'immagine nel VFS (PNG/JPG/WebP) con resize opzionale. Combina conversione formato + ridimensionamento in un unico tool.", | |
| parameters: { type: "object", properties: { path: { type: "string", description: "Percorso immagine nel VFS" }, format: { type: "string", enum: ["png","jpg","webp"], description: "Formato di output (default: jpg)" }, quality: { type: "number", description: "Qualità 1-100 per JPG/WebP (default: 90)" }, max_width: { type: "number", description: "Larghezza massima in px (proporzionale)" }, max_height: { type: "number", description: "Altezza massima in px (proporzionale)" }, filename: { type: "string", description: "Nome file output opzionale" } }, required: ["path"] } | |
| } | |
| }, | |
| { | |
| type: "function", | |
| function: { | |
| name: "create_svg", | |
| description: "Genera file SVG vettoriali da zero specificando elementi (rect, circle, text, path, line, polygon, ellipse). Ideale per icone, diagrammi, loghi, infografiche.", | |
| parameters: { type: "object", properties: { elements: { type: "array", description: "Elementi SVG da disegnare", items: { type: "object", properties: { type: { type: "string", enum: ["rect","circle","text","line","path","ellipse","polygon"], description: "Tipo elemento" }, x: { type: "number" }, y: { type: "number" }, width: { type: "number" }, height: { type: "number" }, r: { type: "number", description: "Raggio (circle)" }, cx: { type: "number" }, cy: { type: "number" }, rx: { type: "number" }, ry: { type: "number" }, x1: { type: "number" }, y1: { type: "number" }, x2: { type: "number" }, y2: { type: "number" }, points: { type: "string", description: "Punti per polygon (es. '0,0 100,0 50,100')" }, d: { type: "string", description: "Path data per path element" }, text: { type: "string", description: "Testo per elemento text" }, font_size: { type: "number" }, font_family: { type: "string" }, font_weight: { type: "string" }, fill: { type: "string" }, stroke: { type: "string" }, stroke_width: { type: "number" }, opacity: { type: "number" }, transform: { type: "string", description: "Trasformazione SVG (es. 'rotate(45 50 50)')" } }, required: ["type"] } }, width: { type: "number", description: "Larghezza canvas SVG (default: 400)" }, height: { type: "number", description: "Altezza canvas SVG (default: 300)" }, filename: { type: "string", description: "Nome file output (default: graphic.svg)" }, background: { type: "string", description: "Colore sfondo (default: transparent)" }, title: { type: "string", description: "Titolo SVG (accessibilità)" } }, required: ["elements"] } | |
| } | |
| }, | |
| ]; | |