Skip to content

Commit 6358236

Browse files
authored
fix(tools): fix perplexity & parallel ai tag dropdown inaccuracies (#2300)
* fix(tools): fix perplexity & parallel ai tag dropdown inaccuracies * fixed stt, tts and added output conditions to conditionally display tag dropdown values based on other subblock values * updated exa to match latest API
1 parent 14846ab commit 6358236

File tree

15 files changed

+291
-130
lines changed

15 files changed

+291
-130
lines changed

apps/docs/content/docs/en/tools/exa.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ Search the web using Exa AI. Returns relevant search results with titles, URLs,
4949
| `type` | string | No | Search type: neural, keyword, auto or fast \(default: auto\) |
5050
| `includeDomains` | string | No | Comma-separated list of domains to include in results |
5151
| `excludeDomains` | string | No | Comma-separated list of domains to exclude from results |
52-
| `category` | string | No | Filter by category: company, research_paper, news_article, pdf, github, tweet, movie, song, personal_site |
52+
| `category` | string | No | Filter by category: company, research paper, news, pdf, github, tweet, personal site, linkedin profile, financial report |
5353
| `text` | boolean | No | Include full text content in results \(default: false\) |
5454
| `highlights` | boolean | No | Include highlighted snippets in results \(default: false\) |
5555
| `summary` | boolean | No | Include AI-generated summaries in results \(default: false\) |
56-
| `livecrawl` | string | No | Live crawling mode: always, fallback, or never \(default: never\) |
56+
| `livecrawl` | string | No | Live crawling mode: never \(default\), fallback, always, or preferred \(always try livecrawl, fall back to cache if fails\) |
5757
| `apiKey` | string | Yes | Exa AI API Key |
5858

5959
#### Output
@@ -76,7 +76,7 @@ Retrieve the contents of webpages using Exa AI. Returns the title, text content,
7676
| `subpages` | number | No | Number of subpages to crawl from the provided URLs |
7777
| `subpageTarget` | string | No | Comma-separated keywords to target specific subpages \(e.g., "docs,tutorial,about"\) |
7878
| `highlights` | boolean | No | Include highlighted snippets in results \(default: false\) |
79-
| `livecrawl` | string | No | Live crawling mode: always, fallback, or never \(default: never\) |
79+
| `livecrawl` | string | No | Live crawling mode: never \(default\), fallback, always, or preferred \(always try livecrawl, fall back to cache if fails\) |
8080
| `apiKey` | string | Yes | Exa AI API Key |
8181

8282
#### Output
@@ -99,10 +99,9 @@ Find webpages similar to a given URL using Exa AI. Returns a list of similar lin
9999
| `includeDomains` | string | No | Comma-separated list of domains to include in results |
100100
| `excludeDomains` | string | No | Comma-separated list of domains to exclude from results |
101101
| `excludeSourceDomain` | boolean | No | Exclude the source domain from results \(default: false\) |
102-
| `category` | string | No | Filter by category: company, research_paper, news_article, pdf, github, tweet, movie, song, personal_site |
103102
| `highlights` | boolean | No | Include highlighted snippets in results \(default: false\) |
104103
| `summary` | boolean | No | Include AI-generated summaries in results \(default: false\) |
105-
| `livecrawl` | string | No | Live crawling mode: always, fallback, or never \(default: never\) |
104+
| `livecrawl` | string | No | Live crawling mode: never \(default\), fallback, always, or preferred \(always try livecrawl, fall back to cache if fails\) |
106105
| `apiKey` | string | Yes | Exa AI API Key |
107106

108107
#### Output

apps/docs/content/docs/en/tools/parallel_ai.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ Conduct comprehensive deep research across the web using Parallel AI. Synthesize
9494

9595
| Parameter | Type | Description |
9696
| --------- | ---- | ----------- |
97-
| `status` | string | Task status \(running, completed, failed\) |
97+
| `status` | string | Task status \(completed, failed\) |
9898
| `run_id` | string | Unique ID for this research task |
99-
| `message` | string | Status message \(for running tasks\) |
99+
| `message` | string | Status message |
100100
| `content` | object | Research results \(structured based on output_schema\) |
101-
| `basis` | array | Citations and sources with excerpts and confidence levels |
101+
| `basis` | array | Citations and sources with reasoning and confidence levels |
102102

103103

104104

apps/docs/content/docs/en/tools/perplexity.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ Generate completions using Perplexity AI chat models
5454

5555
| Parameter | Type | Description |
5656
| --------- | ---- | ----------- |
57-
| `success` | boolean | Operation success status |
58-
| `output` | object | Chat completion results |
57+
| `content` | string | Generated text content |
58+
| `model` | string | Model used for generation |
59+
| `usage` | object | Token usage information |
5960

6061
### `perplexity_search`
6162

@@ -79,8 +80,7 @@ Get ranked search results from Perplexity
7980

8081
| Parameter | Type | Description |
8182
| --------- | ---- | ----------- |
82-
| `success` | boolean | Operation success status |
83-
| `output` | object | Search results |
83+
| `results` | array | Array of search results |
8484

8585

8686

apps/sim/app/api/proxy/stt/route.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,16 @@ export async function POST(request: NextRequest) {
227227

228228
logger.info(`[${requestId}] Transcription completed successfully`)
229229

230-
return NextResponse.json({
231-
transcript,
232-
segments,
233-
language: detectedLanguage,
234-
duration,
235-
confidence,
236-
sentiment: sentimentResults,
237-
entities,
238-
summary,
239-
})
230+
const response: Record<string, any> = { transcript }
231+
if (segments !== undefined) response.segments = segments
232+
if (detectedLanguage !== undefined) response.language = detectedLanguage
233+
if (duration !== undefined) response.duration = duration
234+
if (confidence !== undefined) response.confidence = confidence
235+
if (sentimentResults !== undefined) response.sentiment = sentimentResults
236+
if (entities !== undefined) response.entities = entities
237+
if (summary !== undefined) response.summary = summary
238+
239+
return NextResponse.json(response)
240240
} catch (error) {
241241
logger.error(`[${requestId}] STT proxy error:`, error)
242242
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
@@ -277,11 +277,11 @@ async function transcribeWithWhisper(
277277
formData.append('temperature', temperature.toString())
278278
}
279279

280+
formData.append('response_format', 'verbose_json')
281+
280282
if (timestamps === 'word') {
281-
formData.append('response_format', 'verbose_json')
282283
formData.append('timestamp_granularities', 'word')
283284
} else if (timestamps === 'sentence') {
284-
formData.append('response_format', 'verbose_json')
285285
formData.append('timestamp_granularities', 'segment')
286286
}
287287

@@ -302,17 +302,14 @@ async function transcribeWithWhisper(
302302

303303
const data = await response.json()
304304

305-
if (timestamps === 'none') {
306-
return {
307-
transcript: data.text,
308-
language: data.language,
309-
}
305+
let segments: TranscriptSegment[] | undefined
306+
if (timestamps !== 'none') {
307+
segments = (data.segments || data.words || []).map((seg: any) => ({
308+
text: seg.text,
309+
start: seg.start,
310+
end: seg.end,
311+
}))
310312
}
311-
const segments: TranscriptSegment[] = (data.segments || data.words || []).map((seg: any) => ({
312-
text: seg.text,
313-
start: seg.start,
314-
end: seg.end,
315-
}))
316313

317314
return {
318315
transcript: data.text,

apps/sim/blocks/blocks/parallel.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ export const ParallelBlock: BlockConfig<ToolResponse> = {
110110
title: 'Processor',
111111
type: 'dropdown',
112112
options: [
113-
{ label: 'Lite ($5/1K)', id: 'lite' },
114-
{ label: 'Base ($10/1K)', id: 'base' },
115-
{ label: 'Core ($25/1K)', id: 'core' },
116-
{ label: 'Core 2x ($50/1K)', id: 'core2x' },
117-
{ label: 'Pro ($100/1K)', id: 'pro' },
118-
{ label: 'Ultra ($300/1K)', id: 'ultra' },
119-
{ label: 'Ultra 2x ($600/1K)', id: 'ultra2x' },
120-
{ label: 'Ultra 4x ($1,200/1K)', id: 'ultra4x' },
113+
{ label: 'Lite', id: 'lite' },
114+
{ label: 'Base', id: 'base' },
115+
{ label: 'Core', id: 'core' },
116+
{ label: 'Core 2x', id: 'core2x' },
117+
{ label: 'Pro', id: 'pro' },
118+
{ label: 'Ultra', id: 'ultra' },
119+
{ label: 'Ultra 2x', id: 'ultra2x' },
120+
{ label: 'Ultra 4x', id: 'ultra4x' },
121121
],
122122
value: () => 'base',
123123
condition: { field: 'operation', value: ['search', 'deep_research'] },

apps/sim/blocks/blocks/stt.ts

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,44 @@ export const SttBlock: BlockConfig<SttBlockResponse> = {
304304

305305
outputs: {
306306
transcript: { type: 'string', description: 'Full transcribed text' },
307-
segments: { type: 'array', description: 'Timestamped segments with speaker labels' },
307+
segments: {
308+
type: 'array',
309+
description: 'Timestamped segments with speaker labels',
310+
condition: { field: 'timestamps', value: 'none', not: true },
311+
},
308312
language: { type: 'string', description: 'Detected or specified language' },
309313
duration: { type: 'number', description: 'Audio duration in seconds' },
310314
confidence: {
311315
type: 'number',
312-
description: 'Overall confidence score (Deepgram, AssemblyAI only)',
316+
description: 'Overall confidence score',
317+
condition: { field: 'provider', value: ['deepgram', 'assemblyai', 'gemini'] },
318+
},
319+
sentiment: {
320+
type: 'array',
321+
description: 'Sentiment analysis results',
322+
condition: {
323+
field: 'provider',
324+
value: 'assemblyai',
325+
and: { field: 'sentiment', value: true },
326+
},
327+
},
328+
entities: {
329+
type: 'array',
330+
description: 'Detected entities',
331+
condition: {
332+
field: 'provider',
333+
value: 'assemblyai',
334+
and: { field: 'entityDetection', value: true },
335+
},
336+
},
337+
summary: {
338+
type: 'string',
339+
description: 'Auto-generated summary',
340+
condition: {
341+
field: 'provider',
342+
value: 'assemblyai',
343+
and: { field: 'summarization', value: true },
344+
},
313345
},
314-
sentiment: { type: 'array', description: 'Sentiment analysis results (AssemblyAI only)' },
315-
entities: { type: 'array', description: 'Detected entities (AssemblyAI only)' },
316-
summary: { type: 'string', description: 'Auto-generated summary (AssemblyAI only)' },
317346
},
318347
}

apps/sim/blocks/blocks/tts.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,11 @@ export const TtsBlock: BlockConfig<TtsBlockResponse> = {
579579
outputs: {
580580
audioUrl: { type: 'string', description: 'URL to the generated audio file' },
581581
audioFile: { type: 'json', description: 'Generated audio file object (UserFile)' },
582-
duration: { type: 'number', description: 'Audio duration in seconds' },
582+
duration: {
583+
type: 'number',
584+
description: 'Audio duration in seconds',
585+
condition: { field: 'provider', value: 'deepgram' },
586+
},
583587
characterCount: { type: 'number', description: 'Number of characters processed' },
584588
format: { type: 'string', description: 'Audio format' },
585589
provider: { type: 'string', description: 'TTS provider used' },

apps/sim/blocks/types.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,33 @@ export type BlockOutput =
116116
| PrimitiveValueType
117117
| { [key: string]: PrimitiveValueType | Record<string, any> }
118118

119+
/**
120+
* Condition for showing an output field.
121+
* Uses the same pattern as SubBlockConfig.condition
122+
*/
123+
export interface OutputCondition {
124+
field: string
125+
value: string | number | boolean | Array<string | number | boolean>
126+
not?: boolean
127+
and?: {
128+
field: string
129+
value: string | number | boolean | Array<string | number | boolean> | undefined
130+
not?: boolean
131+
}
132+
}
133+
119134
export type OutputFieldDefinition =
120135
| PrimitiveValueType
121-
| { type: PrimitiveValueType; description?: string }
136+
| {
137+
type: PrimitiveValueType
138+
description?: string
139+
/**
140+
* Optional condition for when this output should be shown.
141+
* If not specified, the output is always shown.
142+
* Uses the same condition format as subBlocks.
143+
*/
144+
condition?: OutputCondition
145+
}
122146

123147
export interface ParamConfig {
124148
type: ParamType

apps/sim/lib/workflows/blocks/block-outputs.ts

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,80 @@ import {
1111
USER_FILE_PROPERTY_TYPES,
1212
} from '@/lib/workflows/types'
1313
import { getBlock } from '@/blocks'
14-
import type { BlockConfig } from '@/blocks/types'
14+
import type { BlockConfig, OutputCondition } from '@/blocks/types'
1515
import { getTrigger, isTriggerValid } from '@/triggers'
1616

1717
type OutputDefinition = Record<string, any>
1818

19+
/**
20+
* Evaluates an output condition against subBlock values.
21+
* Returns true if the condition is met and the output should be shown.
22+
*/
23+
function evaluateOutputCondition(
24+
condition: OutputCondition,
25+
subBlocks: Record<string, any> | undefined
26+
): boolean {
27+
if (!subBlocks) return false
28+
29+
const fieldValue = subBlocks[condition.field]?.value
30+
31+
let matches: boolean
32+
if (Array.isArray(condition.value)) {
33+
matches = condition.value.includes(fieldValue)
34+
} else {
35+
matches = fieldValue === condition.value
36+
}
37+
38+
if (condition.not) {
39+
matches = !matches
40+
}
41+
42+
if (condition.and) {
43+
const andFieldValue = subBlocks[condition.and.field]?.value
44+
let andMatches: boolean
45+
46+
if (Array.isArray(condition.and.value)) {
47+
andMatches = condition.and.value.includes(andFieldValue)
48+
} else {
49+
andMatches = andFieldValue === condition.and.value
50+
}
51+
52+
if (condition.and.not) {
53+
andMatches = !andMatches
54+
}
55+
56+
matches = matches && andMatches
57+
}
58+
59+
return matches
60+
}
61+
62+
/**
63+
* Filters outputs based on their conditions.
64+
* Returns a new OutputDefinition with only the outputs whose conditions are met.
65+
*/
66+
function filterOutputsByCondition(
67+
outputs: OutputDefinition,
68+
subBlocks: Record<string, any> | undefined
69+
): OutputDefinition {
70+
const filtered: OutputDefinition = {}
71+
72+
for (const [key, value] of Object.entries(outputs)) {
73+
if (!value || typeof value !== 'object' || !('condition' in value)) {
74+
filtered[key] = value
75+
continue
76+
}
77+
78+
const condition = value.condition as OutputCondition | undefined
79+
if (!condition || evaluateOutputCondition(condition, subBlocks)) {
80+
const { condition: _, ...rest } = value
81+
filtered[key] = rest
82+
}
83+
}
84+
85+
return filtered
86+
}
87+
1988
const CHAT_OUTPUTS: OutputDefinition = {
2089
input: { type: 'string', description: 'User message' },
2190
conversationId: { type: 'string', description: 'Conversation ID' },
@@ -184,7 +253,8 @@ export function getBlockOutputs(
184253
}
185254

186255
const baseOutputs = { ...(blockConfig.outputs || {}) }
187-
return applyInputFormatToOutputs(blockType, blockConfig, subBlocks, baseOutputs)
256+
const filteredOutputs = filterOutputsByCondition(baseOutputs, subBlocks)
257+
return applyInputFormatToOutputs(blockType, blockConfig, subBlocks, filteredOutputs)
188258
}
189259

190260
function shouldFilterReservedField(

apps/sim/tools/exa/find_similar_links.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ export const findSimilarLinksTool: ToolConfig<
4848
visibility: 'user-only',
4949
description: 'Exclude the source domain from results (default: false)',
5050
},
51-
category: {
52-
type: 'string',
53-
required: false,
54-
visibility: 'user-only',
55-
description:
56-
'Filter by category: company, research_paper, news_article, pdf, github, tweet, movie, song, personal_site',
57-
},
5851
highlights: {
5952
type: 'boolean',
6053
required: false,
@@ -71,7 +64,8 @@ export const findSimilarLinksTool: ToolConfig<
7164
type: 'string',
7265
required: false,
7366
visibility: 'user-only',
74-
description: 'Live crawling mode: always, fallback, or never (default: never)',
67+
description:
68+
'Live crawling mode: never (default), fallback, always, or preferred (always try livecrawl, fall back to cache if fails)',
7569
},
7670
apiKey: {
7771
type: 'string',
@@ -113,9 +107,6 @@ export const findSimilarLinksTool: ToolConfig<
113107
body.excludeSourceDomain = params.excludeSourceDomain
114108
}
115109

116-
// Category filtering
117-
if (params.category) body.category = params.category
118-
119110
// Content options - build contents object
120111
const contents: Record<string, any> = {}
121112
if (params.text !== undefined) contents.text = params.text

0 commit comments

Comments
 (0)