Skip to content

Commit 80e0099

Browse files
committed
fix: resolve PR review comments
- Rename imageFiles/videoFile subblock IDs to avoid canonicalParamId collision - Add response.ok guard in embeddings and rerank transformResponse - Remove unused truncation param from types - Fix test pattern: use beforeEach/clearAllMocks instead of afterEach/resetAllMocks - Add Array.isArray guard for JSON.parse of imageUrls
1 parent 7a6ee14 commit 80e0099

File tree

7 files changed

+15
-18
lines changed

7 files changed

+15
-18
lines changed

apps/sim/app/api/tools/voyageai/multimodal-embeddings/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export async function POST(request: NextRequest) {
7777
if (params.imageUrls?.trim()) {
7878
let urls: string[]
7979
try {
80-
urls = JSON.parse(params.imageUrls)
80+
const parsed = JSON.parse(params.imageUrls)
81+
urls = Array.isArray(parsed) ? parsed : [parsed]
8182
} catch {
8283
urls = params.imageUrls
8384
.split(/[,\n]/)

apps/sim/blocks/blocks/voyageai.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ describe('VoyageAIBlock', () => {
173173
)
174174
const ids = mmBlocks.map((sb) => sb.id)
175175
expect(ids).toContain('multimodalInput')
176-
expect(ids).toContain('imageFiles')
176+
expect(ids).toContain('imageFilesUpload')
177177
expect(ids).toContain('imageFilesRef')
178-
expect(ids).toContain('videoFile')
178+
expect(ids).toContain('videoFileUpload')
179179
expect(ids).toContain('videoFileRef')
180180
expect(ids).toContain('multimodalModel')
181181
})

apps/sim/blocks/blocks/voyageai.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const VoyageAIBlock: BlockConfig = {
7373
condition: { field: 'operation', value: 'multimodal_embeddings' },
7474
},
7575
{
76-
id: 'imageFiles',
76+
id: 'imageFilesUpload',
7777
title: 'Image Files',
7878
type: 'file-upload',
7979
canonicalParamId: 'imageFiles',
@@ -101,7 +101,7 @@ export const VoyageAIBlock: BlockConfig = {
101101
mode: 'advanced',
102102
},
103103
{
104-
id: 'videoFile',
104+
id: 'videoFileUpload',
105105
title: 'Video File',
106106
type: 'file-upload',
107107
canonicalParamId: 'videoFile',

apps/sim/tools/voyageai/embeddings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ export const embeddingsTool: ToolConfig<VoyageAIEmbeddingsParams, VoyageAIEmbedd
5757

5858
transformResponse: async (response) => {
5959
const data = await response.json()
60+
if (!response.ok) {
61+
throw new Error(data.detail ?? data.message ?? `VoyageAI API error: ${response.status}`)
62+
}
6063
return {
6164
success: true,
6265
output: {

apps/sim/tools/voyageai/rerank.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ export const rerankTool: ToolConfig<VoyageAIRerankParams, VoyageAIRerankResponse
6666

6767
transformResponse: async (response, params) => {
6868
const data = await response.json()
69+
if (!response.ok) {
70+
throw new Error(data.detail ?? data.message ?? `VoyageAI API error: ${response.status}`)
71+
}
6972
const originalDocuments: string[] = params
7073
? typeof params.documents === 'string'
7174
? JSON.parse(params.documents)

apps/sim/tools/voyageai/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export interface VoyageAIEmbeddingsParams {
55
input: string | string[]
66
model?: string
77
inputType?: 'query' | 'document'
8-
truncation?: boolean
98
}
109

1110
export interface VoyageAIRerankParams {
@@ -14,7 +13,6 @@ export interface VoyageAIRerankParams {
1413
documents: string | string[]
1514
model?: string
1615
topK?: number
17-
truncation?: boolean
1816
}
1917

2018
export interface VoyageAIEmbeddingsResponse extends ToolResponse {

apps/sim/tools/voyageai/voyageai.test.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @vitest-environment node
33
*/
44
import { ToolTester } from '@sim/testing/builders'
5-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
5+
import { beforeEach, describe, expect, it, vi } from 'vitest'
66
import { embeddingsTool } from '@/tools/voyageai/embeddings'
77
import { multimodalEmbeddingsTool } from '@/tools/voyageai/multimodal-embeddings'
88
import { rerankTool } from '@/tools/voyageai/rerank'
@@ -12,11 +12,7 @@ describe('Voyage AI Embeddings Tool', () => {
1212

1313
beforeEach(() => {
1414
tester = new ToolTester(embeddingsTool as any)
15-
})
16-
17-
afterEach(() => {
18-
tester.cleanup()
19-
vi.resetAllMocks()
15+
vi.clearAllMocks()
2016
})
2117

2218
describe('Tool metadata', () => {
@@ -276,11 +272,7 @@ describe('Voyage AI Rerank Tool', () => {
276272

277273
beforeEach(() => {
278274
tester = new ToolTester(rerankTool as any)
279-
})
280-
281-
afterEach(() => {
282-
tester.cleanup()
283-
vi.resetAllMocks()
275+
vi.clearAllMocks()
284276
})
285277

286278
describe('Tool metadata', () => {

0 commit comments

Comments
 (0)