Skip to content

Commit b258e4a

Browse files
author
aadamgough
committed
pinecone fix
1 parent 012a7db commit b258e4a

File tree

4 files changed

+320
-20
lines changed

4 files changed

+320
-20
lines changed

apps/sim/blocks/blocks/pinecone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export const PineconeBlock: BlockConfig<PineconeResponse> = {
264264

265265
outputs: {
266266
matches: { type: 'json', description: 'Search matches' },
267-
upsertedCount: { type: 'number', description: 'Upserted count' },
267+
statusText: { type: 'string', description: 'Status of the upsert operation' },
268268
data: { type: 'json', description: 'Response data' },
269269
model: { type: 'string', description: 'Model information' },
270270
vector_type: { type: 'string', description: 'Vector type' },

apps/sim/tools/__test-utils__/mock-data.ts

Lines changed: 315 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,318 @@ export const mockHttpResponses = {
2626
status: 401,
2727
},
2828
}
29+
30+
// Gmail Mock Data
31+
export const mockGmailResponses = {
32+
// List messages response
33+
messageList: {
34+
messages: [
35+
{ id: 'msg1', threadId: 'thread1' },
36+
{ id: 'msg2', threadId: 'thread2' },
37+
{ id: 'msg3', threadId: 'thread3' },
38+
],
39+
nextPageToken: 'token123',
40+
},
41+
42+
// Empty list response
43+
emptyList: {
44+
messages: [],
45+
resultSizeEstimate: 0,
46+
},
47+
48+
// Single message response
49+
singleMessage: {
50+
id: 'msg1',
51+
threadId: 'thread1',
52+
labelIds: ['INBOX', 'UNREAD'],
53+
snippet: 'This is a snippet preview of the email...',
54+
payload: {
55+
headers: [
56+
{ name: 'From', value: '[email protected]' },
57+
{ name: 'To', value: '[email protected]' },
58+
{ name: 'Subject', value: 'Test Email Subject' },
59+
{ name: 'Date', value: 'Mon, 15 Mar 2025 10:30:00 -0800' },
60+
],
61+
mimeType: 'multipart/alternative',
62+
parts: [
63+
{
64+
mimeType: 'text/plain',
65+
body: {
66+
data: Buffer.from('This is the plain text content of the email').toString('base64'),
67+
},
68+
},
69+
{
70+
mimeType: 'text/html',
71+
body: {
72+
data: Buffer.from('<div>This is the HTML content of the email</div>').toString(
73+
'base64'
74+
),
75+
},
76+
},
77+
],
78+
},
79+
},
80+
}
81+
82+
// Google Drive Mock Data
83+
export const mockDriveResponses = {
84+
// List files response
85+
fileList: {
86+
files: [
87+
{ id: 'file1', name: 'Document1.docx', mimeType: 'application/vnd.google-apps.document' },
88+
{
89+
id: 'file2',
90+
name: 'Spreadsheet.xlsx',
91+
mimeType: 'application/vnd.google-apps.spreadsheet',
92+
},
93+
{
94+
id: 'file3',
95+
name: 'Presentation.pptx',
96+
mimeType: 'application/vnd.google-apps.presentation',
97+
},
98+
],
99+
nextPageToken: 'drive-page-token',
100+
},
101+
102+
// Empty file list
103+
emptyFileList: {
104+
files: [],
105+
},
106+
107+
// Single file metadata
108+
fileMetadata: {
109+
id: 'file1',
110+
name: 'Document1.docx',
111+
mimeType: 'application/vnd.google-apps.document',
112+
webViewLink: 'https://docs.google.com/document/d/123/edit',
113+
createdTime: '2025-03-15T12:00:00Z',
114+
modifiedTime: '2025-03-16T10:15:00Z',
115+
owners: [{ displayName: 'Test User', emailAddress: '[email protected]' }],
116+
size: '12345',
117+
},
118+
}
119+
120+
// Google Sheets Mock Data
121+
export const mockSheetsResponses = {
122+
// Read range response
123+
rangeData: {
124+
range: 'Sheet1!A1:D5',
125+
majorDimension: 'ROWS',
126+
values: [
127+
['Header1', 'Header2', 'Header3', 'Header4'],
128+
['Row1Col1', 'Row1Col2', 'Row1Col3', 'Row1Col4'],
129+
['Row2Col1', 'Row2Col2', 'Row2Col3', 'Row2Col4'],
130+
['Row3Col1', 'Row3Col2', 'Row3Col3', 'Row3Col4'],
131+
['Row4Col1', 'Row4Col2', 'Row4Col3', 'Row4Col4'],
132+
],
133+
},
134+
135+
// Empty range
136+
emptyRange: {
137+
range: 'Sheet1!A1:D5',
138+
majorDimension: 'ROWS',
139+
values: [],
140+
},
141+
142+
// Update range response
143+
updateResponse: {
144+
spreadsheetId: 'spreadsheet123',
145+
updatedRange: 'Sheet1!A1:D5',
146+
updatedRows: 5,
147+
updatedColumns: 4,
148+
updatedCells: 20,
149+
},
150+
}
151+
152+
// Pinecone Mock Data
153+
export const mockPineconeResponses = {
154+
// Vector embedding
155+
embedding: {
156+
embedding: Array(1536)
157+
.fill(0)
158+
.map(() => Math.random() * 2 - 1),
159+
metadata: { text: 'Sample text for embedding', id: 'embed-123' },
160+
},
161+
162+
// Search results
163+
searchResults: {
164+
matches: [
165+
{ id: 'doc1', score: 0.92, metadata: { text: 'Matching text 1' } },
166+
{ id: 'doc2', score: 0.85, metadata: { text: 'Matching text 2' } },
167+
{ id: 'doc3', score: 0.78, metadata: { text: 'Matching text 3' } },
168+
],
169+
},
170+
171+
// Upsert response
172+
upsertResponse: {
173+
statusText: 'Created',
174+
},
175+
}
176+
177+
// GitHub Mock Data
178+
export const mockGitHubResponses = {
179+
// Repository info
180+
repoInfo: {
181+
id: 12345,
182+
name: 'test-repo',
183+
full_name: 'user/test-repo',
184+
description: 'A test repository',
185+
html_url: 'https://github.com/user/test-repo',
186+
owner: {
187+
login: 'user',
188+
id: 54321,
189+
avatar_url: 'https://avatars.githubusercontent.com/u/54321',
190+
},
191+
private: false,
192+
fork: false,
193+
created_at: '2025-01-01T00:00:00Z',
194+
updated_at: '2025-03-15T10:00:00Z',
195+
pushed_at: '2025-03-15T09:00:00Z',
196+
default_branch: 'main',
197+
open_issues_count: 5,
198+
watchers_count: 10,
199+
forks_count: 3,
200+
stargazers_count: 15,
201+
language: 'TypeScript',
202+
},
203+
204+
// PR creation response
205+
prResponse: {
206+
id: 12345,
207+
number: 42,
208+
title: 'Test PR Title',
209+
body: 'Test PR description',
210+
html_url: 'https://github.com/user/test-repo/pull/42',
211+
state: 'open',
212+
user: {
213+
login: 'user',
214+
id: 54321,
215+
},
216+
created_at: '2025-03-15T10:00:00Z',
217+
updated_at: '2025-03-15T10:05:00Z',
218+
},
219+
}
220+
221+
// Serper Search Mock Data
222+
export const mockSerperResponses = {
223+
// Search results
224+
searchResults: {
225+
searchParameters: {
226+
q: 'test query',
227+
gl: 'us',
228+
hl: 'en',
229+
},
230+
organic: [
231+
{
232+
title: 'Test Result 1',
233+
link: 'https://example.com/1',
234+
snippet: 'This is a snippet for the first test result.',
235+
position: 1,
236+
},
237+
{
238+
title: 'Test Result 2',
239+
link: 'https://example.com/2',
240+
snippet: 'This is a snippet for the second test result.',
241+
position: 2,
242+
},
243+
{
244+
title: 'Test Result 3',
245+
link: 'https://example.com/3',
246+
snippet: 'This is a snippet for the third test result.',
247+
position: 3,
248+
},
249+
],
250+
knowledgeGraph: {
251+
title: 'Test Knowledge Graph',
252+
type: 'Test Type',
253+
description: 'This is a test knowledge graph result',
254+
},
255+
},
256+
}
257+
258+
// Slack Mock Data
259+
export const mockSlackResponses = {
260+
// Message post response
261+
messageResponse: {
262+
ok: true,
263+
channel: 'C1234567890',
264+
ts: '1627385301.000700',
265+
message: {
266+
text: 'This is a test message',
267+
user: 'U1234567890',
268+
ts: '1627385301.000700',
269+
team: 'T1234567890',
270+
},
271+
},
272+
273+
// Error response
274+
errorResponse: {
275+
ok: false,
276+
error: 'channel_not_found',
277+
},
278+
}
279+
280+
// Tavily Mock Data
281+
export const mockTavilyResponses = {
282+
// Search results
283+
searchResults: {
284+
results: [
285+
{
286+
title: 'Test Article 1',
287+
url: 'https://example.com/article1',
288+
content: 'This is the content of test article 1.',
289+
score: 0.95,
290+
},
291+
{
292+
title: 'Test Article 2',
293+
url: 'https://example.com/article2',
294+
content: 'This is the content of test article 2.',
295+
score: 0.87,
296+
},
297+
{
298+
title: 'Test Article 3',
299+
url: 'https://example.com/article3',
300+
content: 'This is the content of test article 3.',
301+
score: 0.72,
302+
},
303+
],
304+
query: 'test query',
305+
search_id: 'search-123',
306+
},
307+
}
308+
309+
// Supabase Mock Data
310+
export const mockSupabaseResponses = {
311+
// Query response
312+
queryResponse: {
313+
data: [
314+
{ id: 1, name: 'Item 1', description: 'Description 1' },
315+
{ id: 2, name: 'Item 2', description: 'Description 2' },
316+
{ id: 3, name: 'Item 3', description: 'Description 3' },
317+
],
318+
error: null,
319+
},
320+
321+
// Insert response
322+
insertResponse: {
323+
data: [{ id: 4, name: 'Item 4', description: 'Description 4' }],
324+
error: null,
325+
},
326+
327+
// Update response
328+
updateResponse: {
329+
data: [{ id: 1, name: 'Updated Item 1', description: 'Updated Description 1' }],
330+
error: null,
331+
},
332+
333+
// Error response
334+
errorResponse: {
335+
data: null,
336+
error: {
337+
message: 'Database error',
338+
details: 'Error details',
339+
hint: 'Error hint',
340+
code: 'DB_ERROR',
341+
},
342+
},
343+
}

apps/sim/tools/pinecone/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface PineconeMatchResponse {
1818
export interface PineconeResponse extends ToolResponse {
1919
output: {
2020
matches?: PineconeMatchResponse[]
21-
upsertedCount?: number
21+
statusText?: string
2222
data?: Array<{
2323
values: number[]
2424
vector_type: 'dense' | 'sparse'

apps/sim/tools/pinecone/upsert_text.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,11 @@ export const upsertTextTool: ToolConfig<PineconeUpsertTextParams, PineconeRespon
7171
},
7272

7373
transformResponse: async (response) => {
74-
// Handle empty response (201 Created)
75-
if (response.status === 201) {
76-
return {
77-
success: true,
78-
output: {
79-
statusText: 'Created',
80-
},
81-
}
82-
}
83-
84-
// Handle response with content
85-
const data = await response.json()
74+
// Pinecone upsert returns 201 Created with empty body on success
8675
return {
87-
success: true,
76+
success: response.status === 201,
8877
output: {
89-
upsertedCount: data.upsertedCount || 0,
78+
statusText: response.status === 201 ? 'Created' : response.statusText,
9079
},
9180
}
9281
},
@@ -96,9 +85,5 @@ export const upsertTextTool: ToolConfig<PineconeUpsertTextParams, PineconeRespon
9685
type: 'string',
9786
description: 'Status of the upsert operation',
9887
},
99-
upsertedCount: {
100-
type: 'number',
101-
description: 'Number of records successfully upserted',
102-
},
10388
},
10489
}

0 commit comments

Comments
 (0)