diff --git a/apps/docs/components/icons.tsx b/apps/docs/components/icons.tsx index ca2a9b16353..a7ee06c5e8d 100644 --- a/apps/docs/components/icons.tsx +++ b/apps/docs/components/icons.tsx @@ -3132,6 +3132,22 @@ export function QdrantIcon(props: SVGProps) { ) } +export function QuiverIcon(props: SVGProps) { + return ( + + + + + + ) +} + export function AshbyIcon(props: SVGProps) { return ( diff --git a/apps/docs/components/ui/icon-mapping.ts b/apps/docs/components/ui/icon-mapping.ts index 9afb78c0959..53ae7c00371 100644 --- a/apps/docs/components/ui/icon-mapping.ts +++ b/apps/docs/components/ui/icon-mapping.ts @@ -126,6 +126,7 @@ import { PosthogIcon, PulseIcon, QdrantIcon, + QuiverIcon, RDSIcon, RedditIcon, RedisIcon, @@ -298,6 +299,7 @@ export const blockTypeToIconMap: Record = { posthog: PosthogIcon, pulse_v2: PulseIcon, qdrant: QdrantIcon, + quiver: QuiverIcon, rds: RDSIcon, reddit: RedditIcon, redis: RedisIcon, diff --git a/apps/docs/content/docs/en/tools/meta.json b/apps/docs/content/docs/en/tools/meta.json index aaff7087831..a29c07b06df 100644 --- a/apps/docs/content/docs/en/tools/meta.json +++ b/apps/docs/content/docs/en/tools/meta.json @@ -121,6 +121,7 @@ "posthog", "pulse", "qdrant", + "quiver", "rds", "reddit", "redis", diff --git a/apps/docs/content/docs/en/tools/quiver.mdx b/apps/docs/content/docs/en/tools/quiver.mdx new file mode 100644 index 00000000000..2a5df8d1ca6 --- /dev/null +++ b/apps/docs/content/docs/en/tools/quiver.mdx @@ -0,0 +1,131 @@ +--- +title: Quiver +description: Generate and vectorize SVGs +--- + +import { BlockInfoCard } from "@/components/ui/block-info-card" + + + +{/* MANUAL-CONTENT-START:intro */} +[QuiverAI](https://quiver.ai/) is an AI-powered SVG generation platform that creates high-quality, scalable vector graphics from text descriptions or by vectorizing raster images. It produces clean, resolution-independent SVGs that are ideal for icons, illustrations, logos, and UI elements. + +With Quiver, you can: + +- **Generate SVGs from text prompts**: Describe the vector graphic you need and get production-ready SVG output +- **Vectorize raster images**: Convert PNG, JPG, and other raster images into clean SVG vector format +- **Provide reference images**: Upload up to 4 reference images to guide the style and composition of generated SVGs +- **Control generation parameters**: Adjust temperature, number of outputs, and token limits to fine-tune results +- **List available models**: Query available QuiverAI models to discover supported operations and capabilities +- **Get clean SVG markup**: Receive raw SVG content alongside downloadable files for easy embedding + +In Sim, the Quiver integration enables your workflows to generate and vectorize graphics on demand. This is useful for creating dynamic illustrations, converting raster assets to scalable vectors, generating icons for applications, producing visual assets for content pipelines, or building design automation workflows. The generated SVGs are returned as files that can be passed to downstream blocks for further processing, storage, or delivery. +{/* MANUAL-CONTENT-END */} + + +## Usage Instructions + +Generate SVG images from text prompts or vectorize raster images into SVGs using QuiverAI. Supports reference images, style instructions, and multiple output generation. + + + +## Tools + +### `quiver_text_to_svg` + +Generate SVG images from text prompts using QuiverAI + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | QuiverAI API key | +| `prompt` | string | Yes | A text description of the desired SVG | +| `model` | string | Yes | The model to use for SVG generation \(e.g., "arrow-preview"\) | +| `instructions` | string | No | Style or formatting guidance for the SVG output | +| `references` | file | No | Reference images to guide SVG generation \(up to 4\) | +| `n` | number | No | Number of SVGs to generate \(1-16, default 1\) | +| `temperature` | number | No | Sampling temperature \(0-2, default 1\) | +| `top_p` | number | No | Nucleus sampling probability \(0-1, default 1\) | +| `max_output_tokens` | number | No | Maximum output tokens \(1-131072\) | +| `presence_penalty` | number | No | Token penalty for prior output \(-2 to 2, default 0\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Whether the SVG generation succeeded | +| `output` | object | Generated SVG output | +| ↳ `file` | file | Generated SVG file | +| ↳ `svgContent` | string | Raw SVG markup content | +| ↳ `id` | string | Generation request ID | +| ↳ `usage` | json | Token usage statistics | +| ↳ `totalTokens` | number | Total tokens used | +| ↳ `inputTokens` | number | Input tokens used | +| ↳ `outputTokens` | number | Output tokens used | + +### `quiver_image_to_svg` + +Convert raster images into vector SVG format using QuiverAI + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | QuiverAI API key | +| `model` | string | Yes | The model to use for vectorization \(e.g., "arrow-preview"\) | +| `image` | file | Yes | The raster image to vectorize into SVG | +| `temperature` | number | No | Sampling temperature \(0-2, default 1\) | +| `top_p` | number | No | Nucleus sampling probability \(0-1, default 1\) | +| `max_output_tokens` | number | No | Maximum output tokens \(1-131072\) | +| `presence_penalty` | number | No | Token penalty for prior output \(-2 to 2, default 0\) | +| `auto_crop` | boolean | No | Automatically crop the image before vectorizing | +| `target_size` | number | No | Square resize target in pixels \(128-4096\) | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Whether the vectorization succeeded | +| `output` | object | Vectorized SVG output | +| ↳ `file` | file | Generated SVG file | +| ↳ `svgContent` | string | Raw SVG markup content | +| ↳ `id` | string | Vectorization request ID | +| ↳ `usage` | json | Token usage statistics | +| ↳ `totalTokens` | number | Total tokens used | +| ↳ `inputTokens` | number | Input tokens used | +| ↳ `outputTokens` | number | Output tokens used | + +### `quiver_list_models` + +List all available QuiverAI models + +#### Input + +| Parameter | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `apiKey` | string | Yes | QuiverAI API key | + +#### Output + +| Parameter | Type | Description | +| --------- | ---- | ----------- | +| `success` | boolean | Whether the request succeeded | +| `output` | object | Available models | +| ↳ `models` | json | List of available QuiverAI models | +| ↳ `id` | string | Model identifier | +| ↳ `name` | string | Human-readable model name | +| ↳ `description` | string | Model capabilities summary | +| ↳ `created` | number | Unix timestamp of creation | +| ↳ `ownedBy` | string | Organization that owns the model | +| ↳ `inputModalities` | json | Supported input types \(text, image, svg\) | +| ↳ `outputModalities` | json | Supported output types \(text, image, svg\) | +| ↳ `contextLength` | number | Maximum context window | +| ↳ `maxOutputLength` | number | Maximum generation length | +| ↳ `supportedOperations` | json | Available operations \(svg_generate, svg_edit, svg_animate, svg_vectorize, chat_completions\) | +| ↳ `supportedSamplingParameters` | json | Supported sampling parameters \(temperature, top_p, top_k, repetition_penalty, presence_penalty, stop\) | + + diff --git a/apps/sim/app/(landing)/integrations/data/icon-mapping.ts b/apps/sim/app/(landing)/integrations/data/icon-mapping.ts index 056e06c9f90..ef6684838d5 100644 --- a/apps/sim/app/(landing)/integrations/data/icon-mapping.ts +++ b/apps/sim/app/(landing)/integrations/data/icon-mapping.ts @@ -126,6 +126,7 @@ import { PosthogIcon, PulseIcon, QdrantIcon, + QuiverIcon, RDSIcon, RedditIcon, RedisIcon, @@ -298,6 +299,7 @@ export const blockTypeToIconMap: Record = { posthog: PosthogIcon, pulse_v2: PulseIcon, qdrant: QdrantIcon, + quiver: QuiverIcon, rds: RDSIcon, reddit: RedditIcon, redis: RedisIcon, diff --git a/apps/sim/app/(landing)/integrations/data/integrations.json b/apps/sim/app/(landing)/integrations/data/integrations.json index 5f5be8239eb..1905e33e881 100644 --- a/apps/sim/app/(landing)/integrations/data/integrations.json +++ b/apps/sim/app/(landing)/integrations/data/integrations.json @@ -8518,6 +8518,37 @@ "integrationType": "databases", "tags": ["vector-search", "knowledge-base"] }, + { + "type": "quiver", + "slug": "quiver", + "name": "Quiver", + "description": "Generate and vectorize SVGs", + "longDescription": "Generate SVG images from text prompts or vectorize raster images into SVGs using QuiverAI. Supports reference images, style instructions, and multiple output generation.", + "bgColor": "#000000", + "iconName": "QuiverIcon", + "docsUrl": "https://docs.sim.ai/tools/quiver", + "operations": [ + { + "name": "Text to SVG", + "description": "Generate SVG images from text prompts using QuiverAI" + }, + { + "name": "Image to SVG", + "description": "Convert raster images into vector SVG format using QuiverAI" + }, + { + "name": "List Models", + "description": "List all available QuiverAI models" + } + ], + "operationCount": 3, + "triggers": [], + "triggerCount": 0, + "authType": "api-key", + "category": "tools", + "integrationType": "design", + "tags": ["image-generation"] + }, { "type": "reddit", "slug": "reddit", diff --git a/apps/sim/app/api/tools/quiver/image-to-svg/route.ts b/apps/sim/app/api/tools/quiver/image-to-svg/route.ts new file mode 100644 index 00000000000..c65118b3773 --- /dev/null +++ b/apps/sim/app/api/tools/quiver/image-to-svg/route.ts @@ -0,0 +1,141 @@ +import { createLogger } from '@sim/logger' +import { type NextRequest, NextResponse } from 'next/server' +import { z } from 'zod' +import { checkInternalAuth } from '@/lib/auth/hybrid' +import { generateRequestId } from '@/lib/core/utils/request' +import { FileInputSchema, type RawFileInput } from '@/lib/uploads/utils/file-schemas' +import { processFilesToUserFiles } from '@/lib/uploads/utils/file-utils' +import { downloadFileFromStorage } from '@/lib/uploads/utils/file-utils.server' + +const logger = createLogger('QuiverImageToSvgAPI') + +const RequestSchema = z.object({ + apiKey: z.string().min(1), + model: z.string().min(1), + image: z.union([FileInputSchema, z.string()]), + temperature: z.number().min(0).max(2).optional().nullable(), + top_p: z.number().min(0).max(1).optional().nullable(), + max_output_tokens: z.number().int().min(1).max(131072).optional().nullable(), + presence_penalty: z.number().min(-2).max(2).optional().nullable(), + auto_crop: z.boolean().optional().nullable(), + target_size: z.number().int().min(128).max(4096).optional().nullable(), +}) + +export async function POST(request: NextRequest) { + const requestId = generateRequestId() + + const authResult = await checkInternalAuth(request, { requireWorkflowId: false }) + if (!authResult.success) { + return NextResponse.json({ success: false, error: 'Unauthorized' }, { status: 401 }) + } + + try { + const body = await request.json() + const data = RequestSchema.parse(body) + + let apiImage: { url: string } | { base64: string } + + if (typeof data.image === 'string') { + try { + const parsed = JSON.parse(data.image) + if (parsed && typeof parsed === 'object') { + const userFiles = processFilesToUserFiles([parsed as RawFileInput], requestId, logger) + if (userFiles.length > 0) { + const buffer = await downloadFileFromStorage(userFiles[0], requestId, logger) + apiImage = { base64: buffer.toString('base64') } + } else { + return NextResponse.json( + { success: false, error: 'Invalid file input' }, + { status: 400 } + ) + } + } else { + apiImage = { url: data.image } + } + } catch { + apiImage = { url: data.image } + } + } else if (typeof data.image === 'object' && data.image !== null) { + const userFiles = processFilesToUserFiles([data.image as RawFileInput], requestId, logger) + if (userFiles.length > 0) { + const buffer = await downloadFileFromStorage(userFiles[0], requestId, logger) + apiImage = { base64: buffer.toString('base64') } + } else { + return NextResponse.json({ success: false, error: 'Invalid file input' }, { status: 400 }) + } + } else { + return NextResponse.json({ success: false, error: 'Image is required' }, { status: 400 }) + } + + const apiBody: Record = { + model: data.model, + image: apiImage, + } + + if (data.temperature != null) apiBody.temperature = data.temperature + if (data.top_p != null) apiBody.top_p = data.top_p + if (data.max_output_tokens != null) apiBody.max_output_tokens = data.max_output_tokens + if (data.presence_penalty != null) apiBody.presence_penalty = data.presence_penalty + if (data.auto_crop != null) apiBody.auto_crop = data.auto_crop + if (data.target_size != null) apiBody.target_size = data.target_size + + logger.info(`[${requestId}] Calling Quiver vectorization API with model: ${data.model}`) + + const response = await fetch('https://api.quiver.ai/v1/svgs/vectorizations', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${data.apiKey}`, + }, + body: JSON.stringify(apiBody), + }) + + if (!response.ok) { + const errorText = await response.text() + logger.error(`[${requestId}] Quiver API error: ${response.status} - ${errorText}`) + return NextResponse.json( + { success: false, error: `Quiver API error: ${response.status} - ${errorText}` }, + { status: response.status } + ) + } + + const result = await response.json() + + if (!result.data || result.data.length === 0) { + return NextResponse.json( + { success: false, error: 'No SVG data returned from Quiver API' }, + { status: 500 } + ) + } + + const svgContent = result.data[0].svg + const svgBuffer = Buffer.from(svgContent, 'utf-8') + const file = { + name: 'vectorized.svg', + mimeType: 'image/svg+xml', + data: svgBuffer.toString('base64'), + size: svgBuffer.length, + } + + return NextResponse.json({ + success: true, + output: { + file, + files: [file], + svgContent, + id: result.id ?? null, + usage: result.usage + ? { + totalTokens: result.usage.total_tokens ?? 0, + inputTokens: result.usage.input_tokens ?? 0, + outputTokens: result.usage.output_tokens ?? 0, + } + : null, + }, + }) + } catch (error) { + logger.error(`[${requestId}] Error in Quiver image-to-svg:`, error) + const message = error instanceof Error ? error.message : 'Unknown error' + return NextResponse.json({ success: false, error: message }, { status: 500 }) + } +} diff --git a/apps/sim/app/api/tools/quiver/text-to-svg/route.ts b/apps/sim/app/api/tools/quiver/text-to-svg/route.ts new file mode 100644 index 00000000000..9a81b440bd3 --- /dev/null +++ b/apps/sim/app/api/tools/quiver/text-to-svg/route.ts @@ -0,0 +1,142 @@ +import { createLogger } from '@sim/logger' +import { type NextRequest, NextResponse } from 'next/server' +import { z } from 'zod' +import { checkInternalAuth } from '@/lib/auth/hybrid' +import { generateRequestId } from '@/lib/core/utils/request' +import { FileInputSchema, type RawFileInput } from '@/lib/uploads/utils/file-schemas' +import { processFilesToUserFiles } from '@/lib/uploads/utils/file-utils' +import { downloadFileFromStorage } from '@/lib/uploads/utils/file-utils.server' + +const logger = createLogger('QuiverTextToSvgAPI') + +const RequestSchema = z.object({ + apiKey: z.string().min(1), + prompt: z.string().min(1), + model: z.string().min(1), + instructions: z.string().optional().nullable(), + references: z + .union([z.array(FileInputSchema), FileInputSchema, z.string()]) + .optional() + .nullable(), + n: z.number().int().min(1).max(16).optional().nullable(), + temperature: z.number().min(0).max(2).optional().nullable(), + top_p: z.number().min(0).max(1).optional().nullable(), + max_output_tokens: z.number().int().min(1).max(131072).optional().nullable(), + presence_penalty: z.number().min(-2).max(2).optional().nullable(), +}) + +export async function POST(request: NextRequest) { + const requestId = generateRequestId() + + const authResult = await checkInternalAuth(request, { requireWorkflowId: false }) + if (!authResult.success) { + return NextResponse.json({ success: false, error: 'Unauthorized' }, { status: 401 }) + } + + try { + const body = await request.json() + const data = RequestSchema.parse(body) + + const apiReferences: Array<{ url: string } | { base64: string }> = [] + + if (data.references) { + const rawRefs = Array.isArray(data.references) ? data.references : [data.references] + + for (const ref of rawRefs) { + if (typeof ref === 'string') { + try { + const parsed = JSON.parse(ref) + if (parsed && typeof parsed === 'object') { + const userFiles = processFilesToUserFiles([parsed as RawFileInput], requestId, logger) + if (userFiles.length > 0) { + const buffer = await downloadFileFromStorage(userFiles[0], requestId, logger) + apiReferences.push({ base64: buffer.toString('base64') }) + } + } + } catch { + apiReferences.push({ url: ref }) + } + } else if (typeof ref === 'object' && ref !== null) { + const userFiles = processFilesToUserFiles([ref as RawFileInput], requestId, logger) + if (userFiles.length > 0) { + const buffer = await downloadFileFromStorage(userFiles[0], requestId, logger) + apiReferences.push({ base64: buffer.toString('base64') }) + } + } + } + } + + const apiBody: Record = { + model: data.model, + prompt: data.prompt, + } + + if (data.instructions) apiBody.instructions = data.instructions + if (apiReferences.length > 0) apiBody.references = apiReferences.slice(0, 4) + if (data.n != null) apiBody.n = data.n + if (data.temperature != null) apiBody.temperature = data.temperature + if (data.top_p != null) apiBody.top_p = data.top_p + if (data.max_output_tokens != null) apiBody.max_output_tokens = data.max_output_tokens + if (data.presence_penalty != null) apiBody.presence_penalty = data.presence_penalty + + logger.info(`[${requestId}] Calling Quiver API with model: ${data.model}`) + + const response = await fetch('https://api.quiver.ai/v1/svgs/generations', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${data.apiKey}`, + }, + body: JSON.stringify(apiBody), + }) + + if (!response.ok) { + const errorText = await response.text() + logger.error(`[${requestId}] Quiver API error: ${response.status} - ${errorText}`) + return NextResponse.json( + { success: false, error: `Quiver API error: ${response.status} - ${errorText}` }, + { status: response.status } + ) + } + + const result = await response.json() + + if (!result.data || result.data.length === 0) { + return NextResponse.json( + { success: false, error: 'No SVG data returned from Quiver API' }, + { status: 500 } + ) + } + + const files = result.data.map((entry: { svg: string }, index: number) => { + const buffer = Buffer.from(entry.svg, 'utf-8') + return { + name: result.data.length > 1 ? `generated-${index + 1}.svg` : 'generated.svg', + mimeType: 'image/svg+xml', + data: buffer.toString('base64'), + size: buffer.length, + } + }) + + return NextResponse.json({ + success: true, + output: { + file: files[0], + files, + svgContent: result.data[0].svg, + id: result.id ?? null, + usage: result.usage + ? { + totalTokens: result.usage.total_tokens ?? 0, + inputTokens: result.usage.input_tokens ?? 0, + outputTokens: result.usage.output_tokens ?? 0, + } + : null, + }, + }) + } catch (error) { + logger.error(`[${requestId}] Error in Quiver text-to-svg:`, error) + const message = error instanceof Error ? error.message : 'Unknown error' + return NextResponse.json({ success: false, error: message }, { status: 500 }) + } +} diff --git a/apps/sim/blocks/blocks/quiver.ts b/apps/sim/blocks/blocks/quiver.ts new file mode 100644 index 00000000000..689a47d971c --- /dev/null +++ b/apps/sim/blocks/blocks/quiver.ts @@ -0,0 +1,251 @@ +import { QuiverIcon } from '@/components/icons' +import type { BlockConfig } from '@/blocks/types' +import { AuthMode, IntegrationType } from '@/blocks/types' +import { normalizeFileInput } from '@/blocks/utils' +import type { QuiverSvgResponse } from '@/tools/quiver/types' + +export const QuiverBlock: BlockConfig = { + type: 'quiver', + name: 'Quiver', + description: 'Generate and vectorize SVGs', + longDescription: + 'Generate SVG images from text prompts or vectorize raster images into SVGs using QuiverAI. Supports reference images, style instructions, and multiple output generation.', + docsLink: 'https://docs.sim.ai/tools/quiver', + category: 'tools', + integrationType: IntegrationType.Design, + tags: ['image-generation'], + bgColor: '#000000', + icon: QuiverIcon, + authMode: AuthMode.ApiKey, + subBlocks: [ + { + id: 'operation', + title: 'Operation', + type: 'dropdown', + options: [ + { label: 'Text to SVG', id: 'text_to_svg' }, + { label: 'Image to SVG', id: 'image_to_svg' }, + { label: 'List Models', id: 'list_models' }, + ], + value: () => 'text_to_svg', + }, + { + id: 'model', + title: 'Model', + type: 'dropdown', + options: [{ label: 'Arrow Preview', id: 'arrow-preview' }], + value: () => 'arrow-preview', + condition: { field: 'operation', value: ['text_to_svg', 'image_to_svg'] }, + }, + { + id: 'prompt', + title: 'Prompt', + type: 'long-input', + placeholder: 'Describe the SVG you want to generate...', + required: { field: 'operation', value: 'text_to_svg' }, + condition: { field: 'operation', value: 'text_to_svg' }, + }, + { + id: 'instructions', + title: 'Instructions', + type: 'long-input', + placeholder: 'Style or formatting guidance (optional)', + required: false, + condition: { field: 'operation', value: 'text_to_svg' }, + }, + { + id: 'referenceFiles', + title: 'Reference Images', + type: 'file-upload', + canonicalParamId: 'references', + placeholder: 'Upload reference images (up to 4)', + mode: 'basic', + multiple: true, + required: false, + condition: { field: 'operation', value: 'text_to_svg' }, + }, + { + id: 'referenceInput', + title: 'Reference Images', + type: 'short-input', + canonicalParamId: 'references', + placeholder: 'Reference files from previous blocks', + mode: 'advanced', + required: false, + condition: { field: 'operation', value: 'text_to_svg' }, + }, + { + id: 'n', + title: 'Number of Outputs', + type: 'short-input', + placeholder: '1', + mode: 'advanced', + required: false, + condition: { field: 'operation', value: 'text_to_svg' }, + }, + { + id: 'imageFile', + title: 'Image', + type: 'file-upload', + canonicalParamId: 'image', + placeholder: 'Upload an image to vectorize', + mode: 'basic', + multiple: false, + required: { field: 'operation', value: 'image_to_svg' }, + condition: { field: 'operation', value: 'image_to_svg' }, + }, + { + id: 'imageInput', + title: 'Image', + type: 'short-input', + canonicalParamId: 'image', + placeholder: 'Reference image from previous blocks', + mode: 'advanced', + required: { field: 'operation', value: 'image_to_svg' }, + condition: { field: 'operation', value: 'image_to_svg' }, + }, + { + id: 'autoCrop', + title: 'Auto Crop', + type: 'dropdown', + options: [ + { label: 'No', id: 'false' }, + { label: 'Yes', id: 'true' }, + ], + value: () => 'false', + mode: 'advanced', + condition: { field: 'operation', value: 'image_to_svg' }, + }, + { + id: 'targetSize', + title: 'Target Size (px)', + type: 'short-input', + placeholder: '128-4096', + mode: 'advanced', + required: false, + condition: { field: 'operation', value: 'image_to_svg' }, + }, + { + id: 'temperature', + title: 'Temperature', + type: 'short-input', + placeholder: '1', + mode: 'advanced', + required: false, + condition: { field: 'operation', value: ['text_to_svg', 'image_to_svg'] }, + }, + { + id: 'topP', + title: 'Top P', + type: 'short-input', + placeholder: '1', + mode: 'advanced', + required: false, + condition: { field: 'operation', value: ['text_to_svg', 'image_to_svg'] }, + }, + { + id: 'maxOutputTokens', + title: 'Max Output Tokens', + type: 'short-input', + placeholder: '131072', + mode: 'advanced', + required: false, + condition: { field: 'operation', value: ['text_to_svg', 'image_to_svg'] }, + }, + { + id: 'presencePenalty', + title: 'Presence Penalty', + type: 'short-input', + placeholder: '0', + mode: 'advanced', + required: false, + condition: { field: 'operation', value: ['text_to_svg', 'image_to_svg'] }, + }, + { + id: 'apiKey', + title: 'API Key', + type: 'short-input', + placeholder: 'Enter your QuiverAI API key', + password: true, + required: true, + }, + ], + tools: { + access: ['quiver_text_to_svg', 'quiver_image_to_svg', 'quiver_list_models'], + config: { + tool: (params: Record) => `quiver_${params.operation}`, + params: (params: Record) => { + const { + references, + image, + topP, + maxOutputTokens, + presencePenalty, + targetSize, + autoCrop, + ...rest + } = params + + const normalizedRefs = normalizeFileInput(references) + const normalizedImage = normalizeFileInput(image, { single: true }) + + return { + ...rest, + ...(normalizedRefs && { references: normalizedRefs }), + ...(normalizedImage && { image: normalizedImage }), + ...(rest.n && { n: Number(rest.n) }), + ...(rest.temperature && { temperature: Number(rest.temperature) }), + ...(topP && { top_p: Number(topP) }), + ...(maxOutputTokens && { max_output_tokens: Number(maxOutputTokens) }), + ...(presencePenalty && { presence_penalty: Number(presencePenalty) }), + ...(targetSize && { target_size: Number(targetSize) }), + ...(autoCrop === 'true' && { auto_crop: true }), + } + }, + }, + }, + inputs: { + prompt: { type: 'string', required: false }, + instructions: { type: 'string', required: false }, + references: { type: 'file', required: false }, + image: { type: 'file', required: false }, + }, + outputs: { + file: { + type: 'file', + description: 'First generated SVG file', + }, + files: { + type: 'json', + description: 'All generated SVG files (when n > 1)', + }, + svgContent: { + type: 'string', + description: 'Raw SVG markup content', + }, + id: { + type: 'string', + description: 'Request ID', + }, + usage: { + type: 'json', + description: 'Token usage statistics', + properties: { + totalTokens: { type: 'number', description: 'Total tokens used' }, + inputTokens: { type: 'number', description: 'Input tokens used' }, + outputTokens: { type: 'number', description: 'Output tokens used' }, + }, + }, + models: { + type: 'json', + description: 'List of available models (list_models operation only)', + optional: true, + properties: { + id: { type: 'string', description: 'Model identifier' }, + name: { type: 'string', description: 'Human-readable model name' }, + description: { type: 'string', description: 'Model capabilities summary' }, + supportedOperations: { type: 'json', description: 'Available operations' }, + }, + }, + }, +} diff --git a/apps/sim/blocks/registry.ts b/apps/sim/blocks/registry.ts index 074bb38b849..a857038e021 100644 --- a/apps/sim/blocks/registry.ts +++ b/apps/sim/blocks/registry.ts @@ -137,6 +137,7 @@ import { PostgreSQLBlock } from '@/blocks/blocks/postgresql' import { PostHogBlock } from '@/blocks/blocks/posthog' import { PulseBlock, PulseV2Block } from '@/blocks/blocks/pulse' import { QdrantBlock } from '@/blocks/blocks/qdrant' +import { QuiverBlock } from '@/blocks/blocks/quiver' import { RDSBlock } from '@/blocks/blocks/rds' import { RedditBlock } from '@/blocks/blocks/reddit' import { RedisBlock } from '@/blocks/blocks/redis' @@ -357,6 +358,7 @@ export const registry: Record = { pulse: PulseBlock, pulse_v2: PulseV2Block, qdrant: QdrantBlock, + quiver: QuiverBlock, rds: RDSBlock, reddit: RedditBlock, redis: RedisBlock, diff --git a/apps/sim/components/icons.tsx b/apps/sim/components/icons.tsx index ca2a9b16353..a7ee06c5e8d 100644 --- a/apps/sim/components/icons.tsx +++ b/apps/sim/components/icons.tsx @@ -3132,6 +3132,22 @@ export function QdrantIcon(props: SVGProps) { ) } +export function QuiverIcon(props: SVGProps) { + return ( + + + + + + ) +} + export function AshbyIcon(props: SVGProps) { return ( diff --git a/apps/sim/tools/quiver/image_to_svg.ts b/apps/sim/tools/quiver/image_to_svg.ts new file mode 100644 index 00000000000..ec05c4b20df --- /dev/null +++ b/apps/sim/tools/quiver/image_to_svg.ts @@ -0,0 +1,123 @@ +import type { QuiverImageToSvgParams, QuiverSvgResponse } from '@/tools/quiver/types' +import type { ToolConfig } from '@/tools/types' + +export const quiverImageToSvgTool: ToolConfig = { + id: 'quiver_image_to_svg', + name: 'Quiver Image to SVG', + description: 'Convert raster images into vector SVG format using QuiverAI', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'QuiverAI API key', + }, + model: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'The model to use for vectorization (e.g., "arrow-preview")', + }, + image: { + type: 'file', + required: true, + visibility: 'user-or-llm', + description: 'The raster image to vectorize into SVG', + }, + temperature: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Sampling temperature (0-2, default 1)', + }, + top_p: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Nucleus sampling probability (0-1, default 1)', + }, + max_output_tokens: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Maximum output tokens (1-131072)', + }, + presence_penalty: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Token penalty for prior output (-2 to 2, default 0)', + }, + auto_crop: { + type: 'boolean', + required: false, + visibility: 'user-or-llm', + description: 'Automatically crop the image before vectorizing', + }, + target_size: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Square resize target in pixels (128-4096)', + }, + }, + + request: { + url: '/api/tools/quiver/image-to-svg', + method: 'POST', + body: (params) => ({ + apiKey: params.apiKey, + model: params.model, + image: params.image, + temperature: params.temperature, + top_p: params.top_p, + max_output_tokens: params.max_output_tokens, + presence_penalty: params.presence_penalty, + auto_crop: params.auto_crop, + target_size: params.target_size, + }), + }, + + transformResponse: async (response) => { + const data = await response.json() + + if (!data.success) { + throw new Error(data.error || 'Failed to vectorize image') + } + + return data + }, + + outputs: { + success: { type: 'boolean', description: 'Whether the vectorization succeeded' }, + output: { + type: 'object', + description: 'Vectorized SVG output', + properties: { + file: { + type: 'file', + description: 'Generated SVG file', + }, + svgContent: { + type: 'string', + description: 'Raw SVG markup content', + }, + id: { + type: 'string', + description: 'Vectorization request ID', + }, + usage: { + type: 'json', + description: 'Token usage statistics', + properties: { + totalTokens: { type: 'number', description: 'Total tokens used' }, + inputTokens: { type: 'number', description: 'Input tokens used' }, + outputTokens: { type: 'number', description: 'Output tokens used' }, + }, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/quiver/index.ts b/apps/sim/tools/quiver/index.ts new file mode 100644 index 00000000000..6a252618f68 --- /dev/null +++ b/apps/sim/tools/quiver/index.ts @@ -0,0 +1,4 @@ +export { quiverImageToSvgTool } from '@/tools/quiver/image_to_svg' +export { quiverListModelsTool } from '@/tools/quiver/list_models' +export { quiverTextToSvgTool } from '@/tools/quiver/text_to_svg' +export * from '@/tools/quiver/types' diff --git a/apps/sim/tools/quiver/list_models.ts b/apps/sim/tools/quiver/list_models.ts new file mode 100644 index 00000000000..7b46853efa2 --- /dev/null +++ b/apps/sim/tools/quiver/list_models.ts @@ -0,0 +1,117 @@ +import type { QuiverListModelsParams, QuiverListModelsResponse } from '@/tools/quiver/types' +import type { ToolConfig } from '@/tools/types' + +export const quiverListModelsTool: ToolConfig = { + id: 'quiver_list_models', + name: 'Quiver List Models', + description: 'List all available QuiverAI models', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'QuiverAI API key', + }, + }, + + request: { + url: 'https://api.quiver.ai/v1/models', + method: 'GET', + headers: (params) => ({ + Authorization: `Bearer ${params.apiKey}`, + }), + }, + + transformResponse: async (response) => { + if (!response.ok) { + let message = `Quiver API error: ${response.status}` + try { + const errorData = await response.json() + message = errorData.message || message + } catch { + // Non-JSON error body (e.g. HTML from gateway) + } + throw new Error(message) + } + + const data = await response.json() + + const models = (data.data ?? []).map( + (model: { + id: string + name: string + description: string + created: number + owned_by: string + input_modalities: string[] + output_modalities: string[] + context_length: number + max_output_length: number + supported_operations: string[] + supported_sampling_parameters: string[] + }) => ({ + id: model.id ?? null, + name: model.name ?? null, + description: model.description ?? null, + created: model.created ?? null, + ownedBy: model.owned_by ?? null, + inputModalities: model.input_modalities ?? [], + outputModalities: model.output_modalities ?? [], + contextLength: model.context_length ?? null, + maxOutputLength: model.max_output_length ?? null, + supportedOperations: model.supported_operations ?? [], + supportedSamplingParameters: model.supported_sampling_parameters ?? [], + }) + ) + + return { + success: true, + output: { + models, + }, + } + }, + + outputs: { + success: { type: 'boolean', description: 'Whether the request succeeded' }, + output: { + type: 'object', + description: 'Available models', + properties: { + models: { + type: 'json', + description: 'List of available QuiverAI models', + properties: { + id: { type: 'string', description: 'Model identifier' }, + name: { type: 'string', description: 'Human-readable model name' }, + description: { type: 'string', description: 'Model capabilities summary' }, + created: { type: 'number', description: 'Unix timestamp of creation' }, + ownedBy: { type: 'string', description: 'Organization that owns the model' }, + inputModalities: { + type: 'json', + description: 'Supported input types (text, image, svg)', + }, + outputModalities: { + type: 'json', + description: 'Supported output types (text, image, svg)', + }, + contextLength: { type: 'number', description: 'Maximum context window' }, + maxOutputLength: { type: 'number', description: 'Maximum generation length' }, + supportedOperations: { + type: 'json', + description: + 'Available operations (svg_generate, svg_edit, svg_animate, svg_vectorize, chat_completions)', + }, + supportedSamplingParameters: { + type: 'json', + description: + 'Supported sampling parameters (temperature, top_p, top_k, repetition_penalty, presence_penalty, stop)', + }, + }, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/quiver/text_to_svg.ts b/apps/sim/tools/quiver/text_to_svg.ts new file mode 100644 index 00000000000..200d7778e75 --- /dev/null +++ b/apps/sim/tools/quiver/text_to_svg.ts @@ -0,0 +1,134 @@ +import type { QuiverSvgResponse, QuiverTextToSvgParams } from '@/tools/quiver/types' +import type { ToolConfig } from '@/tools/types' + +export const quiverTextToSvgTool: ToolConfig = { + id: 'quiver_text_to_svg', + name: 'Quiver Text to SVG', + description: 'Generate SVG images from text prompts using QuiverAI', + version: '1.0.0', + + params: { + apiKey: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'QuiverAI API key', + }, + prompt: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'A text description of the desired SVG', + }, + model: { + type: 'string', + required: true, + visibility: 'user-only', + description: 'The model to use for SVG generation (e.g., "arrow-preview")', + }, + instructions: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'Style or formatting guidance for the SVG output', + }, + references: { + type: 'file', + required: false, + visibility: 'user-or-llm', + description: 'Reference images to guide SVG generation (up to 4)', + }, + n: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Number of SVGs to generate (1-16, default 1)', + }, + temperature: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Sampling temperature (0-2, default 1)', + }, + top_p: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Nucleus sampling probability (0-1, default 1)', + }, + max_output_tokens: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Maximum output tokens (1-131072)', + }, + presence_penalty: { + type: 'number', + required: false, + visibility: 'user-or-llm', + description: 'Token penalty for prior output (-2 to 2, default 0)', + }, + }, + + request: { + url: '/api/tools/quiver/text-to-svg', + method: 'POST', + body: (params) => ({ + apiKey: params.apiKey, + prompt: params.prompt, + model: params.model, + instructions: params.instructions, + references: params.references, + n: params.n, + temperature: params.temperature, + top_p: params.top_p, + max_output_tokens: params.max_output_tokens, + presence_penalty: params.presence_penalty, + }), + }, + + transformResponse: async (response) => { + const data = await response.json() + + if (!data.success) { + throw new Error(data.error || 'Failed to generate SVG') + } + + return data + }, + + outputs: { + success: { type: 'boolean', description: 'Whether the SVG generation succeeded' }, + output: { + type: 'object', + description: 'Generated SVG output', + properties: { + file: { + type: 'file', + description: 'First generated SVG file', + }, + files: { + type: 'json', + description: 'All generated SVG files (when n > 1)', + }, + svgContent: { + type: 'string', + description: 'Raw SVG markup content of the first result', + }, + id: { + type: 'string', + description: 'Generation request ID', + }, + usage: { + type: 'json', + description: 'Token usage statistics', + properties: { + totalTokens: { type: 'number', description: 'Total tokens used' }, + inputTokens: { type: 'number', description: 'Input tokens used' }, + outputTokens: { type: 'number', description: 'Output tokens used' }, + }, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/quiver/types.ts b/apps/sim/tools/quiver/types.ts new file mode 100644 index 00000000000..ba54ab25214 --- /dev/null +++ b/apps/sim/tools/quiver/types.ts @@ -0,0 +1,72 @@ +import type { ToolResponse } from '@/tools/types' + +export interface QuiverTextToSvgParams { + apiKey: string + prompt: string + model: string + instructions?: string + references?: unknown + n?: number + temperature?: number + top_p?: number + max_output_tokens?: number + presence_penalty?: number +} + +export interface QuiverImageToSvgParams { + apiKey: string + model: string + image: unknown + temperature?: number + top_p?: number + max_output_tokens?: number + presence_penalty?: number + auto_crop?: boolean + target_size?: number +} + +export interface QuiverListModelsParams { + apiKey: string +} + +export interface QuiverSvgResponse extends ToolResponse { + output: { + file: { + name: string + mimeType: string + data: string + size: number + } + files: Array<{ + name: string + mimeType: string + data: string + size: number + }> + svgContent: string + id: string + usage: { + totalTokens: number + inputTokens: number + outputTokens: number + } | null + } +} + +export interface QuiverListModelsResponse extends ToolResponse { + output: { + models: Array<{ + id: string + name: string + description: string + created: number | null + ownedBy: string | null + inputModalities: string[] + outputModalities: string[] + contextLength: number | null + maxOutputLength: number | null + supportedOperations: string[] + supportedSamplingParameters: string[] + }> + } +} diff --git a/apps/sim/tools/registry.ts b/apps/sim/tools/registry.ts index 3e840197ace..be98b26b3de 100644 --- a/apps/sim/tools/registry.ts +++ b/apps/sim/tools/registry.ts @@ -1738,6 +1738,7 @@ import { } from '@/tools/posthog' import { pulseParserTool, pulseParserV2Tool } from '@/tools/pulse' import { qdrantFetchTool, qdrantSearchTool, qdrantUpsertTool } from '@/tools/qdrant' +import { quiverImageToSvgTool, quiverListModelsTool, quiverTextToSvgTool } from '@/tools/quiver' import { rdsDeleteTool, rdsExecuteTool, @@ -3542,6 +3543,9 @@ export const tools: Record = { perplexity_search: perplexitySearchTool, pulse_parser: pulseParserTool, pulse_parser_v2: pulseParserV2Tool, + quiver_image_to_svg: quiverImageToSvgTool, + quiver_list_models: quiverListModelsTool, + quiver_text_to_svg: quiverTextToSvgTool, posthog_capture_event: posthogCaptureEventTool, posthog_batch_events: posthogBatchEventsTool, posthog_list_persons: posthogListPersonsTool,