mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
feat(memory): pinecone generate embeddings working
This commit is contained in:
@@ -31,6 +31,7 @@ export const PineconeBlock: BlockConfig<PineconeResponse> = {
|
||||
type: 'short-input',
|
||||
layout: 'full',
|
||||
placeholder: 'gcp-starter',
|
||||
condition: { field: 'operation', value: 'upsert_text' },
|
||||
},
|
||||
{
|
||||
id: 'indexName',
|
||||
@@ -38,6 +39,7 @@ export const PineconeBlock: BlockConfig<PineconeResponse> = {
|
||||
type: 'short-input',
|
||||
layout: 'full',
|
||||
placeholder: 'my-index',
|
||||
condition: { field: 'operation', value: 'upsert_text' },
|
||||
},
|
||||
// Generate embeddings fields
|
||||
{
|
||||
@@ -46,8 +48,9 @@ export const PineconeBlock: BlockConfig<PineconeResponse> = {
|
||||
type: 'dropdown',
|
||||
layout: 'full',
|
||||
options: [
|
||||
{ label: 'text-embedding-3-small', id: 'text-embedding-3-small' },
|
||||
{ label: 'text-embedding-3-large', id: 'text-embedding-3-large' },
|
||||
{ label: 'multilingual-e5-large', id: 'multilingual-e5-large' },
|
||||
{ label: 'llama-text-embed-v2', id: 'llama-text-embed-v2' },
|
||||
{ label: 'pinecone-sparse-english-v0', id: 'pinecone-sparse-english-v0' },
|
||||
],
|
||||
condition: { field: 'operation', value: 'generate' },
|
||||
},
|
||||
@@ -152,12 +155,13 @@ export const PineconeBlock: BlockConfig<PineconeResponse> = {
|
||||
inputs: {
|
||||
operation: { type: 'string', required: true },
|
||||
apiKey: { type: 'string', required: true },
|
||||
environment: { type: 'string', required: true },
|
||||
indexName: { type: 'string', required: true },
|
||||
environment: { type: 'string', required: false },
|
||||
indexName: { type: 'string', required: false },
|
||||
namespace: { type: 'string', required: false },
|
||||
// Generate embeddings inputs
|
||||
model: { type: 'string', required: false },
|
||||
inputs: { type: 'json', required: false },
|
||||
parameters: { type: 'json', required: false },
|
||||
// Upsert text inputs
|
||||
records: { type: 'json', required: false },
|
||||
// Search text inputs
|
||||
@@ -175,7 +179,9 @@ export const PineconeBlock: BlockConfig<PineconeResponse> = {
|
||||
type: {
|
||||
matches: 'any',
|
||||
upsertedCount: 'any',
|
||||
embeddings: 'any',
|
||||
data: 'any',
|
||||
model: 'any',
|
||||
vector_type: 'any',
|
||||
usage: 'any',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -12,8 +12,6 @@ export const generateEmbeddingsTool: ToolConfig<
|
||||
|
||||
params: {
|
||||
apiKey: { type: 'string', required: true, description: 'Pinecone API key' },
|
||||
environment: { type: 'string', required: true, description: 'Pinecone environment' },
|
||||
indexName: { type: 'string', required: true, description: 'Name of the Pinecone index' },
|
||||
model: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
@@ -24,7 +22,6 @@ export const generateEmbeddingsTool: ToolConfig<
|
||||
required: true,
|
||||
description: 'Array of text inputs to generate embeddings for',
|
||||
},
|
||||
parameters: { type: 'object', required: false, description: 'Additional model parameters' },
|
||||
},
|
||||
|
||||
request: {
|
||||
@@ -38,7 +35,7 @@ export const generateEmbeddingsTool: ToolConfig<
|
||||
body: (params) => ({
|
||||
model: params.model,
|
||||
inputs: params.inputs,
|
||||
parameters: {
|
||||
parameters: params.parameters || {
|
||||
input_type: 'passage',
|
||||
truncate: 'END',
|
||||
},
|
||||
@@ -50,7 +47,9 @@ export const generateEmbeddingsTool: ToolConfig<
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
embeddings: data.embeddings,
|
||||
data: data.data,
|
||||
model: data.model,
|
||||
vector_type: data.vector_type,
|
||||
usage: data.usage,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -20,19 +20,27 @@ export interface PineconeResponse extends ToolResponse {
|
||||
matches?: PineconeMatchResponse[]
|
||||
upsertedCount?: number
|
||||
deletedCount?: number
|
||||
embeddings?: number[][]
|
||||
data?: Array<{
|
||||
values: number[]
|
||||
vector_type: 'dense' | 'sparse'
|
||||
}>
|
||||
model?: string
|
||||
vector_type?: 'dense' | 'sparse'
|
||||
usage?: {
|
||||
prompt_tokens: number
|
||||
total_tokens: number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate Embeddings
|
||||
export interface PineconeGenerateEmbeddingsParams extends PineconeBaseParams {
|
||||
export interface PineconeGenerateEmbeddingsParams {
|
||||
apiKey: string
|
||||
model: string
|
||||
inputs: { text: string }[]
|
||||
parameters?: Record<string, any>
|
||||
parameters?: {
|
||||
input_type?: 'passage'
|
||||
truncate?: 'END'
|
||||
}
|
||||
}
|
||||
|
||||
// Upsert Text
|
||||
|
||||
Reference in New Issue
Block a user