Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions apps/docs/content/docs/integrations/gamma.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ Generate a new Gamma presentation, document, webpage, or social post from text i
| `cardSplit` | string | No | How to split content into cards: auto or inputTextBreaks \(default: auto\) |
| `cardDimensions` | string | No | Card aspect ratio. Presentation: fluid, 16x9, 4x3. Document: fluid, pageless, letter, a4. Social: 1x1, 4x5, 9x16 |
| `additionalInstructions` | string | No | Additional instructions for the AI generation \(max 2000 chars\) |
| `exportAs` | string | No | Automatically export the generated gamma as pdf or pptx |
| `folderIds` | string | No | Comma-separated folder IDs to store the generated gamma in |
| `exportAs` | string | No | Automatically export the generated gamma as pdf, pptx, or png \(a zip of one PNG per card\). Check Status returns the download URL |
| `folderIds` | string | No | ID of the folder to store the generated gamma in \(Gamma accepts one folder\) |
| `textAmount` | string | No | Amount of text per card: brief, medium, detailed, or extensive |
| `textTone` | string | No | Tone of the generated text, e.g. "professional", "casual" \(max 500 chars\) |
| `textAudience` | string | No | Target audience for the generated text, e.g. "executives", "students" \(max 500 chars\) |
| `textLanguage` | string | No | Language code for the generated text \(default: en\) |
| `imageSource` | string | No | Where to source images: aiGenerated, pictographic, unsplash, webAllImages, webFreeToUse, webFreeToUseCommercially, giphy, placeholder, or noImages |
| `imageSource` | string | No | Where to source images: aiGenerated, pictographic, pexels, webAllImages, webFreeToUse, webFreeToUseCommercially, giphy, themeAccent, placeholder, or noImages |
| `imageModel` | string | No | AI image generation model to use when imageSource is aiGenerated |
| `imageStyle` | string | No | Style directive for AI-generated images, e.g. "watercolor", "photorealistic" \(max 500 chars\) |

Expand All @@ -52,6 +52,7 @@ Generate a new Gamma presentation, document, webpage, or social post from text i
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `generationId` | string | The ID of the generation job. Use with Check Status to poll for completion. |
| `warnings` | string | Warnings about request options that Gamma ignored |

</ReferenceDetails>

Expand All @@ -68,8 +69,8 @@ Generate a new Gamma by adapting an existing template with a prompt.
| `gammaId` | string | Yes | The ID of the template gamma to adapt |
| `prompt` | string | Yes | Instructions for how to adapt the template \(1-100,000 tokens\) |
| `themeId` | string | No | Custom Gamma workspace theme ID to apply |
| `exportAs` | string | No | Automatically export the generated gamma as pdf or pptx |
| `folderIds` | string | No | Comma-separated folder IDs to store the generated gamma in |
| `exportAs` | string | No | Automatically export the generated gamma as pdf, pptx, or png \(a zip of one PNG per card\). Check Status returns the download URL |
| `folderIds` | string | No | ID of the folder to store the generated gamma in \(Gamma accepts one folder\) |
| `imageModel` | string | No | AI image generation model to use when imageSource is aiGenerated |
| `imageStyle` | string | No | Style directive for AI-generated images, e.g. "watercolor", "photorealistic" \(max 500 chars\) |

Expand All @@ -78,6 +79,7 @@ Generate a new Gamma by adapting an existing template with a prompt.
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `generationId` | string | The ID of the generation job. Use with Check Status to poll for completion. |
| `warnings` | string | Warnings about request options that Gamma ignored |

</ReferenceDetails>

Expand All @@ -100,6 +102,8 @@ Check the status of a Gamma generation job. Returns the gamma URL when completed
| `generationId` | string | The generation ID that was checked |
| `status` | string | Generation status: pending, completed, or failed |
| `gammaUrl` | string | URL of the generated gamma \(only present when status is completed\) |
| `gammaId` | string | ID of the generated gamma \(only present when status is completed\) |
| `exportUrl` | string | Download URL of the exported file when Export As was set \(pdf, pptx, or a zip of PNGs\). Anyone with the link can download it until it expires, about a week later |
| `credits` | object | Credit usage information \(only present when status is completed\) |
| ↳ `deducted` | number | Number of credits deducted for this generation |
| ↳ `remaining` | number | Remaining credits in the account |
Expand Down
43 changes: 43 additions & 0 deletions apps/sim/blocks/blocks/dspy.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { describe, expect, it } from 'vitest'
import { DSPyBlock } from '@/blocks/blocks/dspy'

function mapParams(params: Record<string, unknown>) {
const mapper = DSPyBlock.tools.config?.params
if (!mapper) throw new Error('DSPy block has no params mapper')
return mapper({ operation: 'predict', baseUrl: 'https://dspy.example.com', ...params })
}

describe('DSPy block params', () => {
it('keeps Additional Inputs that an agent passes as an object', () => {
expect(mapParams({ additionalInputs: { topic: 'billing' } }).additionalInputs).toEqual({
topic: 'billing',
})
})

it('fails on Additional Inputs that are not valid JSON instead of dropping them', () => {
expect(() => mapParams({ additionalInputs: '{"topic": ' })).toThrow(
'Additional Inputs must be valid JSON'
)
})

it('fails on Additional Inputs that an agent passes as an array instead of dropping them', () => {
expect(() =>
DSPyBlock.tools.config?.params?.(
{ baseUrl: 'https://dspy.example.com', additionalInputs: ['billing'] },
{ operation: 'predict' }
)
).toThrow()
})

it('ignores stale Additional Inputs on operations that do not send them', () => {
expect(
mapParams({ operation: 'react', additionalInputs: '{"topic": ' }).additionalInputs
).toBeUndefined()
})

it('fails on Additional Inputs that are JSON but not an object', () => {
expect(() => mapParams({ additionalInputs: '["billing"]' })).toThrow(
'Additional Inputs must be a JSON object'
)
})
})
34 changes: 25 additions & 9 deletions apps/sim/blocks/blocks/dspy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
import { isPlainRecord } from '@sim/utils/object'
import { DsPyIcon } from '@/components/icons'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { IntegrationType } from '@/blocks/types'
import { failToolCallOnError, mapperOperation } from '@/blocks/utils'

/** Predict's Additional Inputs: a JSON object as text from the canvas, or an object from an agent. */
function parseAdditionalInputs(value: unknown): Record<string, unknown> | undefined {
if (value === undefined || value === null) return undefined
if (typeof value === 'string' && !value.trim()) return undefined
let parsed: unknown = value
if (typeof value === 'string') {
try {
parsed = JSON.parse(value)
} catch {
throw new Error('Additional Inputs must be valid JSON')
}
}
if (!isPlainRecord(parsed)) {
throw new Error('Additional Inputs must be a JSON object')
}
return parsed
}

export const DSPyBlock: BlockConfig = {
type: 'dspy',
Expand Down Expand Up @@ -142,17 +162,13 @@ export const DSPyBlock: BlockConfig = {
access: ['dspy_predict', 'dspy_chain_of_thought', 'dspy_react'],
config: {
tool: (params) => `dspy_${params.operation}`,
params: (params) => {
params: (params, context) => {
const { operation, additionalInputs, maxIterations, ...rest } = params

let parsedAdditionalInputs: Record<string, unknown> | undefined
if (additionalInputs && typeof additionalInputs === 'string') {
try {
parsedAdditionalInputs = JSON.parse(additionalInputs)
} catch {
// Ignore parse errors
}
}
const parsedAdditionalInputs =
mapperOperation(params, context) === 'predict'
? failToolCallOnError(context, () => parseAdditionalInputs(additionalInputs))
: undefined

let parsedMaxIterations: number | undefined
if (maxIterations) {
Expand Down
24 changes: 10 additions & 14 deletions apps/sim/blocks/blocks/gamma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,13 @@ Return ONLY the dimension value string, nothing else.`,
options: [
{ label: 'AI Generated', id: 'aiGenerated' },
{ label: 'Pictographic', id: 'pictographic' },
{ label: 'Unsplash', id: 'unsplash' },
{ label: 'Pexels', id: 'pexels' },
{ label: 'Unsplash', id: 'unsplash', hidden: true },
{ label: 'Web (All Images)', id: 'webAllImages' },
{ label: 'Web (Free to Use)', id: 'webFreeToUse' },
{ label: 'Web (Free Commercial)', id: 'webFreeToUseCommercially' },
{ label: 'Giphy', id: 'giphy' },
{ label: 'Theme Accent', id: 'themeAccent' },
{ label: 'Placeholder', id: 'placeholder' },
{ label: 'No Images', id: 'noImages' },
],
Expand Down Expand Up @@ -212,6 +214,7 @@ Return ONLY the dimension value string, nothing else.`,
{ label: 'None', id: '' },
{ label: 'PDF', id: 'pdf' },
{ label: 'PPTX', id: 'pptx' },
{ label: 'PNG (zip)', id: 'png' },
],
value: () => '',
condition: { field: 'operation', value: ['generate', 'generate_from_template'] },
Expand All @@ -227,21 +230,11 @@ Return ONLY the dimension value string, nothing else.`,
},
{
id: 'folderIds',
title: 'Folder IDs',
title: 'Folder ID',
type: 'short-input',
placeholder: 'Comma-separated folder IDs',
placeholder: 'Folder ID (use List Folders to find)',
condition: { field: 'operation', value: ['generate', 'generate_from_template'] },
mode: 'advanced',
wandConfig: {
enabled: true,
prompt: `Generate a comma-separated list of Gamma folder IDs.
The user will describe which folders to store the generated gamma in.
Each folder ID is a string identifier from the Gamma workspace.
Use the List Folders operation to find available folder IDs first.
Return ONLY the comma-separated IDs, nothing else.
Example: "folder_abc123, folder_def456"`,
placeholder: 'Describe which folders to store the gamma in...',
},
},
// Generate from Template inputs
{
Expand Down Expand Up @@ -342,7 +335,7 @@ Example: "folder_abc123, folder_def456"`,
imageStyle: { type: 'string', description: 'Image style directive' },
exportAs: { type: 'string', description: 'Export format' },
themeId: { type: 'string', description: 'Theme ID' },
folderIds: { type: 'string', description: 'Comma-separated folder IDs' },
folderIds: { type: 'string', description: 'Folder ID' },
gammaId: { type: 'string', description: 'Template gamma ID' },
prompt: { type: 'string', description: 'Template adaptation prompt' },
generationId: { type: 'string', description: 'Generation ID to check' },
Expand All @@ -354,6 +347,9 @@ Example: "folder_abc123, folder_def456"`,
generationId: { type: 'string', description: 'Generation job ID' },
status: { type: 'string', description: 'Generation status' },
gammaUrl: { type: 'string', description: 'URL of the generated gamma' },
gammaId: { type: 'string', description: 'ID of the generated gamma' },
exportUrl: { type: 'string', description: 'Download URL of the exported file' },
warnings: { type: 'string', description: 'Warnings about request options Gamma ignored' },
credits: { type: 'json', description: 'Credit usage (deducted, remaining)' },
error: { type: 'json', description: 'Error details if generation failed' },
themes: { type: 'json', description: 'List of themes' },
Expand Down
19 changes: 19 additions & 0 deletions apps/sim/blocks/blocks/huggingface.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, expect, it } from 'vitest'
import { HuggingFaceBlock } from '@/blocks/blocks/huggingface'

describe('Hugging Face block params', () => {
it('sends a temperature of 0 instead of dropping it', () => {
const mapper = HuggingFaceBlock.tools.config?.params
if (!mapper) throw new Error('Hugging Face block has no params mapper')

const result = mapper({
apiKey: 'hf_test',
provider: 'novita',
model: 'org/model',
content: 'hi',
temperature: 0,
})

expect(result.temperature).toBe(0)
})
})
7 changes: 6 additions & 1 deletion apps/sim/blocks/blocks/huggingface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ export const HuggingFaceBlock: BlockConfig = {
model: params.model,
content: params.content,
systemPrompt: params.systemPrompt,
temperature: params.temperature ? Number.parseFloat(params.temperature) : undefined,
temperature:
params.temperature === undefined ||
params.temperature === null ||
params.temperature === ''
? undefined
: Number.parseFloat(params.temperature),
maxTokens: params.maxTokens ? Number.parseInt(params.maxTokens) : undefined,
stream: false, // Always false
}
Expand Down
7 changes: 2 additions & 5 deletions apps/sim/tools/dspy/chain_of_thought.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { DSPyChainOfThoughtParams, DSPyChainOfThoughtResponse } from '@/tools/dspy/types'
import { buildDSPyUrl } from '@/tools/dspy/utils'
import type { ToolConfig } from '@/tools/types'

export const chainOfThoughtTool: ToolConfig<DSPyChainOfThoughtParams, DSPyChainOfThoughtResponse> =
Expand Down Expand Up @@ -48,11 +49,7 @@ export const chainOfThoughtTool: ToolConfig<DSPyChainOfThoughtParams, DSPyChainO
select: (params) => ({ question: params.question, context: params.context }),
},
method: 'POST',
url: (params) => {
const baseUrl = params.baseUrl.replace(/\/$/, '')
const endpoint = params.endpoint || '/predict'
return `${baseUrl}${endpoint}`
},
url: (params) => buildDSPyUrl(params.baseUrl, params.endpoint),
headers: (params) => {
const headers: Record<string, string> = {
'Content-Type': 'application/json',
Expand Down
7 changes: 2 additions & 5 deletions apps/sim/tools/dspy/predict.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { DSPyPredictParams, DSPyPredictResponse } from '@/tools/dspy/types'
import { buildDSPyUrl } from '@/tools/dspy/utils'
import type { ToolConfig } from '@/tools/types'

export const predictTool: ToolConfig<DSPyPredictParams, DSPyPredictResponse> = {
Expand Down Expand Up @@ -58,11 +59,7 @@ export const predictTool: ToolConfig<DSPyPredictParams, DSPyPredictResponse> = {
select: (params) => ({ input: params.input, context: params.context }),
},
method: 'POST',
url: (params) => {
const baseUrl = params.baseUrl.replace(/\/$/, '')
const endpoint = params.endpoint || '/predict'
return `${baseUrl}${endpoint}`
},
url: (params) => buildDSPyUrl(params.baseUrl, params.endpoint),
headers: (params) => {
const headers: Record<string, string> = {
'Content-Type': 'application/json',
Expand Down
8 changes: 2 additions & 6 deletions apps/sim/tools/dspy/react.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DSPyReActParams, DSPyReActResponse } from '@/tools/dspy/types'
import { parseTrajectory } from '@/tools/dspy/utils'
import { buildDSPyUrl, parseTrajectory } from '@/tools/dspy/utils'
import type { ToolConfig } from '@/tools/types'

export const reactTool: ToolConfig<DSPyReActParams, DSPyReActResponse> = {
Expand Down Expand Up @@ -54,11 +54,7 @@ export const reactTool: ToolConfig<DSPyReActParams, DSPyReActResponse> = {
select: (params) => ({ task: params.task, context: params.context }),
},
method: 'POST',
url: (params) => {
const baseUrl = params.baseUrl.replace(/\/$/, '')
const endpoint = params.endpoint || '/predict'
return `${baseUrl}${endpoint}`
},
url: (params) => buildDSPyUrl(params.baseUrl, params.endpoint),
headers: (params) => {
const headers: Record<string, string> = {
'Content-Type': 'application/json',
Expand Down
14 changes: 14 additions & 0 deletions apps/sim/tools/dspy/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { describe, expect, it } from 'vitest'
import { buildDSPyUrl } from '@/tools/dspy/utils'

describe('buildDSPyUrl', () => {
it('adds the slash an endpoint path was typed without', () => {
expect(buildDSPyUrl('https://dspy.example.com/', 'predict')).toBe(
'https://dspy.example.com/predict'
)
})

it('defaults to /predict', () => {
expect(buildDSPyUrl('https://dspy.example.com', '')).toBe('https://dspy.example.com/predict')
})
})
9 changes: 9 additions & 0 deletions apps/sim/tools/dspy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ export function parseTrajectory(trajectory: Record<string, unknown>): DSPyTrajec

return steps
}

/**
* The DSPy server URL for an endpoint path (default `/predict`). A path typed without its
* leading slash still lands on that path instead of being appended to the host name.
*/
export function buildDSPyUrl(baseUrl: string, endpoint?: string): string {
const path = endpoint?.trim() || '/predict'
return `${baseUrl.replace(/\/$/, '')}${path.startsWith('/') ? path : `/${path}`}`
}
4 changes: 3 additions & 1 deletion apps/sim/tools/elevenlabs/edit-voice-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
} from '@/tools/elevenlabs/types'
import { ELEVENLABS_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
import type { ToolConfig } from '@/tools/types'
import { safeUrlPathSegment } from '@/tools/url-path'

export const elevenLabsEditVoiceSettingsTool: ToolConfig<
ElevenLabsEditVoiceSettingsParams,
Expand Down Expand Up @@ -61,7 +62,8 @@ export const elevenLabsEditVoiceSettingsTool: ToolConfig<
},

request: {
url: (params) => `https://api.elevenlabs.io/v1/voices/${params.voiceId.trim()}/settings/edit`,
url: (params) =>
`https://api.elevenlabs.io/v1/voices/${safeUrlPathSegment(params.voiceId, 'voiceId')}/settings/edit`,
method: 'POST',
headers: (params) => ({
'xi-api-key': params.apiKey,
Expand Down
4 changes: 3 additions & 1 deletion apps/sim/tools/elevenlabs/get-voice-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
} from '@/tools/elevenlabs/types'
import { ELEVENLABS_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
import type { ToolConfig } from '@/tools/types'
import { safeUrlPathSegment } from '@/tools/url-path'

export const elevenLabsGetVoiceSettingsTool: ToolConfig<
ElevenLabsGetVoiceSettingsParams,
Expand Down Expand Up @@ -31,7 +32,8 @@ export const elevenLabsGetVoiceSettingsTool: ToolConfig<
},

request: {
url: (params) => `https://api.elevenlabs.io/v1/voices/${params.voiceId.trim()}/settings`,
url: (params) =>
`https://api.elevenlabs.io/v1/voices/${safeUrlPathSegment(params.voiceId, 'voiceId')}/settings`,
method: 'GET',
headers: (params) => ({
'xi-api-key': params.apiKey,
Expand Down
4 changes: 3 additions & 1 deletion apps/sim/tools/elevenlabs/get-voice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ElevenLabsGetVoiceParams, ElevenLabsGetVoiceResponse } from '@/tools/elevenlabs/types'
import { ELEVENLABS_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
import type { ToolConfig } from '@/tools/types'
import { safeUrlPathSegment } from '@/tools/url-path'

export const elevenLabsGetVoiceTool: ToolConfig<
ElevenLabsGetVoiceParams,
Expand Down Expand Up @@ -28,7 +29,8 @@ export const elevenLabsGetVoiceTool: ToolConfig<
},

request: {
url: (params) => `https://api.elevenlabs.io/v1/voices/${params.voiceId.trim()}`,
url: (params) =>
`https://api.elevenlabs.io/v1/voices/${safeUrlPathSegment(params.voiceId, 'voiceId')}`,
method: 'GET',
headers: (params) => ({
'xi-api-key': params.apiKey,
Expand Down
Loading
Loading