Skip to content

Commit 1773d7c

Browse files
author
Sim Pi Agent
committed
Pi Babysit: address PR #6066 feedback
1 parent 72cfd5f commit 1773d7c

4 files changed

Lines changed: 38 additions & 6 deletions

File tree

apps/sim/blocks/blocks/pinecone.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ export const PineconeBlock: BlockConfig<PineconeResponse> = {
541541
vector: { type: 'json', description: 'Query vector' },
542542
includeValues: { type: 'boolean', description: 'Include vector values' },
543543
includeMetadata: { type: 'boolean', description: 'Include metadata' },
544+
options: { type: 'json', description: 'Selected vector search options' },
544545
id: { type: 'string', description: 'Vector identifier to update' },
545546
values: { type: 'json', description: 'New dense vector values' },
546547
sparseValues: { type: 'json', description: 'New sparse vector values' },

apps/sim/tools/pinecone/search_vector.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ describe('searchVectorTool', () => {
1313
it.each([
1414
{
1515
name: 'neither option',
16-
options: {},
16+
options: [],
1717
expected: { includeValues: false, includeMetadata: false },
1818
},
1919
{
2020
name: 'include values only',
21-
options: { includeValues: true },
21+
options: ['includeValues'],
2222
expected: { includeValues: true, includeMetadata: false },
2323
},
2424
{
2525
name: 'include metadata only',
26-
options: { includeMetadata: true },
26+
options: ['includeMetadata'],
2727
expected: { includeValues: false, includeMetadata: true },
2828
},
2929
{
3030
name: 'both options',
31-
options: { includeValues: true, includeMetadata: true },
31+
options: ['includeValues', 'includeMetadata'],
3232
expected: { includeValues: true, includeMetadata: true },
3333
},
3434
])('maps $name to the Pinecone query flags', ({ options, expected }) => {

apps/sim/tools/pinecone/search_vector.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
import type { PineconeResponse, PineconeSearchVectorParams } from '@/tools/pinecone/types'
22
import type { ToolConfig } from '@/tools/types'
33

4+
function parseBoolean(value: unknown): boolean {
5+
if (typeof value === 'boolean') return value
6+
if (typeof value === 'number') return value !== 0
7+
return typeof value === 'string' && ['true', '1'].includes(value.trim().toLowerCase())
8+
}
9+
10+
function selectedOptions(value: string[] | string | undefined): Set<string> {
11+
if (Array.isArray(value)) return new Set(value)
12+
if (typeof value !== 'string' || value.trim().length === 0) return new Set()
13+
14+
try {
15+
const parsed: unknown = JSON.parse(value)
16+
return Array.isArray(parsed)
17+
? new Set(parsed.filter((item): item is string => typeof item === 'string'))
18+
: new Set()
19+
} catch {
20+
return new Set()
21+
}
22+
}
23+
424
export const searchVectorTool: ToolConfig<PineconeSearchVectorParams, PineconeResponse> = {
525
id: 'pinecone_search_vector',
626
name: 'Pinecone Search Vector',
@@ -51,6 +71,12 @@ export const searchVectorTool: ToolConfig<PineconeSearchVectorParams, PineconeRe
5171
visibility: 'user-or-llm',
5272
description: 'Include metadata in response (true/false)',
5373
},
74+
options: {
75+
type: 'array',
76+
required: false,
77+
visibility: 'user-only',
78+
description: 'Selected search result options',
79+
},
5480
apiKey: {
5581
type: 'string',
5682
required: true,
@@ -76,8 +102,12 @@ export const searchVectorTool: ToolConfig<PineconeSearchVectorParams, PineconeRe
76102
? JSON.parse(params.filter)
77103
: params.filter
78104
: undefined,
79-
includeValues: Boolean(params.includeValues),
80-
includeMetadata: Boolean(params.includeMetadata)
105+
includeValues: params.options
106+
? selectedOptions(params.options).has('includeValues')
107+
: parseBoolean(params.includeValues),
108+
includeMetadata: params.options
109+
? selectedOptions(params.options).has('includeMetadata')
110+
: parseBoolean(params.includeMetadata),
81111
}),
82112
},
83113

apps/sim/tools/pinecone/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export interface PineconeSearchVectorParams extends PineconeBaseParams {
179179
filter?: Record<string, any> | string
180180
includeValues?: boolean
181181
includeMetadata?: boolean
182+
options?: string[] | string
182183
}
183184

184185
export interface PineconeDeleteVectorsParams {

0 commit comments

Comments
 (0)