diff --git a/components/indexer/pinecone/README.md b/components/indexer/pinecone/README.md new file mode 100644 index 000000000..045c0f96b --- /dev/null +++ b/components/indexer/pinecone/README.md @@ -0,0 +1,122 @@ +# Pinecone Indexer + +English | [简体中文](README_zh.md) + +A Pinecone indexer implementation for [Eino](https://github.com/cloudwego/eino) that implements the `Indexer` interface. This enables seamless integration with Eino's vector storage and retrieval system for enhanced semantic search capabilities. + +## Quick Start + +### Installation + +It requires the go-pinecone client of version v3.x: + +```bash +go get github.com/pinecone-io/go-pinecone/v3@latest +go get github.com/cloudwego/eino-ext/components/indexer/pinecone@latest +``` + +### Create the Pinecone Indexer + +```go +package main + +import ( + "context" + "log" + "os" + + pc "github.com/pinecone-io/go-pinecone/v3/pinecone" + "github.com/cloudwego/eino-ext/components/indexer/pinecone" + "github.com/cloudwego/eino/components/embedding" + "github.com/cloudwego/eino/schema" +) + +func main() { + // Load configuration from environment variables + apiKey := os.Getenv("PINECONE_APIKEY") + if apiKey == "" { + log.Fatal("PINECONE_APIKEY environment variable is required") + } + + // Initialize Pinecone client + client, err := pc.NewClient(pc.NewClientParams{ + ApiKey: apiKey, + }) + if err != nil { + log.Fatalf("Failed to create Pinecone client: %v", err) + } + + // Create Pinecone indexer config + config := pinecone.IndexerConfig{ + Client: client, + Dimension: 2560, // Set according to your embedding model + Embedding: &mockEmbedding{}, + } + + // Create an indexer + ctx := context.Background() + indexer, err := pinecone.NewIndexer(ctx, &config) + if err != nil { + log.Fatalf("Failed to create Pinecone indexer: %v", err) + } + log.Println("Indexer created successfully") + + // Store documents + docs := []*schema.Document{ + { + ID: "pinecone-1", + Content: "pinecone is a vector database", + MetaData: map[string]any{ + "tag1": "pinecone", + "tag2": "vector", + "tag3": "database", + }, + }, + { + ID: "pinecone-2", + Content: "Pinecone is a vector database for building accurate and performant AI applications.", + }, + } + + ids, err := indexer.Store(ctx, docs) + if err != nil { + log.Fatalf("Failed to store documents: %v", err) + return + } + log.Printf("Stored document ids: %v", ids) +} + +// mockEmbedding is a placeholder for your embedding implementation +// Replace with your actual embedding model + +// type mockEmbedding struct{} +// func (m *mockEmbedding) EmbedStrings(ctx context.Context, texts []string, opts ...embedding.Option) ([][]float64, error) { +// // Implement your embedding logic here +// } +``` + +## Configuration + +The following configuration options are available in `IndexerConfig`: + +| Field | Type | Description | Default | +|---------------------|-------------------------|------------------------------------------------------------------|-----------------| +| Client | *pinecone.Client | Pinecone client instance (required) | - | +| IndexName | string | Name of the Pinecone index | "eino-index" | +| Cloud | pinecone.Cloud | Cloud provider (e.g., "aws") | "aws" | +| Region | string | Cloud region (e.g., "us-east-1") | "us-east-1" | +| Metric | pinecone.IndexMetric | Distance metric: "cosine", "euclidean", "dotproduct" | "cosine" | +| Dimension | int32 | Vector dimension | 2560 | +| VectorType | string | Type of vectors (e.g., "float32") | "float32" | +| Namespace | string | Namespace within the index | (default) | +| Field | string | Field to store content text | (default) | +| Tags | *pinecone.IndexTags | Metadata tags | (optional) | +| DeletionProtection | pinecone.DeletionProtection | Deletion protection | (optional) | +| DocumentConverter | func | Custom document converter | (optional) | +| BatchSize | int | Batch size for upserts | 100 | +| MaxConcurrency | int | Max concurrency for upserts | 10 | +| Embedding | embedding.Embedder | Embedding model instance | (required) | + +## License + +Apache 2.0. See [LICENSE](../../LICENSE) for details. diff --git a/components/indexer/pinecone/README_zh.md b/components/indexer/pinecone/README_zh.md new file mode 100644 index 000000000..ee96fb0f5 --- /dev/null +++ b/components/indexer/pinecone/README_zh.md @@ -0,0 +1,122 @@ +# Pinecone 存储 + +[English](README.md) | [简体中文](README_zh.md) + +基于 Pinecone 的向量存储实现,为 [Eino](https://github.com/cloudwego/eino) 提供了符合 `Indexer` 接口的存储方案。该组件可无缝集成到 Eino 的向量存储和检索系统中,增强语义搜索能力。 + +## 快速开始 + +### 安装 + +需要 go-pinecone v3.x 客户端: + +```bash +go get github.com/pinecone-io/go-pinecone/v3@latest +go get github.com/cloudwego/eino-ext/components/indexer/pinecone@latest +``` + +### 创建 Pinecone 存储 + +```go +package main + +import ( + "context" + "log" + "os" + + pc "github.com/pinecone-io/go-pinecone/v3/pinecone" + "github.com/cloudwego/eino-ext/components/indexer/pinecone" + "github.com/cloudwego/eino/components/embedding" + "github.com/cloudwego/eino/schema" +) + +func main() { + // 从环境变量加载配置 + apiKey := os.Getenv("PINECONE_APIKEY") + if apiKey == "" { + log.Fatal("PINECONE_APIKEY 环境变量必填") + } + + // 初始化 Pinecone 客户端 + client, err := pc.NewClient(pc.NewClientParams{ + ApiKey: apiKey, + }) + if err != nil { + log.Fatalf("创建 Pinecone 客户端失败: %v", err) + } + + // 创建 Pinecone 存储配置 + config := pinecone.IndexerConfig{ + Client: client, + Dimension: 2560, // 按照你的 embedding 维度设置 + Embedding: &mockEmbedding{}, + } + + // 创建 Indexer + ctx := context.Background() + indexer, err := pinecone.NewIndexer(ctx, &config) + if err != nil { + log.Fatalf("创建 Pinecone Indexer 失败: %v", err) + } + log.Println("Indexer 创建成功") + + // 存储文档 + docs := []*schema.Document{ + { + ID: "pinecone-1", + Content: "pinecone 是一个向量数据库", + MetaData: map[string]any{ + "tag1": "pinecone", + "tag2": "vector", + "tag3": "database", + }, + }, + { + ID: "pinecone-2", + Content: "Pinecone 是为 AI 应用构建的高性能向量数据库。", + }, + } + + ids, err := indexer.Store(ctx, docs) + if err != nil { + log.Fatalf("存储文档失败: %v", err) + return + } + log.Printf("已存储文档 ids: %v", ids) +} + +// mockEmbedding 是 embedding 实现的占位符 +// 请替换为你自己的 embedding 模型 + +// type mockEmbedding struct{} +// func (m *mockEmbedding) EmbedStrings(ctx context.Context, texts []string, opts ...embedding.Option) ([][]float64, error) { +// // 实现 embedding 逻辑 +// } +``` + +## 配置说明 + +`IndexerConfig` 支持如下配置项: + +| 字段 | 类型 | 说明 | 默认值 | +|--------------------|-----------------------------|----------------------------------------|----------------| +| Client | *pinecone.Client | Pinecone 客户端实例(必填) | - | +| IndexName | string | Pinecone 索引名称 | "eino-index" | +| Cloud | pinecone.Cloud | 云服务商(如 "aws") | "aws" | +| Region | string | 区域(如 "us-east-1") | "us-east-1" | +| Metric | pinecone.IndexMetric | 距离度量:"cosine"、"euclidean"、"dotproduct" | "cosine" | +| Dimension | int32 | 向量维度 | 2560 | +| VectorType | string | 向量类型(如 "float32") | "float32" | +| Namespace | string | Pinecone 命名空间 | (默认) | +| Field | string | 存储内容文本的字段 | (默认) | +| Tags | *pinecone.IndexTags | 元数据标签 | (可选) | +| DeletionProtection | pinecone.DeletionProtection | 删除保护 | (可选) | +| DocumentConverter | func | 自定义文档转换器 | (可选) | +| BatchSize | int | 批量 upsert 的大小 | 100 | +| MaxConcurrency | int | 并发 upsert 的最大协程数 | 10 | +| Embedding | embedding.Embedder | embedding 模型实例 | (必填) | + +## 许可证 + +Apache 2.0。详见 [LICENSE](../../LICENSE)。 diff --git a/components/indexer/pinecone/consts.go b/components/indexer/pinecone/consts.go new file mode 100644 index 000000000..c4a368e17 --- /dev/null +++ b/components/indexer/pinecone/consts.go @@ -0,0 +1,37 @@ +/* + * Copyright 2025 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pinecone + +import "github.com/pinecone-io/go-pinecone/v3/pinecone" + +const ( + typ = "pinecone" + defaultIndexName = "eino-index" + defaultCloud = pinecone.Aws + defaultRegion = "us-east-1" + defaultVectorType = "dense" + defaultDimension = int32(1536) + defaultMetric = pinecone.Cosine + defaultNamespace = "eino_space" + defaultField = "__content__" + defaultDeletionProtection = pinecone.DeletionProtectionDisabled +) + +const ( + defaultMaxConcurrency = 100 + defaultBatchSize = 200 +) diff --git a/components/indexer/pinecone/examples/embeddings.json b/components/indexer/pinecone/examples/embeddings.json new file mode 100644 index 000000000..414d221e8 --- /dev/null +++ b/components/indexer/pinecone/examples/embeddings.json @@ -0,0 +1,5132 @@ +{ + "data": [ + { + "embedding": [ + -3.53125, + -0.25390625, + -1.1015625, + -2.640625, + -1.5546875, + 2.46875, + -1.15625, + -3.875, + 0.17773438, + 0.6328125, + 5.21875, + 0.71484375, + 3.734375, + 0.33398438, + 1.40625, + 0.62890625, + -0.8515625, + -0.9609375, + -0.43359375, + -3.71875, + 0.22753906, + 6.75, + 5.875, + -5.8125, + 2.1875, + -6.375, + 2.515625, + 1.796875, + 2.296875, + -0.27734375, + 4.40625, + -3.265625, + 2.234375, + -0.32617188, + 2.5625, + -2.265625, + -5.03125, + -1.234375, + 6.5625, + -2.625, + -5.625, + 0.609375, + -1.578125, + 4.65625, + -3, + 1.7734375, + 2.203125, + -0.8359375, + -3.8125, + -2.8125, + 1.8203125, + -3.609375, + 6.40625, + -2.875, + 4.09375, + -2.78125, + -7.90625, + 3.3125, + -7.03125, + -3.09375, + 4.0625, + -0.7421875, + 0.31445312, + -0.37109375, + 4.78125, + 6.625, + -2.046875, + -1.2421875, + 2.09375, + 1.8203125, + -0.42382812, + 1.8984375, + 5.78125, + -2.953125, + 5.125, + 5.625, + 4.34375, + 1.8359375, + -3.984375, + 3.8125, + -5.28125, + -0.5546875, + 6.21875, + 2.625, + 4.625, + 4.53125, + -2.90625, + 0.087402344, + -4.53125, + 2.21875, + 4.0625, + 2.4375, + -0.87109375, + -0.44921875, + 2.671875, + 2.984375, + -3.53125, + -6.59375, + -1.2578125, + -2.4375, + -1.7890625, + -4.625, + 0.58203125, + -3.203125, + -4.1875, + 0.11425781, + -4.875, + -5.03125, + -2.796875, + -5.21875, + 1.6953125, + -2.140625, + 4.0625, + -2.453125, + 0.6484375, + -0.5859375, + 2.140625, + -2.828125, + -5.21875, + -1.3984375, + 0.515625, + -1.3203125, + 2.15625, + -3.625, + 2.296875, + 0.103515625, + -1.8359375, + 0.70703125, + 3.3125, + 0.44726562, + 6.09375, + 3.90625, + 2.578125, + -4.59375, + -6.5, + -2.359375, + -3.3125, + 3.078125, + -0.26757812, + 3.359375, + -5.71875, + 0.66015625, + -6.09375, + -5.65625, + 3.859375, + 1.9296875, + -5.78125, + -1.65625, + 7.0625, + -1.203125, + -1.34375, + 2.9375, + 1.3671875, + 6.40625, + -0.63671875, + -3.5625, + 3, + 1.4296875, + 2.53125, + -3.09375, + -0.99609375, + 0.4609375, + 2.28125, + -1.125, + 0.8984375, + -3.140625, + -3.40625, + 2.578125, + 1.40625, + 1.4296875, + 1.4765625, + 11.1875, + 2.859375, + -1.4375, + 1.0078125, + -0.23535156, + 0.6328125, + 8.75, + 3.5625, + -0.43945312, + -0.37109375, + -0.734375, + -0.85546875, + 4.09375, + -3.53125, + 1.3359375, + -1.21875, + -3.6875, + 4.96875, + -2.65625, + 2.84375, + 5.1875, + -3.078125, + -0.82421875, + -5.71875, + -4.3125, + 4.4375, + 2.21875, + 2.28125, + -2.015625, + -4.5625, + -8.4375, + -2.78125, + 1.359375, + -3.546875, + -3.3125, + 1.7421875, + -3.140625, + -0.17285156, + -0.13671875, + 1.765625, + 1.1640625, + -0.15234375, + -1.4140625, + 6.0625, + 2, + 1.90625, + -1.3203125, + 3.859375, + -0.024902344, + 5.6875, + 1.71875, + 0.46875, + -0.19726562, + 2.921875, + 3.421875, + 4.40625, + 2.65625, + -2.15625, + 7.53125, + -1.2265625, + -0.30078125, + 5.21875, + -2.828125, + -2.25, + -2.09375, + -6.53125, + 2.828125, + 0.953125, + 2.5, + -3.234375, + -4.84375, + 1.296875, + 1.9921875, + 2.21875, + 1.578125, + -4.125, + -1.53125, + -3.515625, + -8.1875, + -0.6953125, + 2.875, + -4.46875, + 0.40625, + 2.734375, + 4.875, + -0.38476562, + 4.4375, + 0.78125, + -2.890625, + 1.1796875, + -6.28125, + -3.03125, + 1.78125, + 1.859375, + 2.34375, + 4.40625, + 2.390625, + 2.984375, + 5.15625, + 3.71875, + -5, + -2.453125, + -1.5859375, + -2.109375, + 7.34375, + -2, + -5.46875, + 3.3125, + -1.15625, + -3.3125, + -4.21875, + 1.71875, + -1.8046875, + 2.53125, + -2.4375, + 0.81640625, + 1.078125, + -1.5, + 10.5, + 5.4375, + -2.03125, + 0.7421875, + -1.671875, + -1.8359375, + -2.484375, + -0.88671875, + 1.1484375, + -1.578125, + -1.421875, + 7.8125, + 3.046875, + -0.103027344, + 1.703125, + -2.75, + -0.4140625, + -2.453125, + -5.15625, + 2.140625, + 2.46875, + 1.515625, + 3.625, + 6.46875, + -2.796875, + 0.1484375, + -4.71875, + -2.84375, + 3.5, + -0.3046875, + -0.22070312, + 0.6171875, + -7.5625, + -0.58203125, + -3.828125, + -2.1875, + -4.5625, + 1.3046875, + -1.671875, + 4.5, + 3.578125, + 3.390625, + 3.375, + -7.0625, + -5.3125, + 7.21875, + -0.41210938, + 1.5859375, + 2.9375, + 1.7265625, + 2.75, + -2.53125, + -3.828125, + 2.671875, + -5.53125, + 0.025756836, + 3.5625, + 2.65625, + -1.890625, + 5.375, + -6, + 3.609375, + 1.9921875, + -3.171875, + 6.5, + 8.8125, + 0.59375, + 2.84375, + 2.234375, + 2.84375, + -4.0625, + 2.625, + -0.9921875, + 6, + -2.578125, + -3.21875, + -4.53125, + -1.6328125, + 5.90625, + -2.140625, + -2.90625, + 1.03125, + -4.21875, + 3.390625, + 2.046875, + 3.171875, + -2.171875, + -0.20019531, + 0.91796875, + -3.921875, + 0.640625, + 0.03149414, + 1.40625, + -1.4921875, + 0.42578125, + 3.71875, + 0.012878418, + -1.09375, + 4.5625, + -0.09423828, + -5.96875, + 0.07080078, + -1.75, + -2.96875, + -0.115722656, + 2.734375, + 1.9921875, + -1.5390625, + 3.609375, + -1.609375, + -0.45507812, + 1.875, + -1.0625, + 0.07714844, + -1.5, + -2.953125, + -1.3515625, + -3.21875, + -12.25, + 1.2265625, + 3.578125, + -2.296875, + -2.09375, + 1.6484375, + -3.8125, + -2.875, + 4.78125, + -1.0078125, + 3, + -7.1875, + 2.984375, + 1.5625, + 2.140625, + -0.33789062, + -2.5, + 2.328125, + 0.85546875, + 2.21875, + 6.5, + 0.7578125, + 3.09375, + 2.875, + 0.63671875, + -5.25, + -1.5390625, + -1.8125, + -5.09375, + 4.28125, + -3.375, + -5.625, + 1.28125, + 1.8046875, + -3.125, + 5.5625, + 1.796875, + -7, + -2.71875, + 1.6484375, + 4.5, + -2.46875, + -1.2421875, + 0.234375, + -1.109375, + -2.75, + 2.234375, + 0.88671875, + -1.625, + -2.53125, + 4.3125, + 1.5546875, + -0.46875, + -2.921875, + -0.46289062, + -0.62890625, + 3.171875, + 1.40625, + -2.609375, + -1.84375, + 3.125, + 3.34375, + -6.1875, + -6.28125, + 0.59375, + -2.734375, + -1.2421875, + -0.15625, + 4.625, + 0.012451172, + 0.56640625, + -3.53125, + -4.53125, + 0.19824219, + -6.3125, + 4.5, + 3.75, + -4.25, + -5.34375, + -0.5, + 5.21875, + 2.359375, + 1.234375, + -2.609375, + -0.74609375, + 6.25, + -2.5625, + 3.28125, + 1.15625, + 7.59375, + 2.265625, + -2.59375, + -0.038085938, + -6.125, + -0.31054688, + -1.53125, + 1.421875, + -1.203125, + -2.34375, + 3.421875, + -4.46875, + 1.3046875, + -2.03125, + 2.21875, + -1.4765625, + -2.96875, + 1.3203125, + -4.59375, + -8.125, + -0.46289062, + -1.7578125, + 2.296875, + -1.640625, + -0.35351562, + 1.6640625, + 1.84375, + -0.36914062, + -0.734375, + -3.125, + -2.609375, + -3.46875, + 0.10546875, + 6.1875, + 2.421875, + 3, + -1.3671875, + -5.15625, + -1.1640625, + -1.125, + -1.953125, + -3.15625, + 0.015319824, + 3.4375, + 1.8984375, + -0.17675781, + -6.1875, + -1.1328125, + 2.875, + 0.81640625, + -0.63671875, + -0.72265625, + 2.8125, + 0.48242188, + -0.93359375, + 3.484375, + 2.1875, + 0.38671875, + -0.17382812, + -4.46875, + -5.71875, + -4.3125, + -1.4453125, + 0.5, + 0.34375, + -5.84375, + 2.390625, + 4.125, + -1.2421875, + -2.453125, + 3.0625, + 0.76953125, + 4, + 1.5390625, + 3.078125, + 3.359375, + -2.78125, + -0.75390625, + -0.4921875, + 2.515625, + -8.375, + -7.375, + -1.1328125, + 5.6875, + 3.90625, + -0.67578125, + 2.796875, + -1.140625, + 3.296875, + 1.1875, + -0.8203125, + -11.1875, + 2.734375, + 1.2734375, + -5.5, + -3.875, + -2.046875, + 0.796875, + -1.4375, + -4.21875, + 0.58203125, + -0.3359375, + 2.1875, + 4.625, + -0.53515625, + -0.09326172, + 5.8125, + 1.6953125, + -0.14453125, + 5.03125, + -1.15625, + -3.4375, + 3.328125, + -2.921875, + 2.65625, + 3.953125, + 2.625, + -1.8359375, + 0.037841797, + 1.8203125, + -5.65625, + 0.8984375, + 5.84375, + 3.859375, + -3.96875, + 2.515625, + -4.4375, + 6.84375, + -6.125, + 4.21875, + -0.625, + -4.03125, + -0.025756836, + 5.875, + -5.28125, + -0.92578125, + -1.90625, + -1.5859375, + 2.78125, + 1.21875, + -6.15625, + 1.5546875, + 0.640625, + 0.57421875, + 6.1875, + -1.3125, + -4.03125, + -1.4375, + 3.328125, + 2.953125, + -2.65625, + 3.53125, + 2.28125, + -2.515625, + 1.25, + 5.3125, + -0.8203125, + -0.0032196045, + 2.625, + -0.029296875, + 2.375, + -0.19238281, + 1.7265625, + 1.84375, + -4.625, + -3.453125, + 1.375, + -8.8125, + 2.625, + -2.59375, + -3.1875, + -4.40625, + -1.0703125, + 3.40625, + 3, + 1.9921875, + 2.890625, + 3.953125, + 4.1875, + -3.21875, + 2.875, + -1.734375, + -3.578125, + 0.36132812, + -2.765625, + -2.6875, + -1.1796875, + 2.34375, + -1.4609375, + -0.66796875, + 0.0546875, + -1.59375, + -7.28125, + -6.53125, + 0.5078125, + -3.703125, + 0.94140625, + -2.25, + 2.625, + 0.19433594, + -8.3125, + 1.8359375, + -4.5, + -0.62109375, + -2.078125, + 1.046875, + -5.78125, + -0.12988281, + 6.0625, + -1.84375, + -1.6796875, + 4.96875, + 3.203125, + -0.4921875, + -3.875, + 4, + -1.8671875, + 3.65625, + 2.140625, + -2.203125, + -0.65625, + -5.25, + 0.9609375, + -1.8203125, + 0.609375, + -0.171875, + -0.69140625, + -3.265625, + -5.46875, + -0.8203125, + -0.53125, + -4.375, + -0.734375, + 0.98828125, + -2.421875, + -5.40625, + 2.140625, + 6.53125, + 1.6640625, + 2.21875, + -0.008911133, + 2.1875, + -0.48046875, + 1.6328125, + -4, + -2.265625, + 3.171875, + -1.59375, + -0.734375, + 4.125, + 1.171875, + 0.33789062, + 3.203125, + 2.65625, + -3.171875, + -3.15625, + 3.078125, + 0.0065612793, + 0.21289062, + -0.33398438, + -0.80859375, + -1.6953125, + 1.046875, + -2.25, + -2.03125, + 0.5703125, + 2.234375, + 1.2109375, + 1.59375, + -2.6875, + 5.84375, + 1.203125, + 8.0625, + -4.1875, + -8.375, + -1.125, + 0.51953125, + -1.4140625, + -2.4375, + 4.96875, + -1.2421875, + 0.59375, + -2.3125, + 0.4453125, + -1.1796875, + 0.90625, + 2.296875, + 0.55859375, + 0.890625, + -1.640625, + 3.0625, + -4.8125, + -0.58984375, + -0.25585938, + -4.125, + -0.828125, + 0.7734375, + 3.984375, + -1.015625, + 0.48242188, + -3.046875, + -1.6953125, + -1.65625, + 4.78125, + 5.46875, + -2.796875, + -0.84375, + 0.8125, + 2.890625, + -3.484375, + 5.75, + 0.3984375, + 8, + -0.3671875, + -0.77734375, + 4.8125, + 2.65625, + -0.61328125, + 2.578125, + -8.6875, + -6.8125, + -0.8828125, + 1.8828125, + -2.046875, + 2.6875, + -5.1875, + -1.5859375, + 4.5625, + -2.796875, + 1.2890625, + 1.609375, + 2.609375, + 3.046875, + -3.078125, + -1.859375, + -4.90625, + 0.359375, + 1.0390625, + 2.078125, + -3.734375, + 0.41796875, + 2.6875, + 7.4375, + -1.9375, + -3, + -0.69921875, + 1.8984375, + 0.56640625, + 1.4609375, + -3.140625, + -1.6640625, + 0.9296875, + 2.546875, + -0.64453125, + -3.125, + 0.51171875, + 2.9375, + 3.265625, + -3.59375, + 2.375, + -0.6953125, + 3.890625, + -6.03125, + -4.6875, + -1.0859375, + -0.23632812, + -1.5859375, + -3.734375, + -1.1015625, + 3.984375, + -1.453125, + 4.21875, + -3.0625, + -2.671875, + 4.375, + 1.0078125, + -2.453125, + 0.3125, + 0.25976562, + 1.6171875, + -0.28320312, + 0.91015625, + -2.90625, + -4.6875, + -0.625, + -0.02758789, + -1.2578125, + 2.421875, + 3.921875, + -2.734375, + 1.75, + -5.5625, + 0.99609375, + -3.296875, + 2.390625, + 4.4375, + -3.8125, + -3.65625, + -6, + -8.625, + -0.828125, + -0.75, + -0.53515625, + -3.34375, + -4.0625, + -2.375, + 0.26171875, + -8.75, + -1.84375, + -4.90625, + 0.20019531, + 4, + -0.5625, + 3.0625, + -2.703125, + -1.0546875, + 6.03125, + 3.28125, + 3.96875, + -1.3125, + -0.703125, + 2.5, + 0.546875, + 1.78125, + -1.9296875, + 6.71875, + -0.72265625, + 6.46875, + 2, + 1.984375, + -5.84375, + 2.84375, + 0.6484375, + 3.34375, + -5.5, + -1.4765625, + 1.1484375, + 0.13476562, + -0.74609375, + -1.359375, + -0.8125, + -2.4375, + -0.984375, + 0.9453125, + -7.3125, + -0.76171875, + 4.71875, + 0.71875, + 3.015625, + 1.9921875, + 3.765625, + 1.3046875, + 3.234375, + 1.34375, + 1.5390625, + 3.4375, + -3.921875, + -0.55859375, + -1.375, + -0.10839844, + -2.03125, + 2, + 0.30664062, + 0.18359375, + 4, + 1.28125, + 0.08544922, + 6.8125, + 3.171875, + 1.734375, + -3.09375, + -0.057128906, + -2.078125, + 0.17285156, + 1.8046875, + 0.55859375, + 2.6875, + -3.4375, + -0.91015625, + -1.796875, + 0.58203125, + -0.95703125, + -4.15625, + -1.9375, + -2.5625, + -3.40625, + 7.5625, + -3.671875, + -1.1875, + 1.890625, + 3.28125, + 2.171875, + 5.96875, + 1.53125, + 4.96875, + -2.140625, + -3.171875, + 5.5625, + -2.59375, + -0.15234375, + 5, + 4, + 5.0625, + -1.109375, + -4.34375, + 0.80859375, + 4.59375, + 2.640625, + -2.40625, + -1.6640625, + 2.453125, + 1.0703125, + -4.1875, + 1.8828125, + -0.43554688, + 0.80859375, + -2.546875, + 0.5546875, + 4.34375, + 3.1875, + -3.609375, + -4.875, + -5.1875, + -0.15039062, + 1.046875, + 6, + -2.15625, + 5.34375, + 4.09375, + -2.1875, + 2.5, + -1.859375, + -0.22167969, + -3.796875, + 0.39648438, + 1.15625, + 2.234375, + -2.453125, + -0.2578125, + 1.109375, + -2.140625, + 1.8984375, + 2.734375, + -4.4375, + -0.61328125, + 2.1875, + 0.69921875, + 1.5859375, + 3.796875, + -0.122558594, + -0.671875, + -3.0625, + -4.65625, + -1.1953125, + -0.07421875, + -0.62109375, + -2.1875, + -0.21582031, + 1.265625, + 2.28125, + -2.015625, + 3.09375, + 1, + -3.421875, + 0.45507812, + -5.5, + -4.59375, + -1.203125, + -1.5703125, + -4.375, + -1.8671875, + -0.98046875, + -1.1640625, + 3.1875, + -2.6875, + 5.71875, + -3.96875, + 8.0625, + -2.515625, + -1.09375, + 2.96875, + -4.75, + 2.0625, + -2.3125, + -2.359375, + 2.03125, + -2.28125, + -1.40625, + -0.16796875, + 4.09375, + -0.33984375, + 0.7109375, + 7.625, + -0.052001953, + -3.25, + 0.23632812, + 3.984375, + -2.28125, + -2.78125, + 1.2578125, + 0.7890625, + 0.43359375, + -0.1875, + -1.1875, + -4.40625, + 5.125, + -3.28125, + 0.63671875, + -6.8125, + -0.28710938, + 1.6640625, + 2.375, + 10.0625, + 1.34375, + -3.96875, + -0.78125, + 0.4609375, + -1.5625, + -3.84375, + -2.28125, + 7, + -1.3046875, + -0.41015625, + 1.125, + -2.109375, + -3.875, + 3.96875, + -3.0625, + 4.1875, + 2.71875, + -0.31445312, + 2.25, + 3.625, + 2.203125, + -5.28125, + -3, + -0.55078125, + 2.859375, + 0.85546875, + -2.5625, + 5.46875, + -0.97265625, + 3, + 1.171875, + -2.59375, + 1.8515625, + 6, + 2.734375, + -1.9375, + -1.3125, + 1.2421875, + -0.5234375, + -0.9453125, + -4.90625, + -0.59375, + -5.21875, + -0.6953125, + 1.6484375, + -0.13476562, + 0.73046875, + 3.5, + -3.875, + 3.3125, + -4.09375, + -1.3984375, + 3.96875, + 0.55859375, + -0.23730469, + 4.71875, + 0.71875, + -2.03125, + -2.078125, + 3.921875, + 4.75, + -0.53125, + -4.5, + 4.03125, + 0.008422852, + 5.8125, + -1.5546875, + -1.421875, + -1.2265625, + 3.265625, + 5.4375, + 1.265625, + -2.78125, + 2.15625, + -0.53125, + 0.71875, + 6.40625, + 3.78125, + -6.0625, + -2.296875, + -0.859375, + 4.1875, + 2, + -5.1875, + 0.93359375, + 3.375, + -4.375, + -1.34375, + 0.71875, + 0.99609375, + -2.3125, + 1.5, + -0.6484375, + -3.671875, + -9.3125, + 4.84375, + 0.44335938, + 0.40039062, + -3.328125, + -3.65625, + -1.328125, + -3.015625, + -2.15625, + 1.8515625, + 4, + 2.03125, + -2.890625, + 2.96875, + 5.96875, + -3.546875, + 0.3125, + 4.15625, + -0.24023438, + -2.453125, + -0.46289062, + -1.921875, + -3.046875, + 0.024658203, + -9.5, + -1.2421875, + 6.25, + 3.921875, + 3.59375, + 1.3515625, + 1.546875, + 0.26757812, + -2.796875, + 0.99609375, + -3.25, + -0.78515625, + 3.8125, + 1.8203125, + 0.49023438, + 1.6875, + 1.5078125, + 0.9453125, + -0.17578125, + 1.7421875, + -0.60546875, + 5.8125, + 3.203125, + 4.9375, + -0.20996094, + -7.34375, + 0.8515625, + -1.046875, + -1.125, + 0.3046875, + -2.328125, + 0.47851562, + 0.9375, + 0.31640625, + -4.125, + -3.71875, + -3.96875, + 3.203125, + -0.0038757324, + 1.0078125, + -1.90625, + 3.515625, + 1.296875, + 0.828125, + 3.046875, + -1.1171875, + -0.875, + -2.125, + 1.6171875, + 4.03125, + -0.6015625, + 0.890625, + -1.390625, + 2.046875, + -4.75, + -0.47265625, + -3.40625, + 0.53515625, + -1.5703125, + -4.65625, + 2.609375, + -8.1875, + 4.1875, + 0.24511719, + -3.953125, + -3.03125, + -1.109375, + -0.92578125, + 4.71875, + 1.1328125, + -0.95703125, + 2.28125, + -1.234375, + 4.09375, + 1.578125, + -3.5, + -0.06689453, + 0.66015625, + 1.3984375, + -2.5625, + 2.328125, + -3.4375, + -0.103027344, + 0.30078125, + 4.09375, + -3.484375, + 0.22070312, + 1.390625, + 2.78125, + -2.984375, + -2.40625, + 1.96875, + 2.71875, + -0.07128906, + 2.21875, + -3.421875, + 2.96875, + 5.71875, + 1.6171875, + 2.515625, + -1.9921875, + 5.125, + -0.77734375, + 0.47070312, + 2.390625, + 0.27734375, + 2.703125, + 2.25, + 1.6796875, + 0.109375, + -0.011291504, + 4.15625, + 0.13476562, + -0.734375, + 1.03125, + 1.984375, + -3.640625, + -2.984375, + -7.9375, + 4.25, + -0.5703125, + -1.140625, + 1.6875, + -1.1328125, + 1.5859375, + -1.6015625, + 0.62890625, + 1.25, + -1.7109375, + -2.328125, + 0.73046875, + 0.028076172, + -3.1875, + 0.69140625, + 0.13574219, + 2.8125, + 4.125, + 3.984375, + 2.671875, + -2.3125, + 0.23339844, + -0.09716797, + 3.4375, + 0.14257812, + 0.76953125, + -4.21875, + -2.84375, + 5.53125, + -3.4375, + 0.66796875, + -3.609375, + -4.6875, + -2.3125, + -1.7890625, + 3.59375, + 5.78125, + -4.8125, + -4.59375, + 8.4375, + 3.125, + -0.18652344, + 2.828125, + -2.140625, + 0.5546875, + -1.421875, + 1.0546875, + 4.375, + 5.53125, + 2.109375, + -6.25, + 2.84375, + 6.0625, + 0.640625, + 4.375, + 2.46875, + -1.9140625, + -5.15625, + 3.96875, + 4.0625, + -1.1328125, + -1.328125, + 1.4765625, + 5, + 1.3828125, + 4.875, + -2.578125, + 0.47265625, + -2.046875, + 3.328125, + 0.62109375, + -2.390625, + -2.1875, + 1.8125, + -2, + -2.515625, + 4.625, + 0.38476562, + 2.875, + -1.46875, + 1.2578125, + -1.09375, + 3.578125, + -4.28125, + 4.1875, + -2.015625, + 3.578125, + -3.375, + 1.359375, + -7.5625, + 3.1875, + 3.328125, + 4.78125, + -0.81640625, + -3.609375, + 3.09375, + 2.375, + -1.0546875, + -1.703125, + 4.875, + 3.390625, + 0.15917969, + -3.171875, + -0.23046875, + -1.796875, + 1.8515625, + -1.3984375, + -6.25, + -0.016723633, + 1.8046875, + -3.6875, + -3.796875, + 3.046875, + 3.203125, + -4.78125, + -3.9375, + -0.7265625, + -1.53125, + -2.765625, + 1.7890625, + 3.8125, + -0.26367188, + 6.46875, + 1.875, + 5.4375, + 2.59375, + -1.1328125, + 2.890625, + 5.03125, + -3.609375, + 4.65625, + -0.64453125, + -3.453125, + 0.87109375, + -2.109375, + -0.063964844, + 4.3125, + -1.4609375, + 1.2421875, + -2.34375, + 0.703125, + 3.359375, + 4.5625, + 3.84375, + -0.6640625, + 1.28125, + 2.875, + -2.09375, + -0.16992188, + 0.05810547, + 1.2109375, + -3.046875, + 0.03540039, + -2.0625, + 5.65625, + 1.5546875, + 0.74609375, + 0.18164062, + 4.40625, + -3.1875, + -4.21875, + -6.8125, + 3.375, + -2.375, + -0.37695312, + -0.009643555, + -2.875, + 0.37304688, + 2, + 1.9296875, + 3.671875, + -2.453125, + 2.9375, + 3.71875, + 0.94921875, + -1.7890625, + 0.31640625, + 2.90625, + -0.96875, + 0.29882812, + 2.8125, + -0.96484375, + -1.2578125, + 2.640625, + -6.1875, + -0.084472656, + 0.80078125, + 2.609375, + 0.42773438, + -7.40625, + -1.015625, + -1.3515625, + -2.515625, + -5, + -4.4375, + 2.5625, + 2.109375, + 4.1875, + 8.375, + 3.28125, + -0.053222656, + 4, + 20.375, + -4.90625, + -4.84375, + -1.5, + -2.609375, + 2.421875, + 3.625, + 2.0625, + -1.4140625, + -1.3515625, + 2.90625, + 0.47460938, + 3.25, + -0.0390625, + -3.140625, + 0.55859375, + 0.73046875, + 0.828125, + -2.625, + -1.9140625, + -3.1875, + 1.359375, + 2.109375, + 1.125, + 3.75, + 3.359375, + -0.83984375, + -0.59375, + -1.953125, + -0.74609375, + -6.65625, + -2.9375, + 1.984375, + -3.0625, + 1.84375, + -5.84375, + 6.9375, + 1.0078125, + 0.47460938, + -1.765625, + -2.984375, + -4.09375, + 3.984375, + 0.13574219, + -0.67578125, + 1.546875, + 0.828125, + -0.34960938, + -0.47851562, + -1.296875, + -6.25, + -0.97265625, + -3.71875, + 3.734375, + -0.8359375, + -3.625, + -0.0015869141, + -5.71875, + -0.46484375, + -1.34375, + 1.84375, + -1.7265625, + 4.03125, + 0.27929688, + -0.96484375, + -1.890625, + -2.90625, + -0.46484375, + 3.234375, + -1.09375, + -4.34375, + 0.5625, + 1.6484375, + 1.3671875, + -2.4375, + -4.03125, + 2.640625, + 3.15625, + 2.96875, + -0.19042969, + -3.484375, + 0.24414062, + -1.46875, + 1.0546875, + -0.27929688, + 1.3046875, + -3.75, + 4.8125, + 0.86328125, + -2.859375, + 5.96875, + -6.09375, + 3.390625, + 1.5625, + -6.3125, + -0.23242188, + 2.90625, + 1.8828125, + 1.0859375, + 2.6875, + 1.2109375, + 0.85546875, + 3.328125, + -2.078125, + 1.828125, + 1.9375, + 0.8984375, + 2.125, + 3.71875, + 3.8125, + 1.6015625, + 4.0625, + 0.38476562, + -4.3125, + -0.34570312, + 3.15625, + -3.953125, + -3.8125, + 2.234375, + -2.84375, + 7.71875, + 1.1171875, + -1.1953125, + 4.75, + -7.25, + -1.9453125, + -2.796875, + -6.8125, + 5.1875, + -3.234375, + -1.5859375, + 2.109375, + -0.23925781, + 1.671875, + -3.734375, + -3.65625, + 3.265625, + 6.15625, + 1.8515625, + -1.8125, + -3.90625, + -0.05053711, + 4.5, + -5.28125, + 1.546875, + 1.3515625, + -0.80859375, + 1.8984375, + 2.28125, + -1.4921875, + -2.46875, + 2.4375, + 0.890625, + -4.34375, + -4.28125, + 1.5, + -1.5546875, + 0.4765625, + -3.140625, + -1.96875, + 1.2109375, + -2.671875, + -3.484375, + -2.90625, + -1.09375, + -0.38867188, + 1.328125, + -2.359375, + -1.59375, + 2.21875, + 2.1875, + -7.84375, + -1.7578125, + -0.60546875, + 1.421875, + -1.765625, + 2.8125, + 6.09375, + -0.91796875, + 0.080078125, + 0.15039062, + 0.099609375, + -1.0625, + -6.8125, + 2.28125, + 4.40625, + -5.0625, + 0.09716797, + 0.90625, + 1.9921875, + -5.9375, + -4.40625, + -4.34375, + 5.03125, + 1.90625, + -5.34375, + -2.796875, + -0.67578125, + 1.125, + -1.15625, + -6.1875, + 1.15625, + 3.640625, + 1.5859375, + 4.65625, + 2.09375, + -3.96875, + -0.703125, + 1.484375, + -2.828125, + -5.34375, + 1.3515625, + -0.25976562, + -0.57421875, + -9.6875, + 6.09375, + 3.96875, + 0.265625, + -2.265625, + 0.8671875, + 3.546875, + 1.6484375, + -4.65625, + 1.1640625, + 2.46875, + 1.7734375, + -5.625, + 3.734375, + 1.640625, + -0.100097656, + -1.625, + 7.40625, + -2.59375, + 1.140625, + 0.41796875, + -3.921875, + -2.40625, + -1.453125, + -1.1328125, + 1.171875, + 2.859375, + -1.1640625, + 4.0625, + 3.84375, + -1.5, + 1.640625, + 3.875, + -2.546875, + -1.59375, + 0.45117188, + 0.6875, + 1.7421875, + -1.875, + -5.15625, + -2.765625, + 0.546875, + -3.625, + 2.765625, + -2.828125, + 1.5, + 5.375, + -0.41992188, + 3.140625, + -2.1875, + -0.23632812, + 0.5859375, + 4.125, + -7.9375, + 1.390625, + 1.6640625, + -4.4375, + 2.78125, + 2.65625, + -3.84375, + 0.42578125, + 1.0234375, + 1.484375, + -4.28125, + 3.390625, + 1.1328125, + -0.28710938, + -0.8359375, + 0.07714844, + -1.5, + -1.4375, + -3.78125, + 4, + 0.62109375, + 1.1796875, + -0.8359375, + 3.953125, + 4.9375, + -4.34375, + 2.96875, + -6.34375, + 2.21875, + -0.36328125, + -6.09375, + 4.53125, + -0.8984375, + 1.546875, + 3.09375, + 0.89453125, + -5.15625, + -2.171875, + -4.0625, + -2.25, + 4.3125, + 1.328125, + 0.81640625, + -0.9296875, + 5.25, + 2.484375, + 0.9453125, + 0.90625, + 0.49023438, + -3.234375, + -0.13769531, + 0.515625, + -4.8125, + -1.515625, + 1.6171875, + -2.46875, + 2.15625, + -1.4375, + -0.64453125, + -0.6875, + 0.78125, + -3.765625, + 2.40625, + 3.65625, + -1.7734375, + 2.21875, + -0.9140625, + -0.89453125, + 4.90625, + -0.48242188, + -9.5, + -0.03466797, + 0.15527344, + 0.375, + 0.5625, + -0.5234375, + 0.98046875, + -0.85546875, + 1.71875, + -5.3125, + 3.15625, + 0.640625, + -8.1875, + 0.8671875, + -3.203125, + 0.05908203, + -4.09375, + -0.671875, + 0.024902344, + 6.40625, + 7.5, + 3.5, + 3.765625, + -1.6328125, + 0.5859375, + 2.8125, + -1.859375, + -3.40625, + 1.0546875, + 0.99609375, + -4.3125, + 1.2890625, + 0.69140625, + 0.4140625, + -4.59375, + -2.671875, + 2.71875, + -5.0625, + -0.8359375, + 4.59375, + 6.875, + 1.2265625, + -1.2578125, + -2.765625, + 0.96484375, + 0.84375, + -0.15332031, + 2.03125, + -1.3203125, + 2.90625, + 0.088378906, + 0.49023438, + 0.27929688, + -5.3125, + -2.078125, + -5.21875, + -1.1015625, + -0.7421875, + 1.6328125, + -0.64453125, + -0.11767578, + 0.04638672, + 1.3515625, + 1.7578125, + -0.71875, + -3.265625, + 2.53125, + -2.21875, + -3.171875, + -1.8046875, + 1.8828125, + -3.171875, + -1.4453125, + 0.484375, + 1.1328125, + 1.7265625, + -2.4375, + -2.5625, + 3.515625, + 8.0625, + -1.6796875, + -0.859375, + -1.8125, + 2.765625, + 1.9609375, + -1.3515625, + -1.765625, + -4.46875, + 1.265625, + -5.1875, + -5.5, + 0.39648438, + 0.62109375, + -0.26757812, + 7.84375, + 0.45898438, + -0.31835938, + 3.546875, + -2.21875, + -2.890625, + 2.890625, + 0.7265625, + 1.5703125, + -0.15722656, + 4.375, + -3.390625, + 2.359375, + 6.375, + -1.8984375, + -1.828125, + 0.7734375, + 1.6171875, + -3.5625, + 1.921875, + 3.953125, + -3.359375, + -5.46875, + 11.75, + 1.4375, + 5.46875, + 0.4921875, + -5.375, + 5.46875, + -3.671875, + 1.625, + -1.9140625, + 1.9140625, + 1.7890625, + -7.6875, + 0.28125, + -1.3125, + -3.046875, + 1.46875, + -2.984375, + -3.34375, + 3.671875, + 4.59375, + -2.6875, + 1.015625, + -6.53125, + -1.4140625, + 4.9375, + -1.6640625, + -5.84375, + -0.48242188, + -6.65625, + 1.390625, + -1.453125, + -1.0546875, + -3.84375, + 0.28515625, + -0.3359375, + 4.3125, + -3.828125, + 3.65625, + -0.359375, + -0.07421875, + 1.53125, + 4.59375, + 0.22363281, + 2.453125, + -0.7890625, + 4.28125, + -0.052246094, + -0.08154297, + 0.6953125, + 1.5234375, + -1.0234375, + -0.7578125, + 0.73046875, + 3, + -1.6796875, + -1.96875, + -0.55078125, + 0.064941406, + 0.20507812, + 0.7890625, + -0.87890625, + 2.1875, + 3.09375, + 0.14257812, + 0.049316406, + 0.6796875, + 1.1640625, + -0.48046875, + -0.24121094, + 0.13867188, + -0.12060547, + -1.9609375, + 1.3515625, + 3.203125, + -3.234375, + 0.43945312, + 1.15625, + -1.53125, + -0.30859375, + 0.11767578, + -1.8984375, + 0.53125, + -2.34375, + 2.375, + 0.42773438, + -0.19140625, + -0.42382812, + 0.41601562, + 2.359375, + -1.7734375, + -0.7421875, + 2.890625, + -1.84375, + -1.046875, + -2, + -0.17675781, + 1.6796875, + -0.48632812, + 0.4921875, + 1.75, + 0.23046875, + -0.057861328, + -0.28515625, + 2.96875, + -3.28125, + -1.9296875, + 0.80078125, + 2.640625, + -2.65625, + 0.12792969, + 2.125, + -1.078125, + 0.21289062, + -3.484375, + -1.7265625, + -3.421875, + -0.98828125, + -1.1015625, + -0.3203125, + 0.89453125, + 1.984375, + -3.703125, + 3.09375, + -1.3046875, + 1.53125, + 1.5703125, + 3.03125, + 0.94140625, + -0.98828125, + -2.0625, + 0.52734375, + 0.55078125, + -0.29882812, + 2.046875, + 1.0078125, + -1.859375, + -1.34375, + -0.67578125, + -2.34375, + -0.9609375, + -2.859375, + 1.4609375, + 0.12402344, + 3.578125, + 2.65625, + -0.61328125, + 2.765625, + -0.18261719, + 2.015625, + -2.09375, + 0.7734375, + -0.12890625, + -1, + -0.18164062, + 1.75, + 2.875, + -3.3125, + -0.19042969, + 0.89453125, + 0.66015625, + 2.21875, + -1, + 0.58203125, + -1.2421875, + 4.21875, + 1.140625, + 2.484375, + 0.421875, + 0.87890625, + 1.265625, + -0.8203125, + -0.38085938, + -3.078125, + -2.375, + 1.59375, + 0.94921875, + -0.08105469, + 0.74609375, + 5.625, + -2.4375, + -0.87109375, + -0.34375, + -2.03125, + 2.59375, + 3.484375, + 1.3125, + 4.40625, + -1.5859375, + 0.6171875, + 2.765625, + 2.0625, + 0.36523438, + -0.515625, + 0.38671875, + -0.4921875, + 0.42382812, + 0.39257812, + -0.97265625, + -3.015625, + 1.703125, + -0.2578125, + 3.125, + 1.1171875, + 0.23828125, + -0.15820312, + 0.53125, + -1.8515625, + 0.45898438, + 0.94921875, + -2.875, + -2.046875, + 4.8125, + 0.9296875, + 0.9375, + -1.1640625, + -3.015625, + -0.55078125, + -1.46875, + 2.203125, + -0.49609375, + -0.8125, + -0.81640625, + -1.921875, + -0.23242188, + -1.96875, + 3.796875, + -0.3984375, + 2.265625, + -2.5, + -0.18847656, + 0.6484375, + 2.5625, + 1.015625, + -2.0625, + -0.1484375, + -2.203125, + -0.057617188, + 2.453125, + -1.453125, + 0.030151367, + 2.71875, + -0.45507812, + -0.61328125, + -4.21875, + 0.9609375, + 1.84375, + 1, + -1.671875, + -1.8125, + -0.34375, + -1.03125, + 2.171875, + -3.109375, + 1.2265625, + -3.6875, + -2.46875, + 2.296875, + 1.9609375, + 0.055664062, + 0.8046875, + 1.6875, + -1.5625, + 0.63671875, + -2.21875, + 0.91796875, + -2.453125, + 0.02331543, + 2.703125, + -2.671875, + 0.8203125, + 1.828125, + 0.50390625, + -0.578125, + -2.34375, + 1.484375, + -0.515625, + -0.609375, + 3.328125, + -3.484375, + -0.96484375, + -2, + 0.2578125, + -1.0625, + 2.515625, + 0.095214844, + 1.6328125, + 2.34375, + -2.25, + -2.609375, + 1.921875, + 2.484375, + -2.828125, + 0.010253906, + -0.07470703, + -0.21972656, + -3.125, + -0.87109375, + -2.6875, + -2.765625, + -0.51953125, + -2.984375, + 0.7578125, + 0.24707031, + 1.8203125, + -2.75, + -0.37109375, + 1.3671875, + 0.6484375, + -1.4375, + -1.2890625, + -2.34375, + 3.03125, + 3.03125, + 2.421875, + 2.6875, + -0.484375, + -0.33398438, + -1.7265625, + 1.3671875, + -1.2109375, + -2.125, + -4.28125, + -2.390625, + -1.3984375, + 1.96875, + 1.0234375, + -6.03125, + 1.71875, + -2.546875, + -0.5703125, + 0.61328125, + -1.796875, + 0.59375, + -1.515625, + -0.4375, + 0.84375, + 0.4453125, + 2.078125, + 0.875, + -2.34375, + -1.9765625, + 1.265625, + -4.15625, + 1.453125, + 2.1875, + 1.0078125, + 0.48046875, + 0.26367188, + -1.015625, + -0.4140625, + 1.4453125, + 2.265625, + 2.953125, + 1.6328125, + -2.984375, + -0.859375, + -0.11376953, + -3.234375, + 0.14257812, + -0.17480469, + -1.5, + 0.43164062, + 3.34375, + -1.5, + 0.859375, + 3.328125, + 2.96875, + -1.453125, + 2.21875, + 2.640625, + -3.140625, + -0.06298828, + 0.16503906, + -0.09082031, + -4.25, + -4.15625, + 1.8671875, + 1.0625, + -0.640625, + -2.5, + -2.359375, + -0.30664062, + 1.2578125, + -1.7890625, + -1.9453125, + -1.171875, + 2.390625, + 2.234375, + 0.3671875, + -0.078125, + -2.03125, + -2.75, + -0.6875, + -0.56640625, + -2.5625, + 2.109375, + -1.875, + -3.59375, + 0.6015625, + -1.546875, + -0.984375, + 0.921875, + -0.41992188, + 0.83203125, + -0.009338379, + 3.6875, + -0.75, + -0.8828125, + 3.640625, + 1.90625, + -0.19238281, + -0.17089844, + 1.3125, + 2.640625, + -0.35546875, + -3.828125, + 0.97265625, + 3.71875, + -0.22558594, + -0.34375, + -1.984375, + -0.69921875, + 0.61328125, + -2, + 2.78125, + 0.03173828, + -4.21875, + 0.6484375, + 0.09082031, + -0.3515625, + -4.125, + -3.609375, + 2.390625, + 0.46484375, + 1.3046875, + 3.21875, + -2.265625, + 2.484375, + 1.96875, + -0.23535156, + -1.84375, + -1.265625, + -2.21875, + 1.7421875, + 2.515625, + 0.06347656, + 1.7265625, + -0.45117188, + 0.07861328, + -0.52734375, + -0.59375, + 5.09375, + 0.88671875, + 1.015625, + 2.25, + -1.40625, + -1.015625, + 2.140625, + -1.078125, + -0.1328125, + -2.296875, + -1.328125, + 0.58984375, + -2.40625, + -0.15429688, + -0.13867188, + -0.765625, + -2.6875, + -2.875, + -0.62109375, + -0.080566406, + -0.15820312, + 5.1875, + -0.041015625, + 2.859375, + -2, + 0.44726562, + -0.328125, + 0.3671875, + -2.40625, + 0.984375, + 1.2734375, + -1.1328125, + -2.234375, + 4.09375, + 0.8671875, + -1.609375, + 0.86328125, + -1.1953125, + 3.15625, + -0.79296875, + -6.21875, + -1.6015625, + -0.060791016, + -2.609375, + 0.7421875, + -1.1875, + -0.74609375, + -2.796875, + -2.03125, + 1.359375, + -1.8046875, + 0.04321289, + -1.265625, + -0.453125, + 3.546875, + 0.6484375, + -0.11230469, + 3.515625, + 0.05102539, + -1.140625, + -1.015625, + 2.09375, + 1.859375, + 0.921875, + -0.17578125, + -2.4375, + -0.56640625, + 0.023803711, + -0.36132812, + 0.66015625, + 1.71875, + 0.69921875, + 0.8203125, + -1.625, + -0.16992188, + 1.765625, + -0.30859375, + 2.390625, + -0.25195312, + 0.39648438, + -2.875, + -1.9609375, + 2.640625, + -3.46875, + 1.0390625, + -2.125, + 4.4375, + 4.5625, + 3.125, + 0.72265625, + 1.0234375, + -2.046875, + 1.5546875, + 1.296875, + 1.8828125, + -0.546875, + 0.7734375, + 1.1328125, + 1.796875, + -3.125, + -1.0234375, + 0.006500244, + 2.546875, + 1.5546875, + -2.046875, + 1.640625, + -2.0625 + ] + }, + { + "embedding": [ + -3.390625, + -1.2578125, + -1.8203125, + -1.765625, + -1.421875, + 3.375, + -2.359375, + -3.671875, + -0.15722656, + 1.265625, + 3.453125, + 1.1328125, + 4.0625, + 0.5234375, + 2.125, + 2.65625, + 0.1875, + -1.65625, + -0.515625, + -4.09375, + 0.07324219, + 5.90625, + 6.125, + -6.5, + 2.46875, + -5.75, + 1.7578125, + 2.921875, + 2.515625, + -0.22753906, + 5.59375, + -1.390625, + 2.375, + -0.2578125, + 3.25, + -2.75, + -5.375, + 0.041748047, + 5.34375, + -2.4375, + -5.125, + -0.32421875, + -2.09375, + 4.8125, + -1.5703125, + 2.328125, + 2.25, + -1.9609375, + -5.03125, + -1.859375, + 1.515625, + -3.328125, + 5.8125, + -3.1875, + 3.125, + -3.859375, + -7.5, + 3.40625, + -7.0625, + -2.640625, + 2.765625, + -1.4296875, + 0.47265625, + -1.4609375, + 4.71875, + 6.21875, + -0.796875, + -2.078125, + 1.7578125, + 2.390625, + -1.390625, + 1.015625, + 6.65625, + -1.875, + 5.84375, + 4.71875, + 4.03125, + 2.625, + -3.453125, + 2.265625, + -5.09375, + -2.71875, + 6.875, + 4.28125, + 5.375, + 4.375, + -1.4921875, + 0.03125, + -4, + 2.234375, + 4.28125, + 0.96875, + -1.0859375, + -1.765625, + 2.46875, + 2.03125, + -4.09375, + -5, + -1.75, + -2.265625, + -2.703125, + -4.5625, + 0.068359375, + -2.90625, + -5.34375, + -1.1484375, + -4.34375, + -5.03125, + -0.21777344, + -5.3125, + 0.75, + -1.6171875, + 3.0625, + -1.9765625, + 1.9296875, + -2.125, + 2.53125, + -2.546875, + -5.375, + -0.52734375, + -0.3046875, + 0.05078125, + 1.546875, + -3.671875, + 1.2421875, + 1.4375, + -2.578125, + 0.84375, + 4.40625, + 0.89453125, + 5.6875, + 2.65625, + 2.84375, + -3.9375, + -6.71875, + -3.515625, + -3.359375, + 2.703125, + 1.6484375, + 3.484375, + -6.25, + 0.70703125, + -6.1875, + -5.625, + 5.09375, + 2.265625, + -7.3125, + -1.0859375, + 5.625, + -1.046875, + -0.06591797, + 4.875, + 0.92578125, + 6.03125, + -0.69140625, + -4.375, + 4.53125, + 0.70703125, + 2.96875, + -2.75, + -0.053710938, + 0.140625, + 2.359375, + -0.6171875, + 1.1953125, + -2.1875, + -3.421875, + 1.8984375, + 1.0625, + 0.6953125, + 1.625, + 12.25, + 3.625, + -0.67578125, + 1.34375, + -0.091796875, + 0.43164062, + 8.5625, + 3.171875, + -1.5703125, + 0.20410156, + 0.13671875, + -1.109375, + 2.90625, + -4.375, + 0.97265625, + -1.2109375, + -3.234375, + 4.4375, + -2.375, + 3.09375, + 5.40625, + -3.796875, + -0.087402344, + -5.9375, + -4.875, + 5.40625, + 1.1171875, + 1.59375, + -0.6328125, + -3.625, + -7.9375, + -3.40625, + -0.375, + -4.53125, + -4.1875, + 1.921875, + -3.40625, + -0.22558594, + 1.078125, + 0.73828125, + 0.8203125, + -0.25390625, + 0.27539062, + 7.25, + 1.375, + 1.859375, + -1.2109375, + 4.4375, + 0.77734375, + 6.125, + 1.7578125, + -0.084472656, + -1.84375, + 2.6875, + 2.921875, + 4.90625, + 2.9375, + -1.3359375, + 7.375, + -0.43359375, + 0.2890625, + 5.3125, + -2.015625, + -1.3359375, + -2.5625, + -5.75, + 2.890625, + 1.4140625, + 3.046875, + -2.46875, + -5.4375, + 0.54296875, + 1.6953125, + 1.65625, + 1.2578125, + -3.609375, + -0.71484375, + -2.875, + -8, + -1.890625, + 2.3125, + -5.84375, + 0.93359375, + 3.296875, + 4.65625, + -0.30664062, + 3.84375, + 1.2578125, + -2.828125, + 1.203125, + -6.65625, + -4.0625, + 2.25, + 2.0625, + 3.296875, + 4.4375, + 1.9921875, + 3.171875, + 2.78125, + 5.09375, + -5.25, + -2.546875, + -2.5, + -0.80859375, + 7.96875, + -1.046875, + -5.3125, + 2.796875, + -1.6640625, + -3.359375, + -4.9375, + 2.140625, + -1.46875, + 4.125, + -3.046875, + 0.703125, + 2.5625, + -1.6953125, + 10.8125, + 6.03125, + -1.0234375, + 0.58203125, + -1.375, + -0.96484375, + -0.63671875, + -1.5546875, + 1.3515625, + -1.7109375, + 0.24316406, + 7.875, + 2.6875, + -0.75, + 1.5234375, + -2.78125, + -0.6796875, + -1.578125, + -4.1875, + 2.171875, + 3.59375, + 0.95703125, + 4.25, + 5.5, + -2.59375, + 0.10986328, + -5.5, + -2.234375, + 3.546875, + 0.4140625, + 0.051757812, + 0.09423828, + -7.375, + -0.12207031, + -2.75, + -3.734375, + -4.40625, + 2.125, + -1.5234375, + 4.8125, + 4.53125, + 4.03125, + 3.078125, + -6.25, + -4.21875, + 8.5, + 0.15722656, + 2.046875, + 2.0625, + 1.8828125, + 2.625, + -2.453125, + -3.875, + 2.0625, + -5.25, + 0.1796875, + 2.53125, + 0.76953125, + -1.4765625, + 5.03125, + -6.625, + 3.40625, + 1.7734375, + -1.9921875, + 6.65625, + 8.1875, + 1.2109375, + 2, + 1.390625, + 1.234375, + -3.296875, + 2.1875, + -1.171875, + 5.21875, + -2.109375, + -3.1875, + -4.8125, + -2.375, + 5.875, + -1.3671875, + -3.375, + 0.40625, + -4.65625, + 4.53125, + 3.3125, + 3.359375, + -2.328125, + 0.3671875, + -0.033691406, + -3.984375, + -0.09423828, + 1.59375, + 1.2265625, + -0.81640625, + -0.65234375, + 2.140625, + -0.25976562, + -0.83203125, + 4.75, + -0.453125, + -4.65625, + -0.6015625, + -2.046875, + -3.078125, + -0.6875, + 3.71875, + 1.984375, + -2.640625, + 3.6875, + -1.078125, + -0.83984375, + 1.4609375, + -0.11425781, + -0.515625, + -0.51171875, + -1.875, + -0.29296875, + -2.875, + -10, + 1.9609375, + 4.125, + -2.25, + -1.8359375, + 2.015625, + -5.53125, + -2.84375, + 4.8125, + -0.05078125, + 1.234375, + -6.375, + 2.484375, + 0.84765625, + 3.1875, + 1.40625, + -2.1875, + 2.390625, + -0.25976562, + 0.890625, + 7.03125, + 1.515625, + 2.640625, + 3.171875, + 0.578125, + -5.53125, + -2.6875, + -0.66015625, + -4.78125, + 4.46875, + -2.984375, + -4.9375, + 1.9296875, + 1.671875, + -1.3515625, + 6.15625, + 1.7109375, + -5.875, + -2.96875, + 2.046875, + 5.65625, + -1.28125, + -1.9609375, + -0.39648438, + -1.1796875, + -2.015625, + 1.6015625, + 2.203125, + -1.3828125, + -1.1015625, + 3.296875, + 1.8359375, + -0.37109375, + -2.828125, + -0.37695312, + -1.1484375, + 3.40625, + 1.8515625, + -5.34375, + -1.84375, + 3.5625, + 4.40625, + -7.09375, + -5.03125, + 1.5, + -2.953125, + -1.8359375, + 0.9765625, + 3.796875, + 0.40429688, + -1.6015625, + -2.09375, + -4.78125, + -0.97265625, + -6.90625, + 6.15625, + 3.515625, + -3.609375, + -5.9375, + 1.171875, + 6.625, + 3.078125, + 1.8125, + -2.609375, + -2.078125, + 6.75, + -1.7890625, + 2.921875, + 1.265625, + 7.78125, + 1.6171875, + -3.078125, + -1.2265625, + -5.3125, + -0.48828125, + -2.296875, + 0.91015625, + -3.25, + -2.8125, + 3.140625, + -5.1875, + 2.328125, + -1.953125, + 1.8984375, + -1.0546875, + -2.421875, + 1.828125, + -4.40625, + -7.90625, + -1.2734375, + -1.03125, + 1.71875, + -2.671875, + -0.25390625, + 1.1953125, + 1.1015625, + -1.3125, + -0.8203125, + -3.265625, + -2.953125, + -3.515625, + 0.828125, + 5.09375, + 1.671875, + 4.34375, + -0.3671875, + -5.3125, + -1.7578125, + -0.85546875, + -1.5703125, + -2.953125, + 0.546875, + 2.140625, + 2.109375, + -0.546875, + -5.71875, + -1.53125, + 2.515625, + 0.45117188, + -0.890625, + -0.4375, + 3.765625, + 0.04321289, + -0.61328125, + 2.21875, + 1.53125, + -0.11230469, + -0.104003906, + -4.65625, + -5.40625, + -3.09375, + -1.140625, + 0.796875, + -0.24316406, + -5.65625, + 1.6640625, + 4.65625, + 0.3671875, + -2.8125, + 4.3125, + 1.890625, + 4.53125, + 1.828125, + 2.203125, + 3.140625, + -2.296875, + -1.6640625, + -0.953125, + 2.390625, + -7.125, + -7.1875, + -1.984375, + 6.09375, + 4.125, + -2.359375, + 3.171875, + -1.53125, + 3.484375, + 1.6171875, + -0.84375, + -10.4375, + 3.53125, + -0.72265625, + -6.125, + -4.5625, + -2.078125, + 1.5078125, + -0.7421875, + -5.90625, + 0.31054688, + 0.049804688, + 1.5859375, + 4.84375, + -0.48828125, + -1.3515625, + 7.09375, + 0.2890625, + 0.37890625, + 5.15625, + -2.140625, + -3.75, + 2.59375, + -2.5, + 2.734375, + 3.90625, + 3.40625, + -1.1015625, + -0.640625, + 0.4765625, + -5.15625, + 0.640625, + 5.4375, + 2.890625, + -4.3125, + 1.1875, + -4.71875, + 6.28125, + -5.40625, + 4.125, + -0.70703125, + -4.96875, + -1.2421875, + 4.90625, + -5.34375, + -1.40625, + -2.15625, + -2.140625, + 3.75, + 2.390625, + -6.71875, + 1.734375, + 1.3203125, + -0.35546875, + 6.84375, + -1.0390625, + -2.4375, + -2.0625, + 2.40625, + 3.921875, + -2.578125, + 1.6640625, + 1.53125, + -1.1875, + 1.4140625, + 3.46875, + -0.61328125, + 0.67578125, + 2.453125, + 0.73046875, + 2.96875, + 0.51171875, + 0.78125, + 1.1796875, + -5, + -2.71875, + 2.171875, + -7.15625, + 2.90625, + -2.703125, + -2.296875, + -3.828125, + -0.5703125, + 2.90625, + 2.5625, + 1.25, + 3.046875, + 4.21875, + 4.71875, + -2.671875, + 3.546875, + -1.59375, + -3.1875, + 0.78515625, + -2.59375, + -2.515625, + -1.3046875, + 2.765625, + -1.59375, + -0.42773438, + -0.40625, + -2.421875, + -5.96875, + -6.5, + -0.17578125, + -4.1875, + 1.5390625, + -2.78125, + 2.515625, + 0.890625, + -6.6875, + 1.5390625, + -3.046875, + -0.9609375, + -1.8828125, + 1.4609375, + -5, + -2.109375, + 6.90625, + -0.71875, + -1.9375, + 5.65625, + 3.46875, + 0.91796875, + -4.1875, + 3.796875, + -3.390625, + 3.53125, + 2.09375, + -1.9140625, + -0.06298828, + -5.25, + -0.08544922, + -1.3828125, + 0.55078125, + -0.71484375, + -0.25195312, + -3.53125, + -6.03125, + -0.7265625, + -0.140625, + -3.359375, + -0.71484375, + 1.21875, + -2.265625, + -5.8125, + 1.3046875, + 6.46875, + 2.609375, + 1.6328125, + -1.5859375, + 1.640625, + -1.0859375, + 1.734375, + -3.8125, + -2.046875, + 3.015625, + -0.65625, + -1.1015625, + 3.546875, + 0.4375, + -0.20703125, + 2.203125, + 2.15625, + -3.15625, + -3.46875, + 3.140625, + -0.9140625, + 0.66015625, + -0.049316406, + -0.51171875, + -2.09375, + 1.640625, + -2.765625, + -1.671875, + -0.3203125, + 2.8125, + 1.7421875, + 0.13574219, + -2.859375, + 4.96875, + 1.4453125, + 5.84375, + -5.6875, + -8.25, + -1.5546875, + -1.046875, + -1.25, + -2.6875, + 5.40625, + -0.69921875, + 0.041992188, + -0.9765625, + 0.17382812, + -1.6328125, + 0.5859375, + 3.015625, + 0.8515625, + 1.2890625, + -1.6640625, + 3.8125, + -3.875, + -0.62109375, + 0.56640625, + -4.03125, + -1.0625, + 0.43945312, + 3.515625, + -1.6328125, + 2.375, + -1.890625, + -1.1484375, + -2.34375, + 4.59375, + 5.0625, + -3.0625, + 0.18164062, + -0.07128906, + 1.046875, + -3.203125, + 6.9375, + 0.93359375, + 8.375, + -1.9375, + -0.11328125, + 3.828125, + 0.76953125, + 1.1875, + 2.578125, + -8.875, + -5.78125, + -0.890625, + 1.7421875, + -1.96875, + 3.203125, + -3.8125, + -1.375, + 5.5, + -2.375, + 1.3984375, + 1.2890625, + 2.765625, + 2.59375, + -2.234375, + -1, + -4.03125, + 0.4609375, + 1.1953125, + 1.9921875, + -3.1875, + 0.55859375, + 2.609375, + 8.375, + -2.171875, + -3.390625, + -1.9453125, + 2.46875, + 0.90625, + 1.21875, + -1.859375, + -2.53125, + 1.9609375, + 1.5859375, + -1.0859375, + -3.46875, + 0.25195312, + 2.75, + 4.15625, + -2.796875, + 2.75, + -0.37695312, + 4.28125, + -5.625, + -4.59375, + -1.4921875, + -0.2578125, + -1.640625, + -3.296875, + -0.6484375, + 3.125, + -1.84375, + 3.859375, + -2.953125, + -2.46875, + 4.78125, + 2.0625, + -2.828125, + -0.796875, + 0.49609375, + 1.578125, + -1.0703125, + 0.23144531, + -2.859375, + -2.390625, + -1.390625, + 1.125, + -0.7265625, + 2.765625, + 4.15625, + -1.5859375, + 0.9921875, + -5.1875, + 1.1484375, + -2.5, + 4.25, + 5, + -3.796875, + -3.640625, + -6.15625, + -6.96875, + -1.3125, + 0.13476562, + -0.5703125, + -2.453125, + -4.3125, + -2.03125, + 0.25976562, + -9.0625, + -1.9296875, + -5.5, + 0.29882812, + 4.625, + 1.03125, + 2.125, + -2.6875, + 0.8515625, + 4.96875, + 2.59375, + 4.03125, + -1.171875, + -0.1875, + 3.234375, + 0.092285156, + 2.171875, + -2.015625, + 5.75, + -0.8125, + 6.1875, + 2.5, + 0.006286621, + -6.3125, + 2.109375, + 1.0859375, + 3.171875, + -6, + -1.21875, + 1.21875, + 0.15039062, + 0.48046875, + -1.9921875, + 0.51171875, + -2.40625, + -0.97265625, + -0.40429688, + -7.40625, + -0.46875, + 5.40625, + 0.21972656, + 4.78125, + 1.984375, + 4.0625, + 2.65625, + 2.890625, + 0.90234375, + 1.34375, + 3.015625, + -4.28125, + 0.15722656, + -2.28125, + 0.92578125, + -1.2578125, + 2.390625, + -0.84765625, + 0.88671875, + 4.875, + 1.4296875, + 0.48828125, + 7.09375, + 4.875, + 1.0859375, + -2.171875, + 0.30664062, + -2.203125, + 0.8046875, + 2.03125, + 0.640625, + 2.453125, + -2.953125, + 0.20800781, + -1.6640625, + 1.0703125, + -1.8984375, + -3.765625, + -3.40625, + -2.734375, + -3.765625, + 6.5625, + -2.15625, + 0.2265625, + 0.81640625, + 4.4375, + 2.28125, + 6.5625, + -0.2890625, + 4.875, + -2.84375, + -3.46875, + 4.78125, + -2.171875, + -0.71875, + 3.78125, + 3.40625, + 4.125, + -0.6875, + -4.15625, + 0.03857422, + 4.65625, + 2.84375, + -2.484375, + -0.66796875, + 2.65625, + 1.25, + -4.03125, + 2.203125, + -0.53125, + 1.78125, + -3.484375, + -0.40625, + 3.9375, + 1.890625, + -3.15625, + -5.875, + -4.8125, + -0.43554688, + 2.03125, + 4.625, + -2.21875, + 4.71875, + 2.78125, + -1.8828125, + 2.296875, + -2.15625, + 0.1484375, + -4.375, + 0.96875, + 0.32421875, + 1.7890625, + -1.1640625, + -0.12109375, + -0.36132812, + -0.20117188, + 2.28125, + 3.796875, + -4.375, + -0.34179688, + 1.7421875, + 1.125, + 0.390625, + 2.71875, + 0.41015625, + -0.12890625, + -2.921875, + -4.75, + -2.09375, + 0.4453125, + -0.21386719, + -3.078125, + -0.5546875, + 1.9453125, + 2.578125, + -2.640625, + 2.859375, + 1.6484375, + -2.765625, + 1.0859375, + -5.6875, + -4.0625, + -0.4453125, + -1.4921875, + -3.890625, + -2.671875, + -1.78125, + 0.037353516, + 3.8125, + -4.09375, + 6.3125, + -2.609375, + 7.5625, + -1.078125, + -1.9921875, + 3.59375, + -5.21875, + 3.046875, + -2.671875, + -3.03125, + 1.6640625, + -2.734375, + -2.265625, + -0.49609375, + 4.53125, + 0.45898438, + 0.47265625, + 7.84375, + -0.67578125, + -4.3125, + -0.0154418945, + 3.34375, + -2.25, + -2.78125, + 0.66796875, + 0.9921875, + -0.10058594, + -0.40625, + -1.09375, + -3.859375, + 6.15625, + -2.640625, + 0.69921875, + -7.21875, + -1.359375, + 1.8984375, + 2.640625, + 10.375, + 2.0625, + -3.984375, + 0.27734375, + 1.578125, + -2.359375, + -3.015625, + -3.234375, + 6.34375, + -0.052001953, + -0.7734375, + 1.265625, + -0.37695312, + -3.25, + 3.578125, + -2.265625, + 2.828125, + 3.09375, + -0.1796875, + 1.3203125, + 2.46875, + 1.46875, + -5.8125, + -2.9375, + -0.03112793, + 2.875, + 1.03125, + -1.328125, + 6.0625, + -0.53515625, + 3.25, + 1.3046875, + -2.1875, + 3.046875, + 5.78125, + 2.359375, + -2.1875, + -2.140625, + 1.046875, + -1.2890625, + -1.25, + -6.78125, + -1.796875, + -5.375, + -0.8203125, + 1.8515625, + -0.75390625, + 0.48632812, + 3.375, + -3.875, + 3.46875, + -3.953125, + -1.4765625, + 4.8125, + 0.58203125, + 0.041992188, + 4.40625, + -0.42773438, + -2.71875, + -1.6796875, + 4.09375, + 4.1875, + -1.484375, + -4.65625, + 3.765625, + 0.53125, + 5.40625, + -0.75390625, + -1.2578125, + -1.0078125, + 3.796875, + 3.828125, + 0.95703125, + -2.875, + 2.484375, + -0.078125, + 0.859375, + 7.375, + 4.375, + -4.40625, + -2.78125, + -1.703125, + 4.0625, + 1.7578125, + -4.90625, + -0.104003906, + 3.8125, + -4.0625, + -0.73828125, + 1.3984375, + 0.87109375, + -4.78125, + 2.484375, + -1.8359375, + -4.03125, + -9.6875, + 5.84375, + 0.06689453, + -0.36132812, + -3.765625, + -4.40625, + -1.96875, + -2.828125, + -2.078125, + 2.734375, + 3.875, + 3.3125, + -1.8125, + 3.40625, + 5.4375, + -3.671875, + -0.75, + 5.3125, + -0.32226562, + -2.921875, + -0.49804688, + -3.03125, + -3.59375, + 1.3046875, + -10, + -2.578125, + 6.625, + 4.09375, + 4.4375, + 0.7578125, + 1.2109375, + 1, + -2.03125, + -1.4140625, + -3.96875, + -1.2890625, + 4.15625, + 2.234375, + 1.203125, + 2.109375, + -0.11279297, + 0.018554688, + -0.60546875, + 1.7265625, + 0.12792969, + 6.78125, + 2.453125, + 5.28125, + -2.21875, + -6.71875, + 0.41992188, + -1.84375, + -1.53125, + -1.2265625, + -1.734375, + 1.171875, + 0.75390625, + 0.75390625, + -4.25, + -4.59375, + -4.21875, + 3.046875, + 1.3359375, + 1.703125, + -2.875, + 2.828125, + -0.2734375, + 1.5625, + 2.75, + -1.921875, + 0.039794922, + -1.515625, + 0.5390625, + 4.25, + -0.890625, + -0.76171875, + -1.9453125, + 2.890625, + -3.828125, + -0.49414062, + -4.71875, + 0.072753906, + -1.5859375, + -3.5, + 2.65625, + -6.59375, + 3.6875, + -0.95703125, + -1.875, + -2.046875, + -1.0859375, + 0.11328125, + 5.21875, + 0.765625, + -0.93359375, + 4.46875, + -1.328125, + 4.28125, + 1.9453125, + -3.390625, + -0.703125, + 1.2109375, + 0.78125, + -2.375, + 2.3125, + -2.375, + 0.14355469, + -0.15136719, + 3.5625, + -3.84375, + 0.84765625, + 2.015625, + 2.0625, + -3.640625, + -2.140625, + 1.0390625, + 2.09375, + -0.37890625, + 3.0625, + -4.15625, + 2.296875, + 4.03125, + 0.6484375, + 3.1875, + -1.8515625, + 6.53125, + -0.7734375, + 0.66015625, + 2.328125, + -0.15625, + 2.75, + 0.80859375, + 1.828125, + 0.16308594, + -0.21582031, + 4.21875, + 0.49609375, + -0.828125, + -0.33007812, + 1.5, + -2.84375, + -3.5625, + -8.625, + 4.875, + -0.071777344, + -0.609375, + 1.3203125, + -0.7578125, + 2.109375, + -0.9765625, + -0.375, + 1.34375, + -2.1875, + -2.40625, + 1.125, + 0.25390625, + -3.765625, + 0.90234375, + -0.8359375, + 3.375, + 4.40625, + 5.125, + 3.09375, + -2.421875, + 1.8984375, + -0.34960938, + 2.625, + -0.0023345947, + 0.37890625, + -4.40625, + -1.1875, + 5.15625, + -3.484375, + 0.096191406, + -2.875, + -3.4375, + -1.6875, + -1.359375, + 3.1875, + 6.1875, + -4.3125, + -3.546875, + 9, + 2.875, + -0.0013961792, + 2.1875, + -2.671875, + 0.38867188, + -1.3671875, + 0.1640625, + 4.4375, + 4.8125, + 1.75, + -6.375, + 3.65625, + 5.5, + 1.7578125, + 3.78125, + 2.703125, + -1.828125, + -5.59375, + 3.3125, + 3.609375, + -0.22265625, + -0.87890625, + 0.93359375, + 4.46875, + 1.2578125, + 5.28125, + -4.21875, + 0.62890625, + -2.421875, + 3.5, + 0.8359375, + -1.9921875, + -2.109375, + 2.296875, + -1.28125, + -2.453125, + 4.34375, + -0.0021820068, + 1.6171875, + -1.640625, + 1.2265625, + -2.875, + 4.625, + -4.6875, + 3.09375, + -2.0625, + 2.90625, + -2.171875, + 0.73828125, + -7.28125, + 3.109375, + 2.890625, + 3.25, + -0.80859375, + -2.375, + 2.671875, + 3.765625, + -0.59375, + -2.3125, + 5.21875, + 4.3125, + 0.22460938, + -3.46875, + -0.640625, + -1.3515625, + 1.578125, + 0.034179688, + -5.625, + 1.171875, + 0.21582031, + -3.90625, + -5.25, + 2.5, + 3.359375, + -5.09375, + -3.453125, + -0.51953125, + -0.7578125, + -1.546875, + 2.359375, + 3.875, + -0.39453125, + 6.375, + 2.171875, + 4.90625, + 2.953125, + -0.48242188, + 2.0625, + 4.78125, + -2.96875, + 5.125, + -1.1328125, + -4.28125, + 1.65625, + -1.71875, + -0.73046875, + 4.34375, + -2.125, + 1.828125, + -2.953125, + -1.7578125, + 3.953125, + 3.765625, + 5.90625, + -0.6796875, + 2.234375, + 2.421875, + -1.0078125, + -0.4765625, + 0.328125, + 1.7109375, + -3.34375, + -0.27539062, + -2.96875, + 6.34375, + 1.4296875, + 0.040283203, + -1.734375, + 4.46875, + -2.71875, + -3.34375, + -7.0625, + 2.234375, + -2.015625, + 1.03125, + 0.24609375, + -4.78125, + -0.43554688, + 1.875, + 0.89453125, + 3.984375, + -2.546875, + 3.390625, + 3.421875, + 1.515625, + -2.1875, + -1.078125, + 3.078125, + -0.59765625, + -0.78125, + 1.4140625, + -0.59765625, + -2.015625, + 2.65625, + -6.21875, + 0.27539062, + 1.40625, + 2.65625, + 0.54296875, + -5.46875, + -2.28125, + 0.44726562, + -2.484375, + -5.65625, + -5.375, + 3.3125, + 2.078125, + 3.109375, + 7.75, + 3.53125, + 0.21679688, + 3.546875, + 18, + -4.1875, + -5.1875, + -1.53125, + -2.046875, + 2.734375, + 5.1875, + 2.390625, + -0.34765625, + -0.9765625, + 2.671875, + 2.15625, + 3.515625, + 0.25195312, + -4.21875, + -0.28320312, + 0.51171875, + 0.41210938, + -1.6640625, + -2.109375, + -3.1875, + 1.5390625, + 2.296875, + 0.140625, + 2.671875, + 4.03125, + -0.86328125, + -0.66796875, + -1.890625, + -1.109375, + -5.9375, + -3.578125, + 2.625, + -2.78125, + 1.296875, + -4.875, + 5.5, + 2.046875, + 1.453125, + -1.96875, + -4, + -2.515625, + 3.609375, + -0.90234375, + 0.115722656, + 0.87109375, + -0.41015625, + -0.39257812, + -0.87109375, + -1.4921875, + -5.28125, + -1.890625, + -3.328125, + 5.21875, + -1.1328125, + -3.46875, + 0.49023438, + -6.125, + -2.234375, + -1.6953125, + 2.46875, + -2.71875, + 3.171875, + -0.66015625, + -0.5625, + -2.5, + -3.171875, + -0.8046875, + 2.0625, + -1.2421875, + -4.46875, + 0.9140625, + 1.3515625, + 2.875, + -1.8671875, + -3.0625, + 2.71875, + 3.484375, + 2.046875, + 0.7421875, + -4.6875, + 1.21875, + -1.375, + 1.265625, + 0.82421875, + 1.8515625, + -2.421875, + 4.125, + 1.625, + -3.484375, + 8.625, + -4.96875, + 3.359375, + 1.5234375, + -7.09375, + -0.41601562, + 4.28125, + 3.28125, + -0.38085938, + 3.3125, + 2.046875, + 1.6171875, + 3.125, + -1.6015625, + 2.6875, + 2.171875, + 0.9453125, + 2.875, + 3.296875, + 4.40625, + 0.39453125, + 3.609375, + 0.75, + -4.34375, + 0.16699219, + 4.78125, + -4.0625, + -4.59375, + 1.015625, + -3.359375, + 8.375, + 2.421875, + -1.3125, + 4.09375, + -7.25, + -3.859375, + -2.84375, + -5.71875, + 6, + -2.109375, + -2.71875, + 2.234375, + 0.98046875, + 1.6328125, + -3.953125, + -4.3125, + 2.390625, + 4.5, + 1.703125, + -0.671875, + -5.65625, + 0.025390625, + 3.640625, + -6.1875, + 0.76953125, + 1.2421875, + -1.5859375, + 2.96875, + 2, + -1.828125, + -3.40625, + 3.140625, + 0.734375, + -3.671875, + -3.6875, + 3.390625, + -1.359375, + 0.063964844, + -3.984375, + -1.9375, + 0.10107422, + -2.703125, + -4.28125, + -3.046875, + -1.8984375, + -0.6875, + 1.140625, + -2.046875, + -2.40625, + 2.0625, + 1.9375, + -9.4375, + -0.7734375, + -0.578125, + 2.796875, + -2.3125, + 2.609375, + 6, + -1.0546875, + 0.8828125, + 0.0859375, + -0.28125, + -1.09375, + -5.78125, + 0.421875, + 3.921875, + -4.875, + -1.28125, + 0.2734375, + 0.68359375, + -5.09375, + -2.953125, + -3.28125, + 3.859375, + 1.0859375, + -5.71875, + -1.859375, + -0.47070312, + 0.3984375, + -2.546875, + -6.46875, + 1.359375, + 3.34375, + 2, + 4.34375, + 1.65625, + -3.90625, + -0.671875, + 0.6328125, + -3.359375, + -4.3125, + 1.1171875, + 0.012084961, + -1.640625, + -8.4375, + 7.125, + 3.984375, + 1.7265625, + -1.6171875, + 1.109375, + 2.625, + 1.03125, + -3.796875, + -0.100097656, + 1.921875, + 1.1796875, + -6.21875, + 3.5, + 2.46875, + 0.6953125, + -0.32617188, + 7.46875, + -1.9296875, + 1.1015625, + -0.36328125, + -3.453125, + -2.359375, + -2.453125, + -1.828125, + 0.115722656, + 2.671875, + -1.5546875, + 3.890625, + 4.34375, + -2.734375, + 2.09375, + 4.4375, + -1.9921875, + -2.3125, + -0.13378906, + 0.9453125, + 1.2734375, + -1.1796875, + -4.96875, + -3.21875, + 0.23144531, + -4.84375, + 1.7734375, + -2.703125, + 2.375, + 5, + -0.44140625, + 3.453125, + -3.0625, + -0.41796875, + -0.24609375, + 4.5625, + -5.65625, + 2.546875, + 1.6015625, + -4.46875, + 4.40625, + 1.7421875, + -3.140625, + 0.51171875, + 1.546875, + 1.171875, + -2.765625, + 2.828125, + 1.0078125, + 0.008972168, + -2.609375, + 0.41015625, + -2.453125, + -0.46289062, + -3.21875, + 4.125, + 1.046875, + 1.625, + -1.390625, + 5.4375, + 5.75, + -5.25, + 2.09375, + -6.03125, + 1.6953125, + -1.0859375, + -6.15625, + 4.09375, + -1.0625, + 1.1484375, + 4.65625, + 1.015625, + -7.0625, + -2.578125, + -2.6875, + -1.265625, + 4.6875, + 1.453125, + 0.33398438, + -0.8984375, + 4.28125, + 2.984375, + 1.921875, + 0.21777344, + 0.09375, + -2.875, + 0.52734375, + 0.25195312, + -5.40625, + -1.0546875, + 2.53125, + -3, + 2.09375, + -1, + -1.8828125, + -0.98046875, + 1.0390625, + -3.890625, + 1.9140625, + 4.28125, + -1.0625, + 3.5, + -1.3828125, + -0.8046875, + 3.75, + -0.953125, + -8.875, + -0.7265625, + 1.1484375, + 0.39453125, + 0.6796875, + -1.859375, + 1.015625, + -1.2578125, + -0.06933594, + -4.03125, + 3.265625, + 1.1640625, + -9.9375, + 1.6484375, + -2.03125, + 1.171875, + -4, + -1.0703125, + -1.8671875, + 6.71875, + 5.8125, + 4.5625, + 2.921875, + -2.09375, + 0.69921875, + 3.546875, + -2.359375, + -2.859375, + 2.796875, + 0.60546875, + -4.25, + 0.8828125, + 1.2265625, + 0.45117188, + -4.53125, + -3.9375, + 2.5625, + -3.640625, + -0.44335938, + 4.96875, + 5.15625, + -0.111328125, + -1.828125, + -4.625, + 1.8125, + -1.2265625, + -1.0625, + 2.109375, + -1.140625, + 3.734375, + 0.63671875, + 0.59375, + 0.75390625, + -4.5, + -1.859375, + -5.8125, + -0.734375, + -0.87890625, + 1.75, + -0.43554688, + -0.14550781, + -1.0625, + 1.4296875, + 1.65625, + -1.4609375, + -3.84375, + 2.390625, + -2.015625, + -3.578125, + -2.15625, + 0.65234375, + -3.90625, + -0.42578125, + 0.9453125, + 0.7734375, + 1.2109375, + -2.796875, + -2.578125, + 2.9375, + 6.65625, + -0.59375, + -0.35351562, + -2.375, + 3.03125, + 0.95703125, + -1.7109375, + -1.40625, + -3.6875, + 0.59375, + -3.921875, + -5.90625, + 0.21386719, + 1.3203125, + 1.4921875, + 7.96875, + -1.34375, + 0.08300781, + 3.171875, + -1.9765625, + -2.828125, + 3.453125, + 0.0390625, + 0.9921875, + -1.984375, + 2.75, + -3.296875, + 1.484375, + 6.125, + -2.03125, + -2.75, + 0.84375, + 0.41210938, + -3.546875, + 2.171875, + 3.078125, + -2.234375, + -4.90625, + 11.25, + 1.46875, + 7, + 0.36914062, + -3.671875, + 4.34375, + -4, + 3.515625, + -1.3671875, + 1.4296875, + 2.53125, + -8.25, + -0.32421875, + -0.2734375, + -2.65625, + 1.59375, + -2.75, + -3.359375, + 2.796875, + 6.09375, + -4.375, + 0.69921875, + -4.40625, + -1.03125, + 4.5625, + -1.4453125, + -6.78125, + 0.083496094, + -6.5, + 1.5390625, + -1.0390625, + -0.056152344, + -1.9765625, + 0.30664062, + -0.97265625, + 5.28125, + -4.78125, + 3.140625, + -1.328125, + 0.53515625, + 1.0859375, + 4.84375, + 0.78515625, + 2.21875, + 0.28125, + 4.5, + -0.24511719, + -0.64453125, + 0.55078125, + 1.5234375, + -1.28125, + -0.07080078, + 0.62109375, + 3.046875, + -2.359375, + -1.796875, + -1.2421875, + 0.33203125, + -0.89453125, + 0.92578125, + -1.859375, + 2.359375, + 1.9453125, + 1.1484375, + 0.052978516, + 0.010375977, + 0.2734375, + -0.47265625, + -0.4765625, + -1.078125, + 0.31640625, + -2.328125, + 1.25, + 2.984375, + -3.78125, + -0.80859375, + 0.296875, + -0.9921875, + -0.97265625, + 2.1875, + -1.203125, + -0.24414062, + -1.0859375, + 1.8671875, + 0.07373047, + 0.052978516, + 0.7734375, + -0.28710938, + 2.71875, + -1.015625, + -0.16503906, + 3.421875, + -1.3203125, + -1.640625, + -1.546875, + -0.38085938, + 1.8828125, + -1.4921875, + 0.10449219, + 1.5234375, + 0.92578125, + 1.1015625, + 0.18554688, + 1.390625, + -4.15625, + -0.96484375, + 0.99609375, + 3.078125, + -3.203125, + -1.046875, + 1.3359375, + -1.125, + -1.1484375, + -3, + -1.0625, + -2.265625, + -0.28320312, + -0.09277344, + -0.8046875, + 1.4609375, + 0.25390625, + -3.609375, + 2.5625, + -0.76171875, + 2.59375, + 1.09375, + 3.09375, + 1.8671875, + -2.140625, + -2.171875, + 0.0066833496, + 1.203125, + -0.96484375, + 1.8515625, + 1.2734375, + -1.28125, + -0.51171875, + 0.64453125, + -2.71875, + -0.734375, + -1.3203125, + 0.2109375, + -1.6328125, + 2.734375, + 1.75, + -0.4140625, + 1.5234375, + -0.78515625, + 1.5859375, + -1.0390625, + 0.65234375, + -1.1484375, + -0.5703125, + -1.3125, + 2.015625, + 2.546875, + -1.65625, + -2.765625, + 0.53515625, + -0.109375, + 2.078125, + -0.625, + 0.2421875, + -0.42382812, + 4.875, + 0.107421875, + 0.46875, + 0.15722656, + 0.21191406, + 0.13574219, + -2.984375, + -0.55078125, + -3.453125, + -0.28125, + 0.34960938, + 0.9765625, + -1.2421875, + 1.40625, + 5.1875, + -2.75, + -0.890625, + -0.7109375, + -0.8359375, + 2.5, + 2.71875, + 0.47851562, + 3.828125, + -0.5546875, + -0.33203125, + 3.15625, + 1.1328125, + -1.1640625, + 0.36132812, + -0.16601562, + -1.2734375, + 0.89453125, + -0.07714844, + -1.8125, + -3.71875, + 1.7265625, + -0.5625, + 3.984375, + 1.453125, + -0.8203125, + -0.55859375, + -0.3125, + -1.1171875, + 1.8671875, + -0.15527344, + -2.796875, + -2.453125, + 4.40625, + 1.375, + 0.81640625, + -0.8359375, + -2.75, + -0.77734375, + -0.296875, + 2.46875, + -0.984375, + -1.3203125, + -1.59375, + -2.078125, + 0.59375, + -1.59375, + 4.46875, + -0.3828125, + 2.8125, + -2.484375, + -0.59765625, + 0.578125, + 2.4375, + 1.40625, + -1.625, + -0.13183594, + -2.796875, + -0.111328125, + 2.96875, + -0.69140625, + 0.8828125, + 3.359375, + -0.13964844, + -0.04736328, + -4.59375, + 1.046875, + 1.765625, + 0.26953125, + -0.77734375, + -2.296875, + -0.27929688, + -1.859375, + 2.953125, + -2.765625, + 2.5625, + -3.9375, + -2.765625, + 1.1875, + 2.203125, + 0.30273438, + 0.36132812, + 0.9765625, + -0.41796875, + 0.083496094, + -0.22851562, + -0.140625, + -2.125, + -0.14355469, + 4.125, + -3.8125, + 0.89453125, + 2.078125, + 0.37890625, + -1.0078125, + -1.59375, + 1.546875, + -0.5703125, + -1.15625, + 2.6875, + -4.1875, + -1.3828125, + -1.6171875, + 0.578125, + -0.640625, + 2.765625, + 0.6875, + 3.34375, + 1.8515625, + -2.171875, + -0.7890625, + 2.34375, + 1.2265625, + -3.421875, + 0.032714844, + -1.265625, + 0.23535156, + -3.296875, + -1.1015625, + -3.984375, + -2.3125, + 0.75390625, + -2.34375, + 1.03125, + 0.7734375, + 2.15625, + -2.921875, + 0.7578125, + 1.7734375, + 0.98046875, + -0.71875, + -1.1015625, + -1.125, + 4.4375, + 3.5625, + 2.703125, + 2.25, + -0.54296875, + 0.08642578, + -2.078125, + 1.75, + -1.6015625, + -1.4453125, + -3.484375, + -1.9140625, + -1.4140625, + 1.28125, + 0.44921875, + -4.5625, + 1.5859375, + -2.34375, + -0.11230469, + -0.87890625, + -0.765625, + 1.1328125, + -2.71875, + -0.66796875, + 0.59765625, + 0.5859375, + 1.25, + 0.56640625, + -1.2421875, + -0.796875, + 1.3515625, + -2.28125, + 1.125, + 2.109375, + 1.015625, + 1.8359375, + -0.34765625, + -0.20410156, + 0.140625, + 1.5, + 1.4140625, + 1.8515625, + 3.015625, + -3.53125, + -1.015625, + -0.50390625, + -3.140625, + -0.44726562, + -0.99609375, + -0.88671875, + 0.10253906, + 3.921875, + -1.2265625, + -0.6484375, + 3.34375, + 2.375, + -1.7109375, + 2, + 2.375, + -4.28125, + -1.359375, + 0.104003906, + 0.39648438, + -5.28125, + -4.1875, + 2.140625, + 0.19335938, + -0.23339844, + -3.375, + -1.4453125, + 0.36328125, + 1.4453125, + -1, + -1.6328125, + -2.265625, + 2.015625, + 2.28125, + 0.01953125, + 0.22363281, + -1.2421875, + -1.3671875, + 1.296875, + -0.021850586, + -2.328125, + 1.7890625, + -1.578125, + -1.8984375, + 0.91015625, + -1.5, + -1.6875, + 1.765625, + -0.2421875, + 1.234375, + 0.61328125, + 1.828125, + 0.3984375, + 0.6796875, + 3.8125, + 1.921875, + 0.7265625, + -1.5703125, + 1.59375, + 2.703125, + -0.23046875, + -1.9296875, + 0.60546875, + 3.6875, + -0.45703125, + -0.6796875, + -2.203125, + 0.6015625, + 1.0078125, + -1.7734375, + 3.015625, + 0.22851562, + -3.59375, + 0.02355957, + 0.56640625, + 0.53515625, + -3.59375, + -2.5625, + 2.046875, + 1.3671875, + 1.1953125, + 4.15625, + -2.125, + 0.9453125, + 1.578125, + 0.40429688, + -1.515625, + -0.91796875, + -1.9765625, + 1.140625, + 2.390625, + -0.71484375, + 2.171875, + 0.13574219, + -0.47460938, + -1.28125, + -1.765625, + 5.75, + 0.90625, + -0.203125, + 2.640625, + -2.109375, + -1.4375, + 0.58203125, + -1.09375, + -1.0625, + -0.26953125, + -2.359375, + 0.24609375, + -1.4296875, + -0.04345703, + -0.41015625, + -0.96875, + -2.6875, + -3.09375, + -0.859375, + -1.0234375, + 0.33203125, + 4.96875, + -0.60546875, + 1.1953125, + -2.828125, + 1.0625, + -0.044921875, + 0.390625, + -0.86328125, + 1.1640625, + 1.5, + -1.0859375, + -2.546875, + 4.46875, + 1.015625, + -1.09375, + -0.7421875, + -1.171875, + 2.171875, + -0.99609375, + -5.28125, + -2.375, + -0.84765625, + -3.578125, + 0.58203125, + -1.4375, + -1.203125, + -4.75, + -1.8203125, + -0.66796875, + -1.3828125, + -1.1015625, + -0.20703125, + -0.2734375, + 2.21875, + 0.41601562, + 0.89453125, + 2.578125, + 0.6484375, + -1.84375, + -1.4140625, + 0.80078125, + 2.1875, + 1.46875, + -1.4140625, + -1.1171875, + -0.70703125, + -0.14355469, + -0.6171875, + 0.34960938, + 1.15625, + 0.46484375, + 0.83203125, + -0.9296875, + 0.3828125, + 0.99609375, + 0.50390625, + 1.234375, + -1.0859375, + -0.76953125, + -1.8671875, + -1.8046875, + 1.6796875, + -2.828125, + 1.8359375, + -2.421875, + 4.15625, + 3.328125, + 3.8125, + 0.0067749023, + 0.34570312, + -0.59765625, + 1.109375, + 1.8359375, + 0.31054688, + 0.78125, + 0.87109375, + 0.9296875, + 2.671875, + -3.109375, + -0.43164062, + -0.52734375, + 2.15625, + 1.8046875, + -1.9765625, + 2.140625, + -0.35742188 + ] + } + ] +} \ No newline at end of file diff --git a/components/indexer/pinecone/examples/main.go b/components/indexer/pinecone/examples/main.go new file mode 100644 index 000000000..c78283852 --- /dev/null +++ b/components/indexer/pinecone/examples/main.go @@ -0,0 +1,108 @@ +/* + * Copyright 2025 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "context" + "github.com/bytedance/sonic" + pc "github.com/pinecone-io/go-pinecone/v3/pinecone" + "log" + "os" + + "github.com/cloudwego/eino-ext/components/indexer/pinecone" + "github.com/cloudwego/eino/components/embedding" + "github.com/cloudwego/eino/schema" +) + +func main() { + // Load configuration from environment variables + apiKey := os.Getenv("PINECONE_APIKEY") + if apiKey == "" { + log.Fatal("PINECONE_APIKEY environment variable is required") + } + + // Initialize Pinecone client + client, err := pc.NewClient(pc.NewClientParams{ + ApiKey: apiKey, + }) + if err != nil { + log.Fatalf("Failed to create Pinecone client: %v", err) + } + + // Create Pinecone indexer config + config := pinecone.IndexerConfig{ + Client: client, + Dimension: 2560, + Embedding: &mockEmbedding{}, + } + + // Create an indexer + ctx := context.Background() + indexer, err := pinecone.NewIndexer(ctx, &config) + if err != nil { + log.Fatalf("Failed to create Pinecone indexer: %v", err) + } + log.Println("Indexer created successfully") + + // Store documents + docs := []*schema.Document{ + { + ID: "pinecone-1", + Content: "pinecone is a vector database", + MetaData: map[string]any{ + "tag1": "pinecone", + "tag2": "vector", + "tag3": "database", + }, + }, + { + ID: "pinecone-2", + Content: "Pinecone is an vector database for building accurate and performant AI applications.", + }, + } + + ids, err := indexer.Store(ctx, docs) + if err != nil { + log.Fatalf("Failed to store documents: %v", err) + return + } + log.Printf("Stored documents successfully, ids: %v", ids) +} + +type vector struct { + Data []struct { + Embedding []float64 `json:"embedding"` + } `json:"data"` +} + +type mockEmbedding struct{} + +func (m *mockEmbedding) EmbedStrings(ctx context.Context, texts []string, opts ...embedding.Option) ([][]float64, error) { + bytes, err := os.ReadFile("./examples/embeddings.json") + if err != nil { + return nil, err + } + var v vector + if err := sonic.Unmarshal(bytes, &v); err != nil { + return nil, err + } + res := make([][]float64, 0, len(v.Data)) + for _, data := range v.Data { + res = append(res, data.Embedding) + } + return res, nil +} diff --git a/components/indexer/pinecone/go.mod b/components/indexer/pinecone/go.mod new file mode 100644 index 000000000..543a875a2 --- /dev/null +++ b/components/indexer/pinecone/go.mod @@ -0,0 +1,60 @@ +module github.com/cloudwego/eino-ext/components/indexer/pinecone + +go 1.24.3 + +require ( + github.com/bytedance/mockey v1.2.14 + github.com/bytedance/sonic v1.13.2 + github.com/cloudwego/eino v0.3.40 + github.com/pinecone-io/go-pinecone/v3 v3.1.0 + github.com/smartystreets/goconvey v1.8.1 + google.golang.org/grpc v1.65.0 + google.golang.org/protobuf v1.34.1 +) + +require ( + github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect + github.com/bytedance/sonic/loader v0.2.4 // indirect + github.com/cloudwego/base64x v0.1.5 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect + github.com/getkin/kin-openapi v0.118.0 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/swag v0.19.5 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/goph/emperror v0.17.2 // indirect + github.com/gopherjs/gopherjs v1.17.2 // indirect + github.com/invopop/yaml v0.1.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/jtolds/gls v4.20.0+incompatible // indirect + github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect + github.com/nikolalohinski/gonja v1.5.3 // indirect + github.com/oapi-codegen/runtime v1.1.1 // indirect + github.com/pelletier/go-toml/v2 v2.0.9 // indirect + github.com/perimeterx/marshmallow v1.1.4 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect + github.com/smarty/assertions v1.15.0 // indirect + github.com/stretchr/testify v1.10.0 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/yargevad/filepathx v1.0.0 // indirect + golang.org/x/arch v0.11.0 // indirect + golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect + golang.org/x/net v0.33.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/text v0.22.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect + gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/components/indexer/pinecone/go.sum b/components/indexer/pinecone/go.sum new file mode 100644 index 000000000..5580fb889 --- /dev/null +++ b/components/indexer/pinecone/go.sum @@ -0,0 +1,193 @@ +github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= +github.com/airbrake/gobrake v3.6.1+incompatible/go.mod h1:wM4gu3Cn0W0K7GUuVWnlXZU11AGBXMILnrdOU8Kn00o= +github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= +github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= +github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= +github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= +github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= +github.com/bugsnag/bugsnag-go v1.4.0/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= +github.com/bugsnag/panicwrap v1.2.0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= +github.com/bytedance/mockey v1.2.14 h1:KZaFgPdiUwW+jOWFieo3Lr7INM1P+6adO3hxZhDswY8= +github.com/bytedance/mockey v1.2.14/go.mod h1:1BPHF9sol5R1ud/+0VEHGQq/+i2lN+GTsr3O2Q9IENY= +github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ= +github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY= +github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= +github.com/certifi/gocertifi v0.0.0-20190105021004-abcd57078448/go.mod h1:GJKEexRPVJrBSOjoqN5VNOIKJ5Q3RViH6eu3puDRwx4= +github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= +github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/eino v0.3.40 h1:MiUjwLHZng4PsrzQX1dDns42vSS+/G+vlTqXWaORuGw= +github.com/cloudwego/eino v0.3.40/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/getkin/kin-openapi v0.118.0 h1:z43njxPmJ7TaPpMSCQb7PN0dEYno4tyBPQcrFdHoLuM= +github.com/getkin/kin-openapi v0.118.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc= +github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= +github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJYCFOLkIBwI7xFExG03bbkOkCvUPI= +github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= +github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/goph/emperror v0.17.2 h1:yLapQcmEsO0ipe9p5TaN22djm3OFV/TfM/fcYP0/J18= +github.com/goph/emperror v0.17.2/go.mod h1:+ZbQ+fUNO/6FNiUo0ujtMjhgad9Xa6fQL9KhH4LNHic= +github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g= +github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/invopop/yaml v0.1.0 h1:YW3WGUoJEXYfzWBjn00zIlrw7brGVD0fUKRYDPAPhrc= +github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= +github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= +github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nikolalohinski/gonja v1.5.3 h1:GsA+EEaZDZPGJ8JtpeGN78jidhOlxeJROpqMT9fTj9c= +github.com/nikolalohinski/gonja v1.5.3/go.mod h1:RmjwxNiXAEqcq1HeK5SSMmqFJvKOfTfXhkJv6YBtPa4= +github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro= +github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/pelletier/go-toml/v2 v2.0.9 h1:uH2qQXheeefCCkuBBSLi7jCiSmj3VRh2+Goq2N7Xxu0= +github.com/pelletier/go-toml/v2 v2.0.9/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/perimeterx/marshmallow v1.1.4 h1:pZLDH9RjlLGGorbXhcaQLhfuV0pFMNfPO55FuFkxqLw= +github.com/perimeterx/marshmallow v1.1.4/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= +github.com/pinecone-io/go-pinecone/v3 v3.1.0 h1:JxUK7OXycfqOF+DZbCexT5jKGVA8s5gswZL1wS95zf8= +github.com/pinecone-io/go-pinecone/v3 v3.1.0/go.mod h1:v8VJwwmZFesCP3bIYv98eU/kIpT7v8s0UulNTLWR8c8= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rollbar/rollbar-go v1.0.2/go.mod h1:AcFs5f0I+c71bpHlXNNDbOWJiKwjFDtISeXco0L5PKQ= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f h1:Z2cODYsUxQPofhpYRMQVwWz4yUVpHF+vPi+eUdruUYI= +github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f/go.mod h1:JqzWyvTuI2X4+9wOHmKSQCYxybB/8j6Ko43qVmXDuZg= +github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY= +github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec= +github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY= +github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60= +github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo= +github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= +github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg= +github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE= +github.com/yargevad/filepathx v1.0.0 h1:SYcT+N3tYGi+NvazubCNlvgIPbzAk7i7y2dwg3I5FYc= +github.com/yargevad/filepathx v1.0.0/go.mod h1:BprfX/gpYNJHJfc35GjRRpVcwWXS89gGulUIU5tK3tA= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= +golang.org/x/arch v0.11.0 h1:KXV8WWKCXm6tRpLirl2szsO5j/oOODwZf4hATmGVNs4= +golang.org/x/arch v0.11.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw= +golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= diff --git a/components/indexer/pinecone/indexer.go b/components/indexer/pinecone/indexer.go new file mode 100644 index 000000000..06ca13e52 --- /dev/null +++ b/components/indexer/pinecone/indexer.go @@ -0,0 +1,407 @@ +/* + * Copyright 2025 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pinecone + +import ( + "context" + "fmt" + "sync" + + "github.com/cloudwego/eino/callbacks" + "github.com/cloudwego/eino/components" + "github.com/cloudwego/eino/components/embedding" + "github.com/cloudwego/eino/components/indexer" + "github.com/cloudwego/eino/schema" + "github.com/pinecone-io/go-pinecone/v3/pinecone" + "google.golang.org/protobuf/types/known/structpb" +) + +type IndexerConfig struct { + // Client is the Pinecone client to be called. + // It requires the go-pinecone client. + // Required. + Client *pinecone.Client + + // IndexName is the name of the Pinecone index. + // Optional. Default is "eino-index". + IndexName string + // Cloud specifies the cloud provider where the index is hosted. + // Optional. Default is "aws". + Cloud pinecone.Cloud + // Region specifies the region where the index is hosted. + // Optional. Default is "us-east-1". + Region string + // Metric defines the distance metric used for similarity search in the index. + // e.g., "cosine", "euclidean", "dotproduct". + // Optional. Default is "cosine". + Metric pinecone.IndexMetric + // Dimension is the dimensionality of the vectors to be stored in the index. + // Optional. Default is 2560. + Dimension int32 + // VectorType specifies the type of vectors stored in the index. + // Optional. Default is "float32". Other types might be available based on Pinecone features. + VectorType string + // Namespace is the namespace within the Pinecone index where data will be stored. + // Optional. If not specified, the default namespace is used. + Namespace string + // Field is the field to store content text. + // Optional. If not specified, the default field is used. + Field string + // Tags are metadata tags to be associated with the index. + // Optional. + Tags *pinecone.IndexTags + // DeletionProtection specifies if deletion protection is enabled for the index. + // Optional. Default is typically "disabled". + DeletionProtection pinecone.DeletionProtection + + // DocumentConverter is a function to convert schema.Document and their embeddings + // into Pinecone-specific vector format. + // Optional. If not provided, a default converter will be used. + DocumentConverter func(ctx context.Context, docs []*schema.Document, vectors [][]float64) ([]*pinecone.Vector, error) + + // BatchSize is the number of vectors to include in each batch when upserting data. + // Optional. Default is 100. + BatchSize int + // MaxConcurrency is the maximum number of concurrent goroutines for upserting data. + // Optional. Default is 10. + MaxConcurrency int + + // Embedding is the vectorization method for values that need to be embedded + // from schema.Document's content. + // Required. + Embedding embedding.Embedder +} + +type Indexer struct { + config *IndexerConfig +} + +// NewIndexer creates a new indexer +func NewIndexer(ctx context.Context, conf *IndexerConfig) (*Indexer, error) { + if err := conf.check(); err != nil { + return nil, err + } + + // Create index if it doesn't exist + indexes, err := conf.Client.ListIndexes(ctx) + if err != nil { + return nil, fmt.Errorf("[NewIndexer] failed to list indexes: %w", err) + } + exists := false + for _, index := range indexes { + if index.Name == conf.IndexName { + exists = true + break + } + } + + if !exists { + if _, err := conf.Client.CreateServerlessIndex(ctx, &pinecone.CreateServerlessIndexRequest{ + Name: conf.IndexName, + Cloud: conf.Cloud, + Region: conf.Region, + Metric: &conf.Metric, + DeletionProtection: &conf.DeletionProtection, + Dimension: &conf.Dimension, + VectorType: &conf.VectorType, + Tags: conf.Tags, + }); err != nil { + return nil, fmt.Errorf("[NewIndexer] failed to create index: %w", err) + } + } + + // load index info + index, err := conf.Client.DescribeIndex(ctx, conf.IndexName) + if err != nil { + return nil, fmt.Errorf("[NewIndexer] failed to describe index: %w", err) + } + + // check index schema + if err := validateIndexSchema(index, conf); err != nil { + return nil, fmt.Errorf("[NewIndexer] index schema validation failed: %w", err) + } + + return &Indexer{ + config: conf, + }, nil +} + +// validateIndexSchema checks if the index schema matches the config +func validateIndexSchema(index *pinecone.Index, conf *IndexerConfig) error { + // Check dimension + if index.Dimension != nil && *index.Dimension != conf.Dimension { + return fmt.Errorf("index dimension mismatch: expected %d, got %d", conf.Dimension, *index.Dimension) + } + + // Check metric + if index.Metric != conf.Metric { + return fmt.Errorf("index metric mismatch: expected %s, got %s", conf.Metric, index.Metric) + } + + // Check deletion protection + if index.DeletionProtection != conf.DeletionProtection { + return fmt.Errorf("index deletion protection mismatch: expected %s, got %s", conf.DeletionProtection, index.DeletionProtection) + } + + // Compare tags if provided + if conf.Tags != nil { + for k, v := range *conf.Tags { + if index.Tags != nil && (*index.Tags)[k] != v { + return fmt.Errorf("index tag mismatch for key %s: expected %v, got %v", k, v, (*index.Tags)[k]) + } + } + } + + return nil +} + +// GetType returns the type of the indexer +func (i *Indexer) GetType() string { + return typ +} + +// IsCallbacksEnabled returns whether callbacks are enabled +func (i *Indexer) IsCallbacksEnabled() bool { + return true +} + +// Store stores documents into Pinecone index +func (i *Indexer) Store(ctx context.Context, docs []*schema.Document, opts ...indexer.Option) (ids []string, err error) { + ctx = callbacks.EnsureRunInfo(ctx, i.GetType(), components.ComponentOfIndexer) + ctx = callbacks.OnStart(ctx, &indexer.CallbackInput{Docs: docs}) + defer func() { + if err != nil { + callbacks.OnError(ctx, err) + } + }() + + options := indexer.GetCommonOptions(&indexer.Options{ + Embedding: i.config.Embedding, + }, opts...) + + if options.Embedding == nil { + return nil, fmt.Errorf("[Store] embedding not provided") + } + + // insert documents to index + if err := i.insert(ctx, docs, options); err != nil { + return nil, fmt.Errorf("[Store] failed to insert document: %w", err) + } + + ids = make([]string, 0, len(docs)) + for _, doc := range docs { + ids = append(ids, doc.ID) + } + + callbacks.OnEnd(ctx, &indexer.CallbackOutput{IDs: ids}) + + return ids, nil +} + +func (i *Indexer) insert(ctx context.Context, docs []*schema.Document, options *indexer.Options) error { + // load docs content + texts := make([]string, 0, len(docs)) + for _, doc := range docs { + texts = append(texts, doc.Content) + } + + // embedding docs + embedder := options.Embedding + if embedder == nil { + return fmt.Errorf("[insert] embedding not provided") + } + + vectors, err := embedder.EmbedStrings(makeEmbeddingCtx(ctx, embedder), texts) + if err != nil { + return err + } + + if len(vectors) != len(docs) { + return fmt.Errorf("[insert] number of documents mismatch: expected %d, got %d", len(docs), len(vectors)) + } + + // prepare pinecone vectors + pcVectors, err := i.config.DocumentConverter(ctx, docs, vectors) + if err != nil { + return err + } + + // parallel insert pinecone vectors + if err := i.parallelInsert(ctx, pcVectors); err != nil { + return err + } + + return nil +} + +func (i *Indexer) parallelInsert(ctx context.Context, vectors []*pinecone.Vector) error { + // get index connection + index, err := i.config.Client.DescribeIndex(ctx, i.config.IndexName) + if err != nil { + return fmt.Errorf("[Parallel] failed to describe index: %w", err) + } + indexConn, err := i.config.Client.Index(pinecone.NewIndexConnParams{ + Host: index.Host, + Namespace: i.config.Namespace, + }) + if err != nil { + return fmt.Errorf("[Parallel] failed to connect to index: %w", err) + } + + batchSize := i.config.BatchSize + batchNum := (len(vectors)-1)/batchSize + 1 + + // make vectors into batches + batches := make([][]*pinecone.Vector, 0, batchNum) + for batchId := 0; batchId < batchNum; batchId++ { + start := batchId * i.config.BatchSize + end := start + batchSize + if end > len(vectors) { + end = len(vectors) + } + + batch := vectors[start:end] + batches = append(batches, batch) + } + + // parallel add + errChan := make(chan error, len(vectors)) + semaphore := make(chan struct{}, i.config.MaxConcurrency) + var wg sync.WaitGroup + + for i, batch := range batches { + wg.Add(1) + semaphore <- struct{}{} + + go func(batch []*pinecone.Vector) { + defer func() { + <-semaphore + wg.Done() + }() + + _, err := indexConn.UpsertVectors(ctx, batch) + if err != nil { + errChan <- fmt.Errorf("batch %d failed: %v", i, err) + } + }(batch) + } + + wg.Wait() + close(errChan) + + for err := range errChan { + if err != nil { + return fmt.Errorf("[Parallel] failed to insert documents: %w", err) + } + } + return nil +} + +func (ic *IndexerConfig) getDefaultDocumentConvert() func(ctx context.Context, docs []*schema.Document, vectors [][]float64) ([]*pinecone.Vector, error) { + return func(ctx context.Context, docs []*schema.Document, vectors [][]float64) ([]*pinecone.Vector, error) { + if len(docs) != len(vectors) { + return nil, fmt.Errorf("docs count mismatch: expected %d, got %d", len(vectors), len(docs)) + } + + pcVectors := make([]*pinecone.Vector, 0, len(docs)) + for i, doc := range docs { + // check vector dimension + if len(vectors[i]) != int(ic.Dimension) { + return nil, fmt.Errorf("vector dimension mismatch: expected %d, got %d", ic.Dimension, len(vectors[i])) + } + + // convert float64 to float32 + values := make([]float32, 0, len(vectors[i])) + for _, v := range vectors[i] { + values = append(values, float32(v)) + } + + // convert document metadata to pinecone metadata + meta := make(map[string]any) + if doc.MetaData != nil { + for k, v := range doc.MetaData { + meta[k] = v + } + } + meta[ic.Field] = doc.Content + metadata, err := structpb.NewStruct(meta) + if err != nil { + return nil, fmt.Errorf("[getDefaultDocumentConvert] failed to convert metadata: %w", err) + } + + pcVector := &pinecone.Vector{ + Id: doc.ID, + Values: &values, + Metadata: metadata, + } + + pcVectors = append(pcVectors, pcVector) + } + + return pcVectors, nil + } +} + +// check the indexer config +func (ic *IndexerConfig) check() error { + if ic.Client == nil { + return fmt.Errorf("[NewIndexer] pinecone client not provided") + } + if ic.Embedding == nil { + return fmt.Errorf("[NewIndexer] embedding not provided") + } + if ic.Dimension < 0 { + return fmt.Errorf("[NewIndexer] dimension must be positive") + } + if ic.IndexName == "" { + ic.IndexName = defaultIndexName + } + if ic.Cloud == "" { + ic.Cloud = defaultCloud + } + if ic.Region == "" { + ic.Region = defaultRegion + } + if ic.VectorType == "" { + ic.VectorType = defaultVectorType + } + if ic.Dimension == 0 { + ic.Dimension = defaultDimension + } + if ic.Metric == "" { + ic.Metric = defaultMetric + } + if ic.DeletionProtection == "" { + ic.DeletionProtection = defaultDeletionProtection + } + if ic.MaxConcurrency <= 0 { + ic.MaxConcurrency = defaultMaxConcurrency + } + if ic.BatchSize <= 0 { + ic.BatchSize = defaultBatchSize + } + if ic.Namespace == "" { + ic.Namespace = defaultNamespace + } + if ic.Field == "" { + ic.Field = defaultField + } + if ic.DocumentConverter == nil { + ic.DocumentConverter = ic.getDefaultDocumentConvert() + } + return nil +} diff --git a/components/indexer/pinecone/indexer_test.go b/components/indexer/pinecone/indexer_test.go new file mode 100644 index 000000000..48551efa4 --- /dev/null +++ b/components/indexer/pinecone/indexer_test.go @@ -0,0 +1,336 @@ +/* + * Copyright 2025 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pinecone + +import ( + "context" + "fmt" + "github.com/cloudwego/eino/schema" + "google.golang.org/grpc" + "testing" + + . "github.com/bytedance/mockey" + "github.com/cloudwego/eino/components/embedding" + pc "github.com/pinecone-io/go-pinecone/v3/pinecone" + "github.com/smartystreets/goconvey/convey" +) + +type mockEmbedding struct{} + +func (m *mockEmbedding) EmbedStrings(ctx context.Context, texts []string, opts ...embedding.Option) ([][]float64, error) { + result := make([][]float64, len(texts)) + for i := range texts { + result[i] = []float64{0.1, 0.2, 0.3, 0.4} + } + return result, nil +} + +func TestNewIndexer(t *testing.T) { + PatchConvey("test NewIndexer", t, func() { + ctx := context.Background() + Mock(pc.NewClient).Return(&pc.Client{}, nil).Build() + + mockClient, _ := pc.NewClient(pc.NewClientParams{}) + mockEmb := &mockEmbedding{} + mockDim := defaultDimension + + PatchConvey("test indexer config check", func() { + PatchConvey("test client not provided", func() { + indexer, err := NewIndexer(ctx, &IndexerConfig{ + Client: nil, + Embedding: mockEmb, + }) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewIndexer] pinecone client not provided")) + convey.So(indexer, convey.ShouldBeNil) + }) + + PatchConvey("test embedding not provided", func() { + indexer, err := NewIndexer(ctx, &IndexerConfig{ + Client: mockClient, + Embedding: nil, + }) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewIndexer] embedding not provided")) + convey.So(indexer, convey.ShouldBeNil) + }) + + PatchConvey("test dimension must be positive", func() { + indexer, err := NewIndexer(ctx, &IndexerConfig{ + Client: mockClient, + Embedding: mockEmb, + Dimension: -1, + }) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewIndexer] dimension must be positive")) + convey.So(indexer, convey.ShouldBeNil) + }) + }) + + PatchConvey("test create index pre-check", func() { + Mock(GetMethod(mockClient, "ListIndexes")).To(func(ctx context.Context) ([]*pc.Index, error) { + list := make([]*pc.Index, 0) + list = append(list, &pc.Index{ + Name: defaultIndexName, + Metric: defaultMetric, + VectorType: defaultVectorType, + DeletionProtection: defaultDeletionProtection, + Dimension: &mockDim, + }) + return list, nil + }).Build() + + PatchConvey("test create index failed", func() { + Mock(GetMethod(mockClient, "CreateServerlessIndex")).To(func(ctx context.Context, in *pc.CreateServerlessIndexRequest) (*pc.Index, error) { + return nil, fmt.Errorf("[CreateServerlessIndex] mock failed") + }).Build() + + indexer, err := NewIndexer(ctx, &IndexerConfig{ + Client: mockClient, + Embedding: mockEmb, + IndexName: "test-create", + }) + + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewIndexer] failed to create index: [CreateServerlessIndex] mock failed")) + convey.So(indexer, convey.ShouldBeNil) + }) + + PatchConvey("test validate index failed", func() { + mockIndex := &pc.Index{ + Name: "test-validate", + Metric: defaultMetric, + VectorType: defaultVectorType, + DeletionProtection: defaultDeletionProtection, + Dimension: &mockDim, + Tags: &pc.IndexTags{ + "mockTag": "mockValue", + }, + } + + Mock(GetMethod(mockClient, "CreateServerlessIndex")).To(func(ctx context.Context, in *pc.CreateServerlessIndexRequest) (*pc.Index, error) { + return mockIndex, nil + }).Build() + + Mock(GetMethod(mockClient, "DescribeIndex")).To(func(ctx context.Context, idxName string) (*pc.Index, error) { + return mockIndex, nil + }).Build() + + PatchConvey("test describe index failed", func() { + Mock(GetMethod(mockClient, "DescribeIndex")).To(func(ctx context.Context, idxName string) (*pc.Index, error) { + return nil, fmt.Errorf("[DescribeIndex] mock failed") + }).Build() + + indexer, err := NewIndexer(ctx, &IndexerConfig{ + Client: mockClient, + Embedding: mockEmb, + IndexName: "test-describe", + }) + + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewIndexer] failed to describe index: [DescribeIndex] mock failed")) + convey.So(indexer, convey.ShouldBeNil) + }) + + PatchConvey("test validate index dimension", func() { + otherDim := defaultDimension + 1 + indexer, err := NewIndexer(ctx, &IndexerConfig{ + Client: mockClient, + Embedding: mockEmb, + IndexName: "test-validate", + Dimension: otherDim, + }) + + expectedErr := fmt.Errorf("index dimension mismatch: expected %d, got %d", otherDim, mockDim) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewIndexer] index schema validation failed: %w", expectedErr)) + convey.So(indexer, convey.ShouldBeNil) + }) + + PatchConvey("test validate index metric", func() { + otherMetric := pc.Euclidean + indexer, err := NewIndexer(ctx, &IndexerConfig{ + Client: mockClient, + Embedding: mockEmb, + IndexName: "test-validate", + Metric: otherMetric, + }) + + expectedErr := fmt.Errorf("index metric mismatch: expected %s, got %s", otherMetric, defaultMetric) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewIndexer] index schema validation failed: %w", expectedErr)) + convey.So(indexer, convey.ShouldBeNil) + }) + + PatchConvey("test validate index deletion protection", func() { + otherDeletionProtection := pc.DeletionProtectionEnabled + indexer, err := NewIndexer(ctx, &IndexerConfig{ + Client: mockClient, + Embedding: mockEmb, + IndexName: "test-validate", + DeletionProtection: otherDeletionProtection, + }) + + expectedErr := fmt.Errorf("index deletion protection mismatch: expected %s, got %s", otherDeletionProtection, defaultDeletionProtection) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewIndexer] index schema validation failed: %w", expectedErr)) + convey.So(indexer, convey.ShouldBeNil) + }) + + PatchConvey("test validate index tags", func() { + otherTags := &pc.IndexTags{ + "mockTag": "failedValue", + } + indexer, err := NewIndexer(ctx, &IndexerConfig{ + Client: mockClient, + Embedding: mockEmb, + IndexName: "test-validate", + Tags: otherTags, + }) + + expectedErr := fmt.Errorf("index tag mismatch for key mockTag: expected failedValue, got mockValue") + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewIndexer] index schema validation failed: %w", expectedErr)) + convey.So(indexer, convey.ShouldBeNil) + }) + + }) + }) + }) +} + +func TestIndexerStore(t *testing.T) { + PatchConvey("test Indexer.Store", t, func() { + ctx := context.Background() + Mock(pc.NewClient).Return(&pc.Client{}, nil).Build() + + mockClient, _ := pc.NewClient(pc.NewClientParams{}) + mockDim := int32(4) + mockName := "test-store" + mockIndex := &pc.Index{ + Name: mockName, + Metric: defaultMetric, + VectorType: defaultVectorType, + DeletionProtection: defaultDeletionProtection, + Dimension: &mockDim, + Tags: &pc.IndexTags{ + "mockTag": "mockValue", + }, + } + mockEmb := &mockEmbedding{} + mockDocs := []*schema.Document{ + { + ID: "doc1", + Content: "This is a test document", + MetaData: map[string]interface{}{"key": "value"}, + }, + { + ID: "doc2", + Content: "This is another test document", + MetaData: map[string]interface{}{"key2": "value2"}, + }, + } + + Mock(GetMethod(mockClient, "ListIndexes")).To(func(ctx context.Context) ([]*pc.Index, error) { + list := make([]*pc.Index, 0) + list = append(list, &pc.Index{ + Name: defaultIndexName, + Metric: defaultMetric, + VectorType: defaultVectorType, + DeletionProtection: defaultDeletionProtection, + Dimension: &mockDim, + }) + return list, nil + }).Build() + Mock(GetMethod(mockClient, "CreateServerlessIndex")).To(func(ctx context.Context, in *pc.CreateServerlessIndexRequest) (*pc.Index, error) { + return mockIndex, nil + }).Build() + + Mock(GetMethod(mockClient, "DescribeIndex")).To(func(ctx context.Context, idxName string) (*pc.Index, error) { + if idxName == mockName { + return mockIndex, nil + } else { + return nil, fmt.Errorf("mockDescribeIndex not found index: %s", idxName) + } + }).Build() + + PatchConvey("test store index embedding is nil", func() { + indexer, err := NewIndexer(ctx, &IndexerConfig{ + Client: mockClient, + IndexName: mockName, + Embedding: mockEmb, + Dimension: mockDim, + }) + convey.So(err, convey.ShouldBeNil) + convey.So(indexer, convey.ShouldNotBeNil) + + indexer.config.Embedding = nil + + ids, err := indexer.Store(ctx, mockDocs) + + convey.So(err, convey.ShouldBeError, fmt.Errorf("[Store] embedding not provided")) + convey.So(ids, convey.ShouldBeNil) + }) + + PatchConvey("test store with insert error", func() { + indexer, err := NewIndexer(ctx, &IndexerConfig{ + Client: mockClient, + Embedding: mockEmb, + IndexName: mockName, + Dimension: mockDim, + }) + convey.So(err, convey.ShouldBeNil) + convey.So(indexer, convey.ShouldNotBeNil) + + mockIndexConn := &pc.IndexConnection{Namespace: indexer.config.Namespace} + + Mock(GetMethod(mockClient, "Index")).To(func(in pc.NewIndexConnParams, dialOpts ...grpc.DialOption) (*pc.IndexConnection, error) { + return mockIndexConn, nil + }).Build() + + Mock(GetMethod(mockIndexConn, "UpsertVectors")).To(func(ctx context.Context, in []*pc.Vector) (uint32, error) { + return 0, fmt.Errorf("mock upsert error") + }).Build() + + ids, err := indexer.Store(ctx, mockDocs) + + convey.So(err, convey.ShouldBeError, fmt.Errorf("[Store] failed to insert document: [Parallel] failed to insert documents: batch 0 failed: mock upsert error")) + convey.So(ids, convey.ShouldBeEmpty) + }) + + PatchConvey("test store index success", func() { + indexer, err := NewIndexer(ctx, &IndexerConfig{ + Client: mockClient, + Embedding: mockEmb, + IndexName: mockName, + Dimension: mockDim, + }) + convey.So(err, convey.ShouldBeNil) + convey.So(indexer, convey.ShouldNotBeNil) + + mockIndexConn := &pc.IndexConnection{Namespace: indexer.config.Namespace} + + Mock(GetMethod(mockClient, "Index")).To(func(in pc.NewIndexConnParams, dialOpts ...grpc.DialOption) (*pc.IndexConnection, error) { + return mockIndexConn, nil + }).Build() + + Mock(GetMethod(mockIndexConn, "UpsertVectors")).To(func(ctx context.Context, in []*pc.Vector) (uint32, error) { + return uint32(len(in)), nil + }).Build() + + ids, err := indexer.Store(ctx, mockDocs) + + expectedIds := make([]string, 0, len(mockDocs)) + for _, doc := range mockDocs { + expectedIds = append(expectedIds, doc.ID) + } + convey.So(err, convey.ShouldBeNil) + convey.So(ids, convey.ShouldResemble, expectedIds) + }) + }) +} diff --git a/components/indexer/pinecone/utils.go b/components/indexer/pinecone/utils.go new file mode 100644 index 000000000..4a34ce28d --- /dev/null +++ b/components/indexer/pinecone/utils.go @@ -0,0 +1,38 @@ +/* + * Copyright 2025 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pinecone + +import ( + "context" + "github.com/cloudwego/eino/callbacks" + "github.com/cloudwego/eino/components" + "github.com/cloudwego/eino/components/embedding" +) + +func makeEmbeddingCtx(ctx context.Context, embedder embedding.Embedder) context.Context { + runInfo := &callbacks.RunInfo{ + Component: components.ComponentOfEmbedding, + } + + if embedderType, ok := components.GetType(embedder); ok { + runInfo.Type = embedderType + } + + runInfo.Name = runInfo.Type + string(runInfo.Component) + + return callbacks.ReuseHandlers(ctx, runInfo) +} diff --git a/components/retriever/pinecone/README.md b/components/retriever/pinecone/README.md new file mode 100644 index 000000000..1e43b157e --- /dev/null +++ b/components/retriever/pinecone/README.md @@ -0,0 +1,123 @@ +# Pinecone Search + +[English](README.md) | [简体中文](README_zh.md) + +This is a Pinecone-based vector search implementation that provides a storage solution compatible with the `Retriever` interface for [Eino](https://github.com/cloudwego/eino). The component can be seamlessly integrated into Eino's vector storage and retrieval system to enhance semantic search capabilities. + +## Quick Start + +### Installation + +Requires pinecone-io/go-pinecone/v3 client version 3.x.x + +```bash +go get github.com/eino-project/eino/retriever/pinecone@latest +``` + +### Create a Pinecone Retriever + +```go +package main + +import ( + "context" + "fmt" + "log" + "os" + + "github.com/bytedance/sonic" + "github.com/cloudwego/eino-ext/components/retriever/pinecone" + "github.com/cloudwego/eino/components/embedding" + pc "github.com/pinecone-io/go-pinecone/v3/pinecone" +) + +func main() { + // Load configuration from environment variables + apiKey := os.Getenv("PINECONE_APIKEY") + if apiKey == "" { + log.Fatal("PINECONE_APIKEY environment variable is required") + } + + // Initialize Pinecone client + client, err := pc.NewClient(pc.NewClientParams{ + ApiKey: apiKey, + }) + if err != nil { + log.Fatalf("Failed to create Pinecone client: %v", err) + } + + // Create Pinecone retriever config + config := pinecone.RetrieverConfig{ + Client: client, + Embedding: &mockEmbedding{}, + } + + ctx := context.Background() + retriever, err := pinecone.NewRetriever(ctx, &config) + if err != nil { + log.Fatalf("Failed to create Pinecone retriever: %v", err) + } + log.Println("Retriever created successfully") + + // Retrieve documents + documents, err := retriever.Retrieve(ctx, "pinecone") + if err != nil { + log.Fatalf("Failed to retrieve: %v", err) + return + } + + // Print the documents + for i, doc := range documents { + fmt.Printf("Document %d:\n", i) + fmt.Printf("title: %s\n", doc.ID) + fmt.Printf("content: %s\n", doc.Content) + fmt.Printf("metadata: %v\n", doc.MetaData) + } +} +``` + +## 配置 + +```go +type RetrieverConfig struct { + // Client is the Pinecone client instance used for all API operations. + // Required. Must be initialized before use. + Client *pc.Client + + // IndexName is the name of the Pinecone index to search against. + // Optional. Default is "eino-index". + IndexName string + + // Namespace is the logical namespace within the index, used for multi-tenant or data isolation scenarios. + // Optional. Default is "". + Namespace string + + // MetricType specifies the similarity metric used for vector search (e.g., cosine, dotproduct, euclidean). + // Optional. Default is pc.IndexMetricCosine. + MetricType pc.IndexMetric + + // Field specifies the document field to associate with vector data, used for mapping between Pinecone vectors and application documents. + // Optional. Default is "". Set if you want to map a specific document field. + Field string + + // VectorConverter is a function to convert float64 vectors (from embedding models) to float32 as required by Pinecone API. + // Optional. If nil, a default conversion will be used. + VectorConverter func(ctx context.Context, vector []float64) ([]float32, error) + + // DocumentConverter is a function to convert Pinecone vector results to schema.Document objects for downstream consumption. + // Optional. If nil, a default converter will be used. + DocumentConverter func(ctx context.Context, vector *pc.Vector, field string) (*schema.Document, error) + + // TopK specifies the number of top results to return for each query. + // Optional. Default is 10. + TopK int + + // ScoreThreshold is the minimum similarity score for a result to be returned. + // Optional. Default is 0. Used to filter out low-relevance matches. + ScoreThreshold float64 + + // Embedding is the embedding model or service used to convert queries into vector representations. + // Required for semantic search. + Embedding embedding.Embedder +} +``` \ No newline at end of file diff --git a/components/retriever/pinecone/README_zh.md b/components/retriever/pinecone/README_zh.md new file mode 100644 index 000000000..888bbaa09 --- /dev/null +++ b/components/retriever/pinecone/README_zh.md @@ -0,0 +1,124 @@ +# Pinecone 搜索 + +[English](README.md) | [简体中文](README_zh.md) + +基于 Pinecone 的向量搜索实现,为 [Eino](https://github.com/cloudwego/eino) 提供了符合 `Retriever` 接口的存储方案。该组件可无缝集成 +Eino 的向量存储和检索系统,增强语义搜索能力。 + +## 快速开始 + +### 安装 + +它需要 pinecone-io/go-pinecone/v3 客户端版本 3.x.x + +```bash +go get github.com/eino-project/eino/retriever/pinecone@latest +``` + +### 创建 Pinecone 搜索 + +```go +package main + +import ( + "context" + "fmt" + "log" + "os" + + "github.com/bytedance/sonic" + "github.com/cloudwego/eino-ext/components/retriever/pinecone" + "github.com/cloudwego/eino/components/embedding" + pc "github.com/pinecone-io/go-pinecone/v3/pinecone" +) + +func main() { + // Load configuration from environment variables + apiKey := os.Getenv("PINECONE_APIKEY") + if apiKey == "" { + log.Fatal("PINECONE_APIKEY environment variable is required") + } + + // Initialize Pinecone client + client, err := pc.NewClient(pc.NewClientParams{ + ApiKey: apiKey, + }) + if err != nil { + log.Fatalf("Failed to create Pinecone client: %v", err) + } + + // Create Pinecone retriever config + config := pinecone.RetrieverConfig{ + Client: client, + Embedding: &mockEmbedding{}, + } + + ctx := context.Background() + retriever, err := pinecone.NewRetriever(ctx, &config) + if err != nil { + log.Fatalf("Failed to create Pinecone retriever: %v", err) + } + log.Println("Retriever created successfully") + + // Retrieve documents + documents, err := retriever.Retrieve(ctx, "pinecone") + if err != nil { + log.Fatalf("Failed to retrieve: %v", err) + return + } + + // Print the documents + for i, doc := range documents { + fmt.Printf("Document %d:\n", i) + fmt.Printf("title: %s\n", doc.ID) + fmt.Printf("content: %s\n", doc.Content) + fmt.Printf("metadata: %v\n", doc.MetaData) + } +} +``` + +## 配置 + +```go +type RetrieverConfig struct { + // Pinecone 客户端实例,用于所有 API 操作。 + // 必填,需提前初始化。 + Client *pc.Client + + // Pinecone 索引名称。 + // 可选,默认值为 "eino-index"。 + IndexName string + + // Pinecone 命名空间,用于多租户或数据隔离场景。 + // 可选,默认值为 ""(默认命名空间)。 + Namespace string + + // 相似度度量方式(如 cosine、dotproduct、euclidean)。 + // 可选,默认值为 pc.IndexMetricCosine。 + MetricType pc.IndexMetric + + // 文档字段名,用于将 Pinecone 向量与应用文档字段映射。 + // 可选,默认值为 "",如需映射特定字段可设置。 + Field string + + // 向量转换函数,将 embedding 生成的 float64 向量转换为 Pinecone 所需的 float32。 + // 可选,若为 nil 则使用默认转换。 + VectorConverter func(ctx context.Context, vector []float64) ([]float32, error) + + // 结果转换函数,将 Pinecone 检索结果转换为 schema.Document 对象。 + // 可选,若为 nil 则使用默认转换。 + DocumentConverter func(ctx context.Context, vector *pc.Vector, field string) (*schema.Document, error) + + // 返回每次查询的 TopK 结果数。 + // 可选,默认值为 10。 + TopK int + + // 相似度分数阈值,低于该分数的结果将被过滤。 + // 可选,默认值为 0。 + ScoreThreshold float64 + + // 向量化模型或服务,用于将查询转换为向量表示。 + // 语义检索必填。 + Embedding embedding.Embedder +} +``` \ No newline at end of file diff --git a/components/retriever/pinecone/consts.go b/components/retriever/pinecone/consts.go new file mode 100644 index 000000000..d53c7b573 --- /dev/null +++ b/components/retriever/pinecone/consts.go @@ -0,0 +1,30 @@ +/* + * Copyright 2025 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pinecone + +import pc "github.com/pinecone-io/go-pinecone/v3/pinecone" + +const ( + typ = "pinecone" + + defaultIndexName = "eino-index" + defaultNamespace = "eino_space" + defaultField = "__content__" + defaultMetricType = pc.Cosine + + defaulttopK = 5 +) diff --git a/components/retriever/pinecone/examples/embeddings.json b/components/retriever/pinecone/examples/embeddings.json new file mode 100644 index 000000000..9c3457b1d --- /dev/null +++ b/components/retriever/pinecone/examples/embeddings.json @@ -0,0 +1,2568 @@ +{ + "data": [ + { + "embedding": [ + -1.6484375, + -2.609375, + -2.65625, + -3.453125, + -2.921875, + 1.796875, + -0.90234375, + -4.3125, + -0.8203125, + 2.53125, + 2.1875, + 1.0390625, + 3.21875, + -0.36132812, + 0.6796875, + 2.21875, + -0.33398438, + -0.86328125, + -0.85546875, + -2.453125, + 1.296875, + 6.6875, + 6.625, + -5.59375, + 2.0625, + -6.34375, + 3.34375, + 4.15625, + 2.1875, + 1.03125, + 5.46875, + -2.15625, + 2.9375, + 0.2265625, + 2.46875, + -1.8203125, + -4.21875, + -0.14257812, + 4.59375, + -0.083984375, + -6.03125, + -1.0625, + -0.91015625, + 6.09375, + -2.75, + 2.140625, + 1.4375, + -1.0390625, + -2.828125, + -4.34375, + -0.44140625, + -4.09375, + 4.03125, + -4.53125, + 5, + -2.796875, + -5.6875, + 4.875, + -7.84375, + -3.890625, + 2.921875, + -1.546875, + -0.079589844, + -0.18261719, + 2.1875, + 7.65625, + -0.06591797, + -1.2265625, + 1.1171875, + 5.71875, + -1.375, + 1.9765625, + 6.6875, + -2.109375, + 7.25, + 7.46875, + 4.09375, + 1.3828125, + -2.46875, + 3.796875, + -4.03125, + -2.015625, + 6.5, + 2.90625, + 4.78125, + 3.171875, + -2.203125, + 2.03125, + -3.609375, + 3.03125, + 2.890625, + 1.671875, + -2.21875, + -1.75, + 1.5625, + 3.25, + -3.5, + -5.3125, + -3.28125, + -1.0234375, + -1.9296875, + -3.84375, + 1.5, + -6.15625, + -6.65625, + 0.71875, + -1.7734375, + -3.421875, + -0.84375, + -2.96875, + 0.8828125, + 0.98046875, + 3.421875, + -1.8125, + 3.390625, + -0.100097656, + 3.65625, + -4.875, + -5.34375, + 0.104003906, + -0.8671875, + 1.4140625, + 4.28125, + -2.640625, + 1.9453125, + 2.625, + -0.85546875, + 0.61328125, + 5.3125, + -0.890625, + 6.1875, + 3.3125, + 2.5, + -2.6875, + -6.9375, + -2.59375, + -3.28125, + 5.46875, + 2.5625, + 1.703125, + -6.53125, + 2.140625, + -5.0625, + -7.28125, + 3.578125, + 0.111328125, + -7.375, + -2.21875, + 3.859375, + -1.34375, + -0.15234375, + 3.09375, + 1.609375, + 3.03125, + -1, + -5.125, + 5.09375, + 2.453125, + 1.078125, + -2.625, + 0.3125, + 2.265625, + 1.90625, + 0.4765625, + -0.05029297, + -2.21875, + -6.59375, + 3.15625, + 1.21875, + 0.80078125, + -0.9140625, + 8.75, + 3.328125, + -3.65625, + 1.5546875, + 3.25, + -1.6640625, + 8.6875, + 3.640625, + 0.114746094, + 1.5390625, + 0.08544922, + -0.092285156, + 4.75, + -2.421875, + 1.5546875, + -1.2578125, + -6.03125, + 3.09375, + -1.265625, + 1.40625, + 2.59375, + -0.56640625, + -2.03125, + -8.375, + -2.75, + 3.859375, + 0.015991211, + 2.546875, + 0.51171875, + -3.1875, + -8.5625, + 1.40625, + 0.46484375, + -4.40625, + -2.875, + 2.171875, + -2.890625, + 1.0625, + -0.92578125, + 0.73828125, + -0.14941406, + 1.0703125, + -1.3828125, + 8.0625, + 3.09375, + 2.4375, + -0.91796875, + 3.6875, + 2.453125, + 5.3125, + 2.15625, + -0.057861328, + -2.796875, + 2.921875, + 4.71875, + 3.90625, + 3.640625, + 0.107910156, + 7.375, + -1.4921875, + 1.625, + 5.4375, + -1.4921875, + -2.03125, + -2.84375, + -6.875, + 0.9453125, + -0.12451172, + 3.125, + -3.828125, + -7.34375, + -0.33984375, + 2.28125, + 1.9453125, + -0.47460938, + -3.359375, + -2.34375, + -2.328125, + -6.3125, + -0.33398438, + 2.65625, + -3.75, + -0.04638672, + 7.21875, + 1.6015625, + 0.47851562, + 5, + -0.107421875, + -2.890625, + 1.125, + -6.09375, + -3.203125, + 2.28125, + 2.03125, + 2.46875, + 5.59375, + 0.21386719, + 4.4375, + 2.6875, + 6.71875, + -5.4375, + -1.65625, + -1.109375, + -3.15625, + 7, + 0.19238281, + -4.40625, + 4.6875, + -4.1875, + -3.6875, + -7.375, + 2.90625, + -1.7421875, + 2.8125, + -2.125, + 0.89453125, + 2.953125, + -2.109375, + 11, + 5.5, + -0.9765625, + 1.1484375, + -2.296875, + -1.703125, + -0.9765625, + -0.91796875, + 0.97265625, + -3.90625, + 0.40234375, + 6.5, + 4.09375, + 0.390625, + 2.21875, + -1.5703125, + -0.84375, + -2.171875, + -3.734375, + 1.03125, + 4.15625, + 0.16503906, + 3.078125, + 7.75, + -2.96875, + 2.40625, + -5.03125, + -5.4375, + 4.8125, + -0.7578125, + -1.4609375, + -0.38476562, + -5.59375, + -1.6171875, + -3.390625, + -1.1015625, + -6.9375, + 1.5234375, + -0.74609375, + 4.90625, + 1.921875, + 1.5, + 3, + -6.03125, + -4.21875, + 9.8125, + -0.5234375, + 2.046875, + 3.765625, + 0.24511719, + 2.15625, + -2.453125, + -5.28125, + 1.9140625, + -6, + -1.2421875, + 4.34375, + 3.421875, + -0.70703125, + 3.90625, + -6.1875, + 2.671875, + 1.53125, + -2.03125, + 5.90625, + 6.5625, + -0.484375, + 1.359375, + -0.15039062, + -1.046875, + -2.859375, + 2.859375, + -0.9375, + 5.21875, + -0.66796875, + -4.125, + -4.78125, + -1.7578125, + 5.5, + -1.328125, + -1.203125, + -0.52734375, + -5.0625, + 3.578125, + 0.4140625, + 4.09375, + -3.390625, + -0.12695312, + -0.12792969, + -4.1875, + 0.734375, + 0.1953125, + 1.3671875, + -1.3359375, + -2.171875, + 3.890625, + 0.87890625, + -3.65625, + 3.390625, + 0.53515625, + -3.359375, + 0.036376953, + 0.037597656, + -2.25, + -1.609375, + 3.375, + 0.05810547, + -0.92578125, + 4.03125, + -1.6875, + 0.3046875, + 1.84375, + -1.7421875, + 0.65625, + -2.921875, + -1.1796875, + -1.6171875, + -0.89453125, + -7.46875, + 3, + 3.046875, + -3.375, + -0.7578125, + 3.625, + -3.609375, + -3.59375, + 4.90625, + -1.703125, + 2.96875, + -6.6875, + 1.546875, + -1.4765625, + 0.66796875, + 2.40625, + -1.0390625, + 1.0390625, + -0.13574219, + 0.93359375, + 6.1875, + 2.03125, + 4.59375, + 2.453125, + 1.5546875, + -4.75, + -3.1875, + 0.51171875, + -5.75, + 3.84375, + -2.859375, + -4.5625, + 3.234375, + 3.84375, + -2.171875, + 3.84375, + 2.765625, + -7.09375, + -3.390625, + 0.671875, + 5.5625, + -2.640625, + -0.45898438, + 1.2421875, + -1.25, + -2.34375, + 1.4140625, + 2.921875, + -1.09375, + -3.453125, + 3.84375, + 4.78125, + 0.83984375, + -2.1875, + 0.35351562, + -0.84375, + 2.984375, + 1.296875, + -5.25, + -2.03125, + 1, + 4.4375, + -7.96875, + -6.8125, + -0.012268066, + -1.828125, + -0.8671875, + 1.75, + 4, + 0.099121094, + -2.78125, + -3.125, + -5.40625, + -1.875, + -6.375, + 2.71875, + 0.48046875, + -3.40625, + -5.59375, + 1.4375, + 6.59375, + 1.5859375, + 0.7734375, + -2.96875, + -1.0078125, + 6, + -2.265625, + 2.734375, + 3.4375, + 7.8125, + -2.234375, + -2.671875, + 0.421875, + -7.5625, + 0.7109375, + -4.03125, + -2.828125, + -2.609375, + -0.96484375, + 3.171875, + -5.625, + 0.4609375, + -2.09375, + 3.90625, + -0.44140625, + -3.15625, + 2.40625, + -5.3125, + -7.4375, + -0.78125, + 0.6953125, + 2.609375, + 0.6875, + -2.953125, + 3.390625, + 3.5, + -0.8828125, + -0.8359375, + -3.78125, + -2.921875, + -3.796875, + 0.61328125, + 3.515625, + 1.2109375, + 4.65625, + 1.0625, + -6.0625, + -1.0234375, + -3.78125, + -1.8671875, + -2.265625, + 0.059570312, + 3.453125, + 2.359375, + -0.96484375, + -3.75, + -0.53515625, + 2.421875, + -0.099609375, + -0.068359375, + -0.22460938, + 3.96875, + -1.0703125, + -0.85546875, + 1.7890625, + 4.625, + -0.34570312, + 0.60546875, + -4.1875, + -4.21875, + -2.25, + -2.328125, + -0.67578125, + -0.76953125, + -6.09375, + 1.2109375, + 5.90625, + 1.4609375, + -1.7734375, + 3.21875, + 2.09375, + 2.671875, + 1.5546875, + 0.70703125, + 3.9375, + -3.328125, + -2.875, + -2.28125, + 4.03125, + -7.75, + -4.84375, + -2.71875, + 5.625, + 3.640625, + -3.015625, + 3.21875, + -1.8984375, + 1.40625, + 1.4765625, + 0.65234375, + -10.875, + 4.25, + -2.34375, + -4.40625, + -3.890625, + -0.9921875, + 1.6640625, + -1.703125, + -1.984375, + 1.171875, + -1.7890625, + 1.9765625, + 7.6875, + -1.984375, + -0.83984375, + 6.1875, + 0.33203125, + -2.40625, + 4.375, + -1.7890625, + -3.96875, + 1.9609375, + -2.640625, + -0.21484375, + 2.5, + 2.921875, + -2.390625, + -0.6015625, + 1.3359375, + -4.125, + -1.578125, + 6.03125, + 2.5, + -5.0625, + 4.125, + -5.09375, + 7.1875, + -3.078125, + 4.40625, + 0.047607422, + -6.03125, + -1.4453125, + 1.921875, + -5.75, + -3.59375, + -1.03125, + -1.6015625, + 4.375, + 3.109375, + -5.65625, + 0.25195312, + -0.58984375, + 0.025878906, + 5.1875, + 0.28125, + -2.984375, + -2.0625, + 2.03125, + 4.59375, + -1.84375, + 3.0625, + -0.021606445, + -1.7421875, + 0.5859375, + 5.1875, + -2.296875, + 1.0078125, + 3.171875, + 0.51171875, + 2.390625, + -2.984375, + 1.1875, + 0.16894531, + -6.375, + -2.609375, + 1.4609375, + -4.78125, + 5.625, + -1.9296875, + -1.828125, + -3.53125, + -0.45898438, + 3.40625, + 5.4375, + 2.703125, + 2.796875, + 4.4375, + 4.21875, + -3.875, + 5.4375, + -1.578125, + -5.125, + 3.640625, + -4.46875, + -4.6875, + -1.4765625, + 1.3125, + -1.1640625, + -1.640625, + -0.48632812, + -3.21875, + -4.59375, + -5.5, + -0.70703125, + -4.3125, + 2.484375, + -0.98828125, + 2.953125, + 0.25195312, + -6.0625, + 2.09375, + -2.546875, + -1.203125, + -4.3125, + 2.078125, + -6.84375, + -1.09375, + 7.84375, + -0.22460938, + -2.171875, + 4.3125, + 5.375, + 0.08496094, + -4.78125, + 2.71875, + -6.15625, + 1.328125, + 2.375, + -2.578125, + -1.046875, + -5.03125, + 1.59375, + -2.203125, + 1.75, + -0.056152344, + -1.46875, + -3.46875, + -5.5, + -0.75390625, + -1.484375, + -3.921875, + 1.921875, + 2.046875, + -0.93359375, + -3.125, + -0.18164062, + 3.875, + 0.17089844, + -0.34765625, + -1.859375, + 2, + -2.15625, + 2.171875, + -3.46875, + -3.5625, + 1.421875, + -1.5625, + 0.053466797, + 7.15625, + 0.6328125, + 1.3046875, + 2.984375, + 2.828125, + -4.75, + -3.578125, + 5.46875, + -1.4765625, + -1.25, + -1.2734375, + 2.5625, + -0.28125, + 1.8515625, + -1.0859375, + -2.84375, + -2.578125, + 3.375, + 1.1328125, + -0.578125, + -5.3125, + 3.78125, + 2.484375, + 4.65625, + -5.1875, + -9.9375, + -0.703125, + -0.041503906, + -1.7265625, + -2.65625, + 7.0625, + -1.3203125, + -1.7421875, + -3.0625, + -1.3671875, + -0.73828125, + 0.61328125, + 5.71875, + 1.9296875, + 1.6640625, + -0.70703125, + 3.734375, + -2.734375, + 0.4609375, + -1.078125, + -3.140625, + 0.1953125, + -0.16015625, + 3.671875, + -2.171875, + 0.43164062, + -2.828125, + -0.984375, + -1.3828125, + 5.59375, + 8.25, + -2.625, + -0.41992188, + -0.60546875, + 1.6953125, + -3.15625, + 6.78125, + 0.21875, + 7.21875, + 0.67578125, + -1.4609375, + 4.96875, + -0.44726562, + -0.7734375, + 1.84375, + -8, + -5.8125, + -1.203125, + 2.59375, + -3.8125, + 0.69921875, + -2.703125, + -1.84375, + 3.46875, + -2.296875, + -0.46679688, + 2.171875, + 1.734375, + 1.8046875, + -2.703125, + -2.375, + -4.9375, + -0.9375, + 1.40625, + 1.4921875, + -2.34375, + -0.1484375, + 2.484375, + 8.375, + -2.84375, + -1.71875, + -2.015625, + 2.984375, + 0.41796875, + 0.24121094, + 0.9453125, + -2.34375, + 1.8515625, + 2.28125, + -1.609375, + -5, + -1.703125, + 4.59375, + 4.4375, + -4.09375, + 1.046875, + 0.091308594, + 3.640625, + -7.65625, + -4.5625, + -1.5078125, + -2.09375, + -1.2890625, + -0.90234375, + -0.099121094, + 0.64453125, + -1.0390625, + 4.5625, + -2.453125, + -1.71875, + 3.453125, + 1.7890625, + -1.859375, + -1.0390625, + 0.2890625, + 2.875, + 0.859375, + 0.703125, + -3.671875, + -0.6171875, + -1.5546875, + -1.6484375, + -0.9140625, + 1.7578125, + 4.40625, + -0.73046875, + 3.09375, + -6.0625, + 2.0625, + -2.359375, + 3.640625, + 5.3125, + -2.328125, + -2.015625, + -5.0625, + -8.875, + -2.4375, + 0.43164062, + -0.953125, + -4.625, + -4.40625, + -0.78515625, + -0.921875, + -8.1875, + -0.12792969, + -4.21875, + -0.90625, + 0.96484375, + -0.04296875, + 2.359375, + -4.46875, + 1.796875, + 4.875, + 4.875, + 2.03125, + 0.1875, + 2.546875, + 3.421875, + -0.93359375, + 1.328125, + -2.625, + 7.25, + -0.29492188, + 8.75, + 2.921875, + 0.41210938, + -5.78125, + 4.375, + 2.921875, + 6.3125, + -4.59375, + -2.03125, + -1.453125, + -1.2265625, + -1.53125, + -1.0546875, + 2.03125, + -2.703125, + -3.25, + -0.515625, + -5.9375, + -0.060791016, + 5.1875, + -1.2421875, + 5.09375, + 1.6875, + 2.984375, + 2.921875, + 2.75, + 2.453125, + 2.375, + 3.828125, + -4.375, + 2.390625, + -1.8359375, + 2.203125, + -0.91015625, + 1.0859375, + 1.421875, + -0.063964844, + 3.625, + 2.859375, + 1.640625, + 7.59375, + 1.703125, + 2.78125, + -2.75, + 1.1328125, + -0.921875, + -0.076660156, + 1.9140625, + 2.703125, + 2.53125, + -2.46875, + -0.765625, + -0.25195312, + 0.94140625, + -1.5859375, + -4.5, + -3.609375, + -4.09375, + -2.953125, + 7.78125, + -2.96875, + -1.953125, + 1.90625, + 3.015625, + 2.796875, + 6.75, + -0.23632812, + 4.0625, + -2.609375, + -0.2734375, + 4.0625, + -2.65625, + 1.078125, + 5.03125, + 4.125, + 5.40625, + 1.0390625, + -2.421875, + -1.046875, + 4.9375, + 3.75, + -4.125, + 1.0390625, + 4.9375, + -0.39453125, + -1.78125, + 3.859375, + -0.63671875, + 3.828125, + -5.125, + 1.2890625, + 6.25, + -0.10253906, + -2.4375, + -6.5625, + -3.5625, + -1.1328125, + 3.6875, + 4.59375, + -1.2578125, + 4.625, + 3.734375, + -1.703125, + 1.9296875, + -3.671875, + -0.64453125, + -3.375, + -0.63671875, + 3.640625, + 0.74609375, + -3.171875, + -0.8671875, + 1.3828125, + -0.7734375, + 3.734375, + 3.21875, + -4.6875, + -0.66796875, + 1.34375, + -0.89453125, + 2.0625, + 2.5, + 2.265625, + 1.625, + -3.03125, + -3.25, + -0.81640625, + -1.8046875, + 0.10107422, + -2.9375, + 1.3359375, + 3.125, + 2.234375, + -3.296875, + 3.671875, + -2.171875, + -2.75, + 2.078125, + -6, + -5.1875, + 0.62890625, + 0.13671875, + -5.3125, + -0.80078125, + -1.09375, + -0.65625, + 2.9375, + -4.40625, + 2.921875, + -2.703125, + 6.125, + -0.44140625, + -1.3203125, + 1.9609375, + -5.15625, + 4.3125, + -1.4375, + -2.078125, + 3.046875, + -3.4375, + -0.9921875, + -1.328125, + 2.609375, + -2.28125, + 0.06933594, + 5.59375, + -1.9921875, + -2.34375, + 1.7734375, + 3.6875, + -1.4140625, + -4.53125, + 1.4765625, + 3.28125, + 0.33789062, + -3.453125, + -0.62109375, + -3.640625, + 5, + -3.390625, + 1.96875, + -7.46875, + -2.015625, + 2.125, + 0.43945312, + 9.5625, + 4.375, + -4.65625, + -0.28125, + 1.1484375, + -3.15625, + -4.5, + -3.078125, + 6.0625, + -2.46875, + 0.2734375, + 1.2109375, + -0.33398438, + -2.875, + 3.640625, + -2.046875, + 3.65625, + 4.25, + -1.53125, + 2.859375, + 2.203125, + 1.3984375, + -4.3125, + -1.375, + -2.328125, + 3.078125, + 1.96875, + -1.7109375, + 5.34375, + -1.8828125, + 2.640625, + 1.1953125, + -1.296875, + 0.38671875, + 3.984375, + 1.875, + -2.828125, + -1.6953125, + 1.8203125, + -1.421875, + -0.29492188, + -5.6875, + -0.75, + -3.234375, + 0.92578125, + 2.453125, + -1.0390625, + 1.2890625, + 3.5, + -2.609375, + 2.515625, + -3.9375, + -3.65625, + 5.0625, + 0.59375, + -0.008056641, + 5.3125, + -0.8671875, + -2.546875, + 0.33203125, + 2.53125, + 2.0625, + -2.5, + -4.875, + 4.34375, + -0.65625, + 2.921875, + -3.828125, + -2.359375, + -3.125, + 4.5625, + 5.03125, + 1.09375, + -1.3984375, + 1.34375, + -0.5703125, + 1.46875, + 0.97265625, + 4.40625, + -5.59375, + -2.21875, + -1.484375, + 5.90625, + 1.84375, + -4.71875, + -0.5625, + 2.84375, + -3.171875, + -0.8515625, + 3.046875, + 0.18066406, + -3.03125, + 0.36132812, + -2.984375, + -4.90625, + -7, + 4.25, + 0.0023040771, + 1.828125, + -2.328125, + -2, + -1, + -3.484375, + -0.34375, + 3.21875, + 2.828125, + 4.8125, + -0.33398438, + 3.75, + 4.59375, + -3.296875, + 1.953125, + 3.953125, + -0.45703125, + -2.453125, + 1.484375, + -3.828125, + -5.34375, + 1.2890625, + -8.625, + -1.546875, + 4.96875, + 3.59375, + 2.5625, + -1.28125, + 0.55859375, + 0.34570312, + -3.40625, + -1.8125, + -4.3125, + 0.22070312, + 4.21875, + -0.05493164, + 0.8828125, + -1.953125, + -0.578125, + 2.71875, + -1.5234375, + 1.984375, + -1.953125, + 5.5625, + 2.109375, + 6.03125, + -1.6953125, + -4.28125, + 2.671875, + -1.5703125, + -3.03125, + -1.765625, + -2.59375, + -1.7734375, + 2.4375, + 2.484375, + -2.078125, + -3.515625, + -4.59375, + 3.78125, + -0.07080078, + 0.6953125, + -2.296875, + 3.171875, + -0.18847656, + 1.0234375, + 3.21875, + -4.84375, + -2.09375, + 0.59765625, + 2.1875, + 5.84375, + 0.78515625, + -0.35351562, + -3.421875, + 3.203125, + -2.4375, + -0.23339844, + -4.0625, + -2.171875, + -1.5, + -3.40625, + 2.671875, + -4.5, + 4.5, + -1.5390625, + -2.09375, + -1.7109375, + -0.053955078, + -0.359375, + 4.25, + 0.74609375, + -0.9765625, + 3.875, + -2.84375, + 3.78125, + 2.171875, + -3.28125, + 0.09716797, + 1.9453125, + 1.2265625, + -2.3125, + 1.546875, + -1.7734375, + -0.3125, + 1.34375, + 4.5625, + -5.625, + 2.671875, + 1.796875, + 3.0625, + -4.40625, + -3.078125, + -0.16308594, + 1.703125, + 0.27929688, + 2.703125, + -4.53125, + 2.21875, + 4.21875, + -0.22265625, + 1.75, + -0.984375, + 4.6875, + -0.8203125, + 0.23828125, + 4.15625, + 1.390625, + 2.578125, + 1.375, + 1.421875, + -0.021850586, + -0.23925781, + 3.359375, + -0.328125, + -1.0234375, + -1.15625, + 2.125, + -3.484375, + -2.515625, + -7.375, + 3.546875, + 0.109375, + 1.0703125, + 0.9921875, + -0.067871094, + -0.057373047, + -0.9140625, + -1.6328125, + -0.29492188, + -3.109375, + -2.1875, + -1.2734375, + 2.25, + -2.796875, + 2.140625, + 1.0078125, + 1.4453125, + 4.21875, + 2.1875, + 3.796875, + -0.33789062, + 1.7578125, + 0.22167969, + 1.921875, + -1.9375, + 2.484375, + -2.421875, + -0.703125, + 2.921875, + -4.21875, + 1.8515625, + -4.53125, + -2.375, + -4.8125, + -2.171875, + 3.1875, + 5.75, + -4.375, + -3.15625, + 9.0625, + 1.2421875, + 1.9296875, + 2.53125, + -3.921875, + -0.34960938, + -1.8828125, + -0.049316406, + 6.375, + 3.03125, + 2.859375, + -4.09375, + 6.875, + 6.96875, + 0.091796875, + 3.609375, + 1.3984375, + -1.6484375, + -4.625, + 4.6875, + 2.203125, + 0.46679688, + -2.59375, + 2.421875, + 4.25, + -0.25976562, + 5.5625, + -5.9375, + 0.6640625, + -0.20703125, + 3.25, + -0.06201172, + -3.875, + -3.96875, + 2.234375, + -0.068847656, + -1.4609375, + 5.8125, + -1.1171875, + 0.42382812, + -1.6015625, + 3.625, + 0.93359375, + 4.4375, + -3.109375, + 3.71875, + -3.84375, + 3.984375, + -2.140625, + 0.48242188, + -4.625, + 1.3203125, + 2.671875, + 5.90625, + -3.578125, + -5.125, + 3.6875, + 0.28125, + -0.36132812, + -2.15625, + 6.46875, + 4.78125, + 1.578125, + -4.21875, + -1.6640625, + 0.6953125, + 1.5, + 0.89453125, + -6.21875, + 2.140625, + 1.046875, + -2.78125, + -1.1328125, + 1.2578125, + 4.09375, + -3.21875, + -3.53125, + -1.125, + 0.62109375, + -1.59375, + 1.96875, + 4.40625, + -0.84765625, + 5.6875, + 0.009033203, + 5, + 1.28125, + -0.8828125, + 2.78125, + 3.078125, + -2.734375, + 4.53125, + 1.1796875, + -2.3125, + 2.09375, + 0.73828125, + 0.12158203, + 3.53125, + -2.171875, + -0.13671875, + -1.7734375, + -0.080078125, + 1.0234375, + 4.34375, + 5.1875, + -0.66015625, + 0.30664062, + 2.765625, + -0.53515625, + -1.6015625, + 0.8671875, + 2.125, + -3.28125, + -3.8125, + -2.046875, + 6.34375, + 2.078125, + -0.44335938, + 0.22460938, + 1.921875, + -4.09375, + -5, + -6.53125, + 0.81640625, + -1.09375, + 3.09375, + 1.765625, + -3.9375, + 1.1953125, + 4.5625, + 3.15625, + 4.0625, + -2.25, + 1.5390625, + 4.71875, + 2.03125, + -3.328125, + 0.036865234, + 3.6875, + -2.9375, + -3.15625, + 1.234375, + -0.5859375, + -2.3125, + 1.046875, + -5.53125, + -2.4375, + -0.19335938, + 2.84375, + -1.1796875, + -6.15625, + -1.296875, + -2.296875, + -3.96875, + -3.453125, + -5.0625, + 3.546875, + 3.25, + 2.9375, + 4.71875, + 2.046875, + -2.71875, + 4.96875, + 18.75, + -3.28125, + -3.640625, + -1.6015625, + -1.1796875, + 1.9375, + 2.796875, + 3.953125, + 1.1328125, + -2.703125, + -0.10644531, + 1.265625, + 3.9375, + 0.89453125, + -2.265625, + 0.48242188, + 0.14257812, + 0.9609375, + -2.828125, + -3.796875, + -2.59375, + 2, + 2.234375, + 0.87890625, + 1.3203125, + 3.3125, + 0.95703125, + -0.46679688, + -0.375, + -2.640625, + -5.96875, + -4.25, + 1.59375, + -0.21679688, + 3.8125, + -3.9375, + 5.1875, + 0.65625, + -0.30664062, + -2.140625, + -4.40625, + -1.96875, + 2.546875, + 0.48632812, + -1.3515625, + 3.34375, + -2.40625, + -3.703125, + -1.6484375, + 0.111328125, + -5.65625, + -1.140625, + -2.171875, + 3.46875, + 1.34375, + -3.859375, + 0.23535156, + -6.78125, + -1.078125, + -0.48828125, + 2.734375, + -2.890625, + 3.765625, + 0.7734375, + -1.8359375, + -2.875, + -4.90625, + -1.7265625, + 1.984375, + -1.421875, + -5.46875, + 1.2265625, + -0.12988281, + 2.703125, + -1.21875, + -1.640625, + 1.8984375, + 4.46875, + 1.21875, + 0.70703125, + -3.140625, + 1.6171875, + -1.546875, + -2.578125, + -0.7890625, + -0.12890625, + -4.34375, + 4.625, + 1.8359375, + -2.421875, + 4.84375, + -6.8125, + 4.40625, + 4.4375, + -4.90625, + 0.9921875, + 5.40625, + 0.99609375, + -0.106933594, + 0.076660156, + 2.765625, + 2.46875, + 2.703125, + -2.3125, + 1.7734375, + 2.484375, + 0.17773438, + 2.046875, + 3.953125, + 3.078125, + 1.015625, + 4.28125, + 0.59375, + -3.296875, + -0.93359375, + 2.34375, + -4.375, + -2.234375, + -0.33789062, + -4.09375, + 7.3125, + 1.8046875, + -0.546875, + 3.484375, + -6.21875, + -4.46875, + -4.25, + -6.15625, + 6.46875, + -1.375, + -0.9140625, + 2.03125, + 0.22558594, + 1.34375, + -1.90625, + -2.8125, + 0.63671875, + 4.84375, + 0.31835938, + -1.0625, + -4.8125, + 1.3984375, + 4.34375, + -4.59375, + 1.125, + 1.8828125, + -3.515625, + 2.359375, + -0.057128906, + 0.0087890625, + -3.15625, + 3.359375, + 2, + -4.40625, + -5.65625, + 3.109375, + -2.28125, + -2.703125, + -3.90625, + -1.671875, + -2.375, + -3, + -2.09375, + -1.453125, + -2.03125, + -2.921875, + 2, + -1.4765625, + -1.9453125, + 3.203125, + 1.7578125, + -5.46875, + -2.8125, + 0.51171875, + 0.5234375, + -4.09375, + 2.15625, + 6.4375, + -0.31054688, + 0.6171875, + 0.8125, + 0.057128906, + -2.125, + -4.875, + 0.8828125, + 2.28125, + -3.96875, + 0.12792969, + -0.88671875, + 0.017822266, + -5.1875, + -1.2421875, + -2.390625, + 3.125, + 2.75, + -5.03125, + -1.671875, + -1.9453125, + 1.28125, + -2.046875, + -3.8125, + 3.6875, + 3.65625, + 0.421875, + 3.96875, + 1.1484375, + -4.96875, + -1.109375, + 1.9140625, + -2.046875, + -5.15625, + 3.796875, + -0.025878906, + 1.171875, + -8.375, + 5.84375, + 1.546875, + 0.017333984, + -0.67578125, + 1.3125, + 0.80078125, + 1.6328125, + -4.75, + 0.045898438, + 2.0625, + 2.265625, + -6.59375, + 2.375, + 3.0625, + -0.86328125, + -1.7578125, + 6.3125, + -0.546875, + 1.515625, + -0.46679688, + -5.25, + -0.328125, + -2.609375, + -0.76953125, + 1.7890625, + 3.515625, + -2.234375, + 3.140625, + 5.53125, + -2.53125, + 1.5703125, + 5.75, + -1.484375, + -1.4296875, + 1.265625, + 1.75, + 0.7578125, + 1.4453125, + -4.375, + -4.59375, + -0.16503906, + -3.359375, + 0.921875, + -3.203125, + 3.0625, + 4.71875, + -1.78125, + 4.90625, + -2.0625, + 0.890625, + 1.4765625, + 2.796875, + -4.1875, + 1.609375, + 2.734375, + -3.125, + 4.125, + -1.6328125, + -4.6875, + -0.89453125, + 3.5625, + -0.51171875, + -6.25, + 1.6953125, + 2.3125, + -2.078125, + 1.1640625, + 1.4140625, + -2.109375, + -0.546875, + -2.609375, + 4.15625, + -0.359375, + 0.94921875, + -1.3203125, + 3.890625, + 4.65625, + -1.734375, + 1.9453125, + -4.75, + 1.421875, + -1.2890625, + -4.46875, + 5.0625, + -0.76953125, + 2.109375, + 5.46875, + 1.7734375, + -7.8125, + -1.109375, + -1.8515625, + 1.28125, + 6.03125, + 1.609375, + -1.2265625, + -1.9609375, + 2.921875, + 2.875, + 2.625, + 2.3125, + 1.28125, + -4.0625, + 4.09375, + 1.109375, + -6.3125, + 0.85546875, + 2.734375, + -2.59375, + 2.640625, + -1.9140625, + -2.046875, + -0.78515625, + 0.48632812, + -4.5625, + 1.609375, + 3.78125, + -0.8515625, + 2.3125, + 0.734375, + -0.072753906, + 4.71875, + -0.44335938, + -12.1875, + -0.6953125, + 0.00680542, + 2.78125, + 1.9765625, + 0.3671875, + 1.375, + -1.625, + 0.18261719, + -3.890625, + 2.34375, + 0.24902344, + -12.0625, + 1.8125, + -3.328125, + -0.88671875, + -4.125, + -2.78125, + -2.65625, + 5.1875, + 3.75, + 2.625, + 2.625, + -1.25, + 0.73828125, + 4.21875, + -1.9140625, + -2.765625, + 2.734375, + 0.69140625, + -3.734375, + -0.55859375, + 2.578125, + 2.546875, + -3.25, + -3.53125, + 4.3125, + -1.296875, + 0.73046875, + 5.46875, + 5.03125, + 1.2109375, + -0.41992188, + -4.0625, + 1.8359375, + -1.9765625, + -2.640625, + 1.28125, + -1.6171875, + 3.3125, + -2.203125, + 1.8828125, + -0.57421875, + -4.34375, + -1.796875, + -2.859375, + -0.5859375, + 2.015625, + 3.1875, + 0.4765625, + -0.8203125, + 0.36914062, + 1.3984375, + 2.109375, + -1.8828125, + -2.8125, + 2.375, + -1.7109375, + -3.015625, + 0.0016708374, + 1.6875, + -4, + -2.03125, + 1.09375, + 2.03125, + 0.10888672, + -1.6953125, + -2.5625, + 2.875, + 4.84375, + -1.4609375, + -1.6796875, + -0.50390625, + 2.140625, + 3.890625, + -1.3671875, + -1.703125, + -3.03125, + -0.81640625, + -5.15625, + -4.5, + 2.390625, + -0.41992188, + 1.5859375, + 6.125, + 0.08496094, + -0.66015625, + 4.5625, + -1.8515625, + -2.828125, + 1.703125, + 0.515625, + -0.30664062, + -1.46875, + 1.3984375, + -4, + 2.765625, + 5.03125, + -3.578125, + -2.03125, + 1.109375, + -0.26171875, + -5.15625, + 2.078125, + 3.25, + -3.109375, + -6.1875, + 9.5625, + 2.609375, + 4.46875, + 2.625, + -3.875, + 4.53125, + -2.96875, + 1.1953125, + -0.6796875, + 1.4921875, + 2.390625, + -6.28125, + -1, + -1.9296875, + -3.078125, + -0.026245117, + -1.0625, + -2.484375, + 1.6875, + 7.28125, + -3.8125, + -0.3828125, + -4.90625, + -2.109375, + 3.171875, + -1.3125, + -7.46875, + 1.609375, + -7.53125, + 0.58203125, + -1.84375, + 1.40625, + -3.8125, + 0.703125, + 0.78515625, + 4.71875, + -3.390625, + 2.125, + -2.984375, + 1.5, + -0.72265625, + 4.5625, + 1.140625, + 1.6015625, + 0.69140625, + 4.71875, + -1.8671875, + 0.515625, + -1.3203125, + 0.4609375, + -1.09375, + 1.34375, + 1.8359375, + 3.03125, + -2.28125, + -2.15625, + -1.203125, + -0.056152344, + -0.6875, + 0.82421875, + -1.7890625, + 1.90625, + 0.1796875, + -0.46679688, + 0.91796875, + -0.96484375, + -0.59765625, + -1.75, + -0.54296875, + 0.032470703, + 0.90625, + 0.114746094, + 0.08105469, + 3.125, + -1.5234375, + -0.90234375, + 1.171875, + -0.41992188, + -0.90234375, + 1.2265625, + -1.640625, + 0.10253906, + -1.65625, + 2.203125, + 0.52734375, + -0.42773438, + 2.59375, + -1.9296875, + 1.6484375, + -1.7421875, + -0.118652344, + 0.91796875, + -0.8984375, + -0.45507812, + -1.9765625, + -0.24707031, + 0.13183594, + -1.578125, + 1.8828125, + -0.41992188, + -0.0018920898, + -0.49609375, + 1.09375, + 1.2421875, + -2.515625, + -1.5, + 0.828125, + 2.578125, + -0.36523438, + 2.15625, + 1.6484375, + -1.6328125, + -0.7421875, + -0.43164062, + -2.1875, + -1.078125, + -1.8828125, + 0.4140625, + -1.71875, + 2.765625, + -0.23046875, + -2.390625, + 0.083984375, + -1.3125, + 2.890625, + -0.18164062, + 0.94140625, + 0.60546875, + -1.2109375, + 0.33789062, + 0.20898438, + 1.9765625, + 0.4375, + 0.7109375, + 0.4921875, + -1.109375, + -0.59375, + 1.8671875, + -1.9921875, + 0.3828125, + -1.8046875, + 1.40625, + -0.20214844, + 2.5, + 2.140625, + 0.099121094, + -0.59375, + 0.020874023, + 0.9609375, + -1.8984375, + 2.40625, + 2.09375, + 0.48632812, + -1.96875, + 2.28125, + 0.96484375, + -1.3125, + -1.0625, + -0.6328125, + -0.36328125, + 2.21875, + 1.765625, + -0.46875, + -1.0625, + 2.296875, + -0.11035156, + 1.421875, + 1.0703125, + 1.8515625, + -0.9375, + -1.4375, + -1.1875, + -1.5390625, + -1.078125, + 0.5703125, + 0.45703125, + -1.9296875, + -1.03125, + 0.984375, + -0.921875, + -0.68359375, + 1.078125, + -0.021606445, + 2.8125, + 3.046875, + 2.453125, + 2.765625, + -2.453125, + 1.5, + 0.10205078, + 1, + -0.86328125, + 0.20800781, + -0.43359375, + -2.6875, + -0.5078125, + 0.099121094, + 1.109375, + -2.796875, + -0.1015625, + -0.06933594, + 3.046875, + 1.15625, + 0.5, + 0.41992188, + 0.54296875, + -0.734375, + 0.9375, + 0.07128906, + -3.578125, + -0.029785156, + 2.40625, + 2.640625, + 1.78125, + 0.7109375, + -0.83984375, + 0.98828125, + -2.640625, + 1.5859375, + -0.47070312, + -1.46875, + -0.77734375, + -0.58203125, + -0.045898438, + 0.071777344, + 3.671875, + -0.94140625, + 1.5, + -0.421875, + -0.2890625, + -0.7421875, + 0.9609375, + 0.44726562, + -0.953125, + 0.58203125, + -2.5, + -0.40234375, + 0.88671875, + -1.5703125, + -0.44140625, + 2.171875, + -0.375, + -0.020507812, + -2.828125, + 0.063964844, + 0.8671875, + 2.21875, + -1.2265625, + -3.078125, + 0.8671875, + -0.34960938, + 0.90234375, + -1.2734375, + 2.0625, + -1.4296875, + -3.234375, + 3.015625, + 1.3359375, + 1.375, + 0.38085938, + 2.3125, + -1.46875, + 0.5625, + -0.13671875, + -0.8671875, + -2.828125, + 0.26367188, + 0.71484375, + -1.75, + -0.49609375, + 1.0234375, + -0.83984375, + -0.2890625, + 0.07763672, + 1.03125, + 0.24511719, + -0.92578125, + 1.15625, + -3.875, + -0.328125, + -0.76171875, + 0.79296875, + -0.9921875, + 0.92578125, + -0.35351562, + 3.328125, + 1.0078125, + -0.3515625, + -0.96875, + 0.2734375, + 0.59375, + 0.625, + -0.390625, + -0.06347656, + -0.44335938, + -1.9765625, + 0.23046875, + -2.734375, + -1.578125, + 0.005493164, + -3.34375, + 1.2578125, + -2, + 0.56640625, + -1.96875, + 0.53515625, + 1.28125, + 1.0078125, + -1.8671875, + 1.3046875, + -2.140625, + 2.046875, + 4.09375, + 1.9296875, + 2.578125, + 0.7421875, + -0.68359375, + -2.265625, + 0.7734375, + -1.171875, + -1.1171875, + -1.953125, + 0.5078125, + -1.1171875, + 1.140625, + 2.953125, + -1.7421875, + 1.015625, + -0.34375, + -0.01965332, + -1.0859375, + -1.140625, + 0.59765625, + -2.40625, + 0.0027923584, + 0.140625, + 0.28125, + 2.046875, + 0.89453125, + -1.546875, + -0.66015625, + -0.07080078, + -2.609375, + -0.31445312, + 1.9453125, + 0.021728516, + 2.046875, + -0.29492188, + -0.68359375, + -1.2265625, + 0.107910156, + 0.50390625, + 0.6015625, + 2.296875, + -4.25, + 1.40625, + 1.203125, + -1.9140625, + -0.74609375, + 1.3984375, + 1.890625, + -0.765625, + -0.035888672, + -0.14648438, + -0.03149414, + 3.03125, + 1.171875, + -0.013793945, + 0.890625, + 3.84375, + -2.734375, + -1.9921875, + -0.60546875, + 0.91015625, + -3.765625, + -2.484375, + 4.25, + -0.18066406, + -0.984375, + -0.37695312, + -1.9765625, + 0.87890625, + 0.083496094, + -0.15820312, + -2.703125, + -0.053466797, + 0.58984375, + 0.028076172, + 1.1953125, + 0.119628906, + -1.40625, + -2.375, + -2.03125, + -0.071777344, + -0.84375, + 3, + 0.037109375, + -1.515625, + 1.25, + -1.984375, + 1.046875, + -0.39453125, + 1.109375, + 1.46875, + 0.31640625, + 1.5234375, + 1.7265625, + -2.4375, + 1.640625, + 0.375, + 1.1875, + 0.28515625, + -0.40625, + 0.67578125, + 0.49804688, + -1.6640625, + 0.89453125, + 0.40625, + -2.484375, + -1.1953125, + -1.5859375, + -0.7109375, + 1.859375, + -1.421875, + 0.27148438, + -0.4140625, + -1.6796875, + 0.8515625, + 0.921875, + 0.44921875, + -4.125, + -0.4296875, + 2.25, + 0.013671875, + -0.049804688, + 1.375, + -2.796875, + 0.71484375, + 0.75390625, + 0.07421875, + -0.9375, + -1.25, + -0.65625, + 1.984375, + 0.53515625, + -0.57421875, + 1.03125, + -1.578125, + -0.5078125, + 0.66796875, + 0.55859375, + 2.453125, + 0.39257812, + 0.953125, + 1.140625, + -1.2578125, + -1.6484375, + 2.046875, + 0.59375, + 0.65234375, + -1.59375, + -3.140625, + -0.39453125, + -0.42578125, + 0.15332031, + -0.6171875, + 0.12158203, + -0.66015625, + -2.796875, + 0.9375, + -0.13769531, + 2.390625, + 2.859375, + 0.32617188, + -1.2109375, + -0.671875, + 2.03125, + -0.26953125, + 0.75, + 0.58984375, + 0.49414062, + 1.71875, + -1.3984375, + 0.5390625, + 1.6875, + -0.15429688, + -2.421875, + 0.8984375, + -0.56640625, + 2.5, + -0.42578125, + -3.875, + -2.046875, + -0.9453125, + -3.375, + 0.55078125, + -2.03125, + -0.033447266, + -2.671875, + 0.34960938, + 0.12109375, + -0.51171875, + 0.48828125, + -1.515625, + 0.43164062, + 1.46875, + 0.32617188, + -0.33203125, + 1.71875, + -1.5234375, + -1.6328125, + -2.671875, + 4.03125, + 1.125, + -0.79296875, + -2.5, + -1.8046875, + -0.640625, + -0.6328125, + -0.82421875, + -0.67578125, + 2.203125, + 0.69921875, + 1.3046875, + 0.35742188, + 0.28320312, + 0.16699219, + -0.12060547, + 1.0546875, + -0.44726562, + 0.29882812, + -1.90625, + -1.296875, + 0.63671875, + -2.25, + -0.16113281, + -1.8984375, + 2.96875, + 1.5078125, + 4.96875, + 2.1875, + 1.609375, + -1.8984375, + -0.4609375, + -0.119628906, + -0.28515625, + -0.69140625, + 2.71875, + 0.20507812, + 1.625, + -2.40625, + -0.22167969, + -1.765625, + 2.578125, + 0.94921875, + -0.56640625, + 1.96875, + -2.359375 + ] + } + ] +} diff --git a/components/retriever/pinecone/examples/main.go b/components/retriever/pinecone/examples/main.go new file mode 100644 index 000000000..fe980ea2f --- /dev/null +++ b/components/retriever/pinecone/examples/main.go @@ -0,0 +1,101 @@ +/* + * Copyright 2025 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "context" + "fmt" + "log" + "os" + + "github.com/bytedance/sonic" + "github.com/cloudwego/eino-ext/components/retriever/pinecone" + "github.com/cloudwego/eino/components/embedding" + pc "github.com/pinecone-io/go-pinecone/v3/pinecone" +) + +func main() { + // Load configuration from environment variables + apiKey := os.Getenv("PINECONE_APIKEY") + if apiKey == "" { + log.Fatal("PINECONE_APIKEY environment variable is required") + } + + // Initialize Pinecone client + client, err := pc.NewClient(pc.NewClientParams{ + ApiKey: apiKey, + }) + if err != nil { + log.Fatalf("Failed to create Pinecone client: %v", err) + } + + // Create Pinecone retriever config + config := pinecone.RetrieverConfig{ + Client: client, + Embedding: &mockEmbedding{}, + } + + ctx := context.Background() + retriever, err := pinecone.NewRetriever(ctx, &config) + if err != nil { + log.Fatalf("Failed to create Pinecone retriever: %v", err) + } + log.Println("Retriever created successfully") + + // Retrieve documents + documents, err := retriever.Retrieve(ctx, "pinecone") + if err != nil { + log.Fatalf("Failed to retrieve: %v", err) + return + } + + // Print the documents + for i, doc := range documents { + fmt.Printf("Document %d:\n", i) + fmt.Printf("title: %s\n", doc.ID) + fmt.Printf("content: %s\n", doc.Content) + fmt.Printf("metadata: %v\n", doc.MetaData) + } +} + +type vector struct { + Data []struct { + Embedding []float64 `json:"embedding"` + } `json:"data"` +} + +type mockEmbedding struct{} + +func (m *mockEmbedding) EmbedStrings( + ctx context.Context, + texts []string, + opts ...embedding.Option, +) ([][]float64, error) { + bytes, err := os.ReadFile("./examples/embeddings.json") + if err != nil { + return nil, err + } + var v vector + if err := sonic.Unmarshal(bytes, &v); err != nil { + return nil, err + } + res := make([][]float64, 0, len(v.Data)) + for _, data := range v.Data { + res = append(res, data.Embedding) + } + return res, nil +} diff --git a/components/retriever/pinecone/go.mod b/components/retriever/pinecone/go.mod new file mode 100644 index 000000000..7a42647ee --- /dev/null +++ b/components/retriever/pinecone/go.mod @@ -0,0 +1,57 @@ +module github.com/cloudwego/eino-ext/components/retriever/pinecone + +go 1.21.12 + +require ( + github.com/bytedance/mockey v1.2.14 + github.com/bytedance/sonic v1.13.2 + github.com/cloudwego/eino v0.3.41 + github.com/pinecone-io/go-pinecone/v3 v3.1.0 +) + +require ( + github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect + github.com/bytedance/sonic/loader v0.2.4 // indirect + github.com/cloudwego/base64x v0.1.5 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect + github.com/getkin/kin-openapi v0.118.0 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/swag v0.19.5 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/goph/emperror v0.17.2 // indirect + github.com/gopherjs/gopherjs v1.17.2 // indirect + github.com/invopop/yaml v0.1.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/jtolds/gls v4.20.0+incompatible // indirect + github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + github.com/nikolalohinski/gonja v1.5.3 // indirect + github.com/oapi-codegen/runtime v1.1.1 // indirect + github.com/pelletier/go-toml/v2 v2.0.9 // indirect + github.com/perimeterx/marshmallow v1.1.4 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f // indirect + github.com/smarty/assertions v1.15.0 // indirect + github.com/smartystreets/goconvey v1.8.1 // indirect + github.com/stretchr/testify v1.9.0 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/yargevad/filepathx v1.0.0 // indirect + golang.org/x/arch v0.11.0 // indirect + golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect + golang.org/x/net v0.33.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/text v0.22.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/grpc v1.65.0 // indirect + google.golang.org/protobuf v1.34.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/components/retriever/pinecone/go.sum b/components/retriever/pinecone/go.sum new file mode 100644 index 000000000..a39944610 --- /dev/null +++ b/components/retriever/pinecone/go.sum @@ -0,0 +1,188 @@ +github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= +github.com/airbrake/gobrake v3.6.1+incompatible/go.mod h1:wM4gu3Cn0W0K7GUuVWnlXZU11AGBXMILnrdOU8Kn00o= +github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= +github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= +github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= +github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= +github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= +github.com/bugsnag/bugsnag-go v1.4.0/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= +github.com/bugsnag/panicwrap v1.2.0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= +github.com/bytedance/mockey v1.2.14 h1:KZaFgPdiUwW+jOWFieo3Lr7INM1P+6adO3hxZhDswY8= +github.com/bytedance/mockey v1.2.14/go.mod h1:1BPHF9sol5R1ud/+0VEHGQq/+i2lN+GTsr3O2Q9IENY= +github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ= +github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY= +github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= +github.com/certifi/gocertifi v0.0.0-20190105021004-abcd57078448/go.mod h1:GJKEexRPVJrBSOjoqN5VNOIKJ5Q3RViH6eu3puDRwx4= +github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= +github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/eino v0.3.41 h1:bb6W5/+8QE+jlhDBY2TxcxYu6odpNQ436oDdBF45jgQ= +github.com/cloudwego/eino v0.3.41/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/getkin/kin-openapi v0.118.0 h1:z43njxPmJ7TaPpMSCQb7PN0dEYno4tyBPQcrFdHoLuM= +github.com/getkin/kin-openapi v0.118.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc= +github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= +github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJYCFOLkIBwI7xFExG03bbkOkCvUPI= +github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= +github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/goph/emperror v0.17.2 h1:yLapQcmEsO0ipe9p5TaN22djm3OFV/TfM/fcYP0/J18= +github.com/goph/emperror v0.17.2/go.mod h1:+ZbQ+fUNO/6FNiUo0ujtMjhgad9Xa6fQL9KhH4LNHic= +github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g= +github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/invopop/yaml v0.1.0 h1:YW3WGUoJEXYfzWBjn00zIlrw7brGVD0fUKRYDPAPhrc= +github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= +github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= +github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= +github.com/nikolalohinski/gonja v1.5.3 h1:GsA+EEaZDZPGJ8JtpeGN78jidhOlxeJROpqMT9fTj9c= +github.com/nikolalohinski/gonja v1.5.3/go.mod h1:RmjwxNiXAEqcq1HeK5SSMmqFJvKOfTfXhkJv6YBtPa4= +github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro= +github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/pelletier/go-toml/v2 v2.0.9 h1:uH2qQXheeefCCkuBBSLi7jCiSmj3VRh2+Goq2N7Xxu0= +github.com/pelletier/go-toml/v2 v2.0.9/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/perimeterx/marshmallow v1.1.4 h1:pZLDH9RjlLGGorbXhcaQLhfuV0pFMNfPO55FuFkxqLw= +github.com/perimeterx/marshmallow v1.1.4/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= +github.com/pinecone-io/go-pinecone/v3 v3.1.0 h1:JxUK7OXycfqOF+DZbCexT5jKGVA8s5gswZL1wS95zf8= +github.com/pinecone-io/go-pinecone/v3 v3.1.0/go.mod h1:v8VJwwmZFesCP3bIYv98eU/kIpT7v8s0UulNTLWR8c8= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rollbar/rollbar-go v1.0.2/go.mod h1:AcFs5f0I+c71bpHlXNNDbOWJiKwjFDtISeXco0L5PKQ= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f h1:Z2cODYsUxQPofhpYRMQVwWz4yUVpHF+vPi+eUdruUYI= +github.com/slongfield/pyfmt v0.0.0-20220222012616-ea85ff4c361f/go.mod h1:JqzWyvTuI2X4+9wOHmKSQCYxybB/8j6Ko43qVmXDuZg= +github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY= +github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec= +github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY= +github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60= +github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo= +github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= +github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg= +github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE= +github.com/yargevad/filepathx v1.0.0 h1:SYcT+N3tYGi+NvazubCNlvgIPbzAk7i7y2dwg3I5FYc= +github.com/yargevad/filepathx v1.0.0/go.mod h1:BprfX/gpYNJHJfc35GjRRpVcwWXS89gGulUIU5tK3tA= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= +golang.org/x/arch v0.11.0 h1:KXV8WWKCXm6tRpLirl2szsO5j/oOODwZf4hATmGVNs4= +golang.org/x/arch v0.11.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw= +golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= diff --git a/components/retriever/pinecone/retriever.go b/components/retriever/pinecone/retriever.go new file mode 100644 index 000000000..f07bd8089 --- /dev/null +++ b/components/retriever/pinecone/retriever.go @@ -0,0 +1,251 @@ +/* + * Copyright 2025 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pinecone + +import ( + "context" + "fmt" + + "github.com/cloudwego/eino/callbacks" + "github.com/cloudwego/eino/components" + "github.com/cloudwego/eino/components/embedding" + "github.com/cloudwego/eino/components/retriever" + "github.com/cloudwego/eino/schema" + pc "github.com/pinecone-io/go-pinecone/v3/pinecone" +) + +type RetrieverConfig struct { + // Client is the Pinecone client instance used for all API operations. + // Required. Must be initialized before use. + Client *pc.Client + + // IndexName is the name of the Pinecone index to search against. + // Optional. Default is "eino-index". + IndexName string + + // Namespace is the logical namespace within the index, used for multi-tenant or data isolation scenarios. + // Optional. Default is "". + Namespace string + + // MetricType specifies the similarity metric used for vector search (e.g., cosine, dotproduct, euclidean). + // Optional. Default is pc.IndexMetricCosine. + MetricType pc.IndexMetric + + // Field specifies the document field to associate with vector data, used for mapping between Pinecone vectors and application documents. + // Optional. Default is "". Set if you want to map a specific document field. + Field string + + // VectorConverter is a function to convert float64 vectors (from embedding models) to float32 as required by Pinecone API. + // Optional. If nil, a default conversion will be used. + VectorConverter func(ctx context.Context, vector []float64) ([]float32, error) + + // DocumentConverter is a function to convert Pinecone vector results to schema.Document objects for downstream consumption. + // Optional. If nil, a default converter will be used. + DocumentConverter func(ctx context.Context, vector *pc.Vector, field string) (*schema.Document, error) + + // TopK specifies the number of top results to return for each query. + // Optional. Default is 10. + TopK int + + // ScoreThreshold is the minimum similarity score for a result to be returned. + // Optional. Default is 0. Used to filter out low-relevance matches. + ScoreThreshold float64 + + // Embedding is the embedding model or service used to convert queries into vector representations. + // Required for semantic search. + Embedding embedding.Embedder +} + +// Retriever implements the retriever interface for Pinecone vector database. +type Retriever struct { + config RetrieverConfig +} + +// NewRetriever creates a new Retriever instance with the given configuration. +// It validates the configuration and the Pinecone index. +func NewRetriever(ctx context.Context, config *RetrieverConfig) (*Retriever, error) { + if err := config.check(); err != nil { + return nil, err + } + + index, err := config.Client.DescribeIndex(ctx, config.IndexName) + if err != nil { + return nil, fmt.Errorf("[NewRetriever] failed to describe index: %w", err) + } + + if err := config.validateIndex(index); err != nil { + return nil, fmt.Errorf("[NewRetriever] failed to validate index, err: %w", err) + } + + return &Retriever{ + config: *config, + }, nil +} + +// Retrieve performs a search in Pinecone using the provided query string and options. +// It returns a list of matching documents. +func (r *Retriever) Retrieve(ctx context.Context, query string, opts ...retriever.Option) (docs []*schema.Document, err error) { + // get common options + co := retriever.GetCommonOptions(&retriever.Options{ + Index: &r.config.IndexName, + TopK: &r.config.TopK, + ScoreThreshold: &r.config.ScoreThreshold, + Embedding: r.config.Embedding, + }, opts...) + + ctx = callbacks.EnsureRunInfo(ctx, r.GetType(), components.ComponentOfRetriever) + // callback info on start + ctx = callbacks.OnStart(ctx, &retriever.CallbackInput{ + Query: query, + TopK: *co.TopK, + ScoreThreshold: co.ScoreThreshold, + Extra: map[string]any{ + "metric_type": r.config.MetricType, + }, + }) + // callback on error + defer func() { + if err != nil { + callbacks.OnError(ctx, err) + } + }() + + // get the embedding vector + emb := co.Embedding + if emb == nil { + return nil, fmt.Errorf("[pinecone retriever] embedding not provided") + } + + embeddingQuery, err := r.embeddingQuery(ctx, emb, query) + if err != nil { + return nil, fmt.Errorf("[pinecone retriever] failed to embedding query, err: %w", err) + } + + queryVec, err := r.config.VectorConverter(ctx, embeddingQuery) + if err != nil { + return nil, fmt.Errorf("[pinecone retriever] failed to convert vector: %w", err) + } + + // search on pinecone index + index, err := r.config.Client.DescribeIndex(ctx, r.config.IndexName) + if err != nil { + return nil, fmt.Errorf("[pinecone retriever] failed to describe index, err: %w", err) + } + indexConn, err := r.config.Client.Index(pc.NewIndexConnParams{ + Host: index.Host, + Namespace: r.config.Namespace, + }) + if err != nil { + return nil, fmt.Errorf("[pinecone retriever] failed to create IndexConnection for Host: %w", err) + } + pcResp, err := indexConn.QueryByVectorValues(ctx, &pc.QueryByVectorValuesRequest{ + Vector: queryVec, + TopK: uint32(r.config.TopK), + IncludeValues: true, + IncludeMetadata: true, + }) + if err != nil { + return nil, fmt.Errorf("[pinecone retriever] error encountered when querying by vector: %w", err) + } + // check the search result + if len(pcResp.Matches) == 0 { + return nil, fmt.Errorf("[pinecone retriever] no results found") + } + + // convert the search result to schema.Document + documents := make([]*schema.Document, 0, len(pcResp.Matches)) + for _, record := range pcResp.Matches { + if co.ScoreThreshold != nil && float64(record.Score) < *co.ScoreThreshold { + continue + } + document, err := r.config.DocumentConverter(ctx, record.Vector, r.config.Field) + if err != nil { + return nil, fmt.Errorf("[pinecone retriever] failed to convert search result to schema.Document: %w", err) + } + documents = append(documents, document) + } + + // callback info on end + callbacks.OnEnd(ctx, &retriever.CallbackOutput{Docs: documents}) + + return documents, nil +} + +func (r *Retriever) GetType() string { + return typ +} + +func (r *Retriever) IsCallbacksEnabled() bool { + return true +} + +// embeddingQuery generates an embedding vector for the query using the provided embedder. +func (r *Retriever) embeddingQuery(ctx context.Context, embedder embedding.Embedder, query string) ([]float64, error) { + // embedding the query + vectors, err := embedder.EmbedStrings(r.makeEmbeddingCtx(ctx, embedder), []string{query}) + if err != nil { + return nil, fmt.Errorf("[pinecone retriever] embedding has error: %w", err) + } + + // check the embedding result + if len(vectors) != 1 { + return nil, fmt.Errorf("[pinecone retriever] invalid return length of vector, got=%d, expected=1", len(vectors)) + } + + return vectors[0], nil +} + +func (conf *RetrieverConfig) validateIndex(index *pc.Index) error { + if index.Metric != conf.MetricType { + return fmt.Errorf("[validate] index metric and config metric mismatch, index: %s, config: %s", index.Metric, conf.MetricType) + } + return nil +} + +func (rc *RetrieverConfig) check() error { + if rc.Client == nil { + return fmt.Errorf("[NewRetriever] milvus client not provided") + } + if rc.Embedding == nil { + return fmt.Errorf("[NewRetriever] embedding not provided") + } + if rc.ScoreThreshold < 0 { + return fmt.Errorf("[NewRetriever] invalid search params") + } + if rc.IndexName == "" { + rc.IndexName = defaultIndexName + } + if rc.Namespace == "" { + rc.Namespace = defaultNamespace + } + if rc.MetricType == "" { + rc.MetricType = defaultMetricType + } + if rc.Field == "" { + rc.Field = defaultField + } + if rc.TopK == 0 { + rc.TopK = defaulttopK + } + if rc.VectorConverter == nil { + rc.VectorConverter = defaultVectorConverter() + } + if rc.DocumentConverter == nil { + rc.DocumentConverter = defaultDocumentConverter() + } + return nil +} diff --git a/components/retriever/pinecone/retriever_test.go b/components/retriever/pinecone/retriever_test.go new file mode 100644 index 000000000..1f616595e --- /dev/null +++ b/components/retriever/pinecone/retriever_test.go @@ -0,0 +1,269 @@ +/* + * Copyright 2025 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pinecone + +import ( + "context" + "fmt" + "testing" + + . "github.com/bytedance/mockey" + "github.com/cloudwego/eino/components/embedding" + "github.com/cloudwego/eino/schema" + pc "github.com/pinecone-io/go-pinecone/v3/pinecone" + "github.com/smartystreets/goconvey/convey" + "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/structpb" +) + +type mockEmbedding struct{} + +func (m *mockEmbedding) EmbedStrings( + ctx context.Context, + texts []string, + opts ...embedding.Option, +) ([][]float64, error) { + result := make([][]float64, len(texts)) + for i := range texts { + result[i] = []float64{0.1, 0.2, 0.3, 0.4} + } + return result, nil +} + +func TestNewRetriever(t *testing.T) { + PatchConvey("test NewRetriever", t, func() { + ctx := context.Background() + Mock(pc.NewClient).Return(&pc.Client{}, nil).Build() + + mockClient, _ := pc.NewClient(pc.NewClientParams{}) + mockDim := int32(4) + mockName := "test-store" + mockIndex := &pc.Index{ + Name: mockName, + Metric: defaultMetricType, + Dimension: &mockDim, + Tags: &pc.IndexTags{ + "mockTag": "mockValue", + }, + } + mockEmb := &mockEmbedding{} + + Mock(GetMethod(mockClient, "DescribeIndex")). + To(func(ctx context.Context, idxName string) (*pc.Index, error) { + if idxName == mockName { + return mockIndex, nil + } else { + return nil, fmt.Errorf("mockDescribeIndex not found index: %s", idxName) + } + }).Build() + + PatchConvey("test retriever config check", func() { + PatchConvey("test client not provided", func() { + retriever, err := NewRetriever(ctx, &RetrieverConfig{}) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewRetriever] milvus client not provided")) + convey.So(retriever, convey.ShouldBeNil) + }) + + PatchConvey("test embedding not provided", func() { + retriever, err := NewRetriever(ctx, &RetrieverConfig{ + Client: mockClient, + }) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewRetriever] embedding not provided")) + convey.So(retriever, convey.ShouldBeNil) + }) + + PatchConvey("test ScoreThreshold is illegal", func() { + retriever, err := NewRetriever(ctx, &RetrieverConfig{ + Client: mockClient, + Embedding: mockEmb, + ScoreThreshold: -1, + }) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewRetriever] invalid search params")) + convey.So(retriever, convey.ShouldBeNil) + }) + }) + + PatchConvey("test retriever index validate", func() { + PatchConvey("test index metric type mismatch", func() { + mockMetricType := pc.Euclidean + retriever, err := NewRetriever(ctx, &RetrieverConfig{ + Client: mockClient, + Embedding: mockEmb, + IndexName: mockName, + MetricType: mockMetricType, + }) + expectedErr := fmt.Errorf("[validate] index metric and config "+ + "metric mismatch, index: %s, config: %s", defaultMetricType, mockMetricType) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[NewRetriever] failed to validate index, "+ + "err: %w", expectedErr)) + convey.So(retriever, convey.ShouldBeNil) + }) + }) + }) +} + +func TestRetriever_Retrieve(t *testing.T) { + PatchConvey("test Retriever.Retrieve", t, func() { + ctx := context.Background() + Mock(pc.NewClient).Return(&pc.Client{}, nil).Build() + + mockClient, _ := pc.NewClient(pc.NewClientParams{}) + mockDim := int32(4) + mockName := "test-store" + mockIndex := &pc.Index{ + Name: mockName, + Metric: defaultMetricType, + Dimension: &mockDim, + Tags: &pc.IndexTags{ + "mockTag": "mockValue", + }, + } + mockEmb := &mockEmbedding{} + mockQuery := "pinecone" + + Mock(GetMethod(mockClient, "DescribeIndex")). + To(func(ctx context.Context, idxName string) (*pc.Index, error) { + if idxName == mockName { + return mockIndex, nil + } else { + return nil, fmt.Errorf("mockDescribeIndex not found index: %s", idxName) + } + }).Build() + + retriever, err := NewRetriever(ctx, &RetrieverConfig{ + Client: mockClient, + Embedding: mockEmb, + IndexName: mockName, + }) + convey.So(err, convey.ShouldBeNil) + convey.So(retriever, convey.ShouldNotBeNil) + + PatchConvey("test retriever check", func() { + PatchConvey("test embedding is not provided", func() { + retriever.config.Embedding = nil + docs, err := retriever.Retrieve(ctx, mockQuery) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[pinecone retriever] embedding not provided")) + convey.So(docs, convey.ShouldBeEmpty) + }) + + PatchConvey("test describe index mismatch", func() { + mockErr := fmt.Errorf("mockDescribeIndex not found index") + Mock(GetMethod(mockClient, "DescribeIndex")). + To(func(ctx context.Context, idxName string) (*pc.Index, error) { + return nil, mockErr + }).Build() + + docs, err := retriever.Retrieve(ctx, mockQuery) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[pinecone retriever] "+ + "failed to describe index, err: %w", mockErr)) + convey.So(docs, convey.ShouldBeEmpty) + }) + + PatchConvey("test create index connection failed", func() { + mockErr := fmt.Errorf("mock create index connection failed") + Mock(GetMethod(mockClient, "Index")). + To(func(in pc.NewIndexConnParams, dialOpts ...grpc.DialOption) (*pc.IndexConnection, error) { + return nil, mockErr + }).Build() + + docs, err := retriever.Retrieve(ctx, mockQuery) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[pinecone retriever] "+ + "failed to create IndexConnection for Host: %w", mockErr)) + convey.So(docs, convey.ShouldBeEmpty) + }) + }) + + PatchConvey("test query pinecone", func() { + mockIndexConn := &pc.IndexConnection{} + Mock(GetMethod(mockClient, "Index")). + To(func(in pc.NewIndexConnParams, dialOpts ...grpc.DialOption) (*pc.IndexConnection, error) { + return mockIndexConn, nil + }).Build() + + PatchConvey("test query failed", func() { + mockErr := fmt.Errorf("mockQueryByVectorValues failed") + Mock(GetMethod(mockIndexConn, "QueryByVectorValues")). + To(func(ctx context.Context, in *pc.QueryByVectorValuesRequest) (*pc.QueryVectorsResponse, error) { + return nil, mockErr + }).Build() + + docs, err := retriever.Retrieve(ctx, mockQuery) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[pinecone retriever] "+ + "error encountered when querying by vector: %w", mockErr)) + convey.So(docs, convey.ShouldBeEmpty) + }) + + PatchConvey("test search result number is empty", func() { + mockSearchResp := &pc.QueryVectorsResponse{ + Matches: []*pc.ScoredVector{}, + } + Mock(GetMethod(mockIndexConn, "QueryByVectorValues")). + To(func(ctx context.Context, in *pc.QueryByVectorValuesRequest) (*pc.QueryVectorsResponse, error) { + return mockSearchResp, nil + }).Build() + + docs, err := retriever.Retrieve(ctx, mockQuery) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[pinecone retriever] no results found")) + convey.So(docs, convey.ShouldBeEmpty) + }) + + PatchConvey("test search result not contain content meta", func() { + mockMeta, _ := structpb.NewStruct(map[string]any{}) + mockSearchResp := &pc.QueryVectorsResponse{ + Matches: []*pc.ScoredVector{ + &pc.ScoredVector{Vector: &pc.Vector{Id: "mockId1", Metadata: mockMeta}}, + &pc.ScoredVector{Vector: &pc.Vector{Id: "mockId2", Metadata: mockMeta}}, + }, + } + Mock(GetMethod(mockIndexConn, "QueryByVectorValues")). + To(func(ctx context.Context, in *pc.QueryByVectorValuesRequest) (*pc.QueryVectorsResponse, error) { + return mockSearchResp, nil + }).Build() + + docs, err := retriever.Retrieve(ctx, mockQuery) + convey.So(err, convey.ShouldBeError, fmt.Errorf("[pinecone retriever] "+ + "failed to convert search result to schema.Document: "+ + "[converter] content field not found, field: %s", defaultField)) + convey.So(docs, convey.ShouldBeEmpty) + }) + + PatchConvey("test search success", func() { + mockMeta, _ := structpb.NewStruct(map[string]any{ + defaultField: "mockContent", + }) + mockSearchResp := &pc.QueryVectorsResponse{ + Matches: []*pc.ScoredVector{ + &pc.ScoredVector{Vector: &pc.Vector{Id: "mockId1", Metadata: mockMeta}}, + &pc.ScoredVector{Vector: &pc.Vector{Id: "mockId2", Metadata: mockMeta}}, + }, + } + mockResult := []*schema.Document{ + &schema.Document{ID: "mockId1", Content: "mockContent", MetaData: make(map[string]any)}, + &schema.Document{ID: "mockId2", Content: "mockContent", MetaData: make(map[string]any)}, + } + Mock(GetMethod(mockIndexConn, "QueryByVectorValues")). + To(func(ctx context.Context, in *pc.QueryByVectorValuesRequest) (*pc.QueryVectorsResponse, error) { + return mockSearchResp, nil + }).Build() + + docs, err := retriever.Retrieve(ctx, mockQuery) + convey.So(err, convey.ShouldBeNil) + convey.So(docs, convey.ShouldEqual, mockResult) + }) + }) + }) +} diff --git a/components/retriever/pinecone/utils.go b/components/retriever/pinecone/utils.go new file mode 100644 index 000000000..0c10aab66 --- /dev/null +++ b/components/retriever/pinecone/utils.go @@ -0,0 +1,74 @@ +/* + * Copyright 2025 CloudWeGo Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pinecone + +import ( + "context" + "fmt" + + "github.com/cloudwego/eino/callbacks" + "github.com/cloudwego/eino/components" + "github.com/cloudwego/eino/components/embedding" + "github.com/cloudwego/eino/schema" + pc "github.com/pinecone-io/go-pinecone/v3/pinecone" +) + +// makeEmbeddingCtx makes the embedding context +func (r *Retriever) makeEmbeddingCtx(ctx context.Context, emb embedding.Embedder) context.Context { + runInfo := &callbacks.RunInfo{ + Component: components.ComponentOfEmbedding, + } + + if embType, ok := components.GetType(emb); ok { + runInfo.Type = embType + } + + runInfo.Name = runInfo.Type + string(runInfo.Component) + + return callbacks.ReuseHandlers(ctx, runInfo) +} + +func defaultVectorConverter() func(ctx context.Context, vector []float64) ([]float32, error) { + return func(ctx context.Context, vector []float64) ([]float32, error) { + vec := make([]float32, 0, len(vector)) + for _, value := range vector { + vec = append(vec, float32(value)) + } + return vec, nil + } +} + +func defaultDocumentConverter() func(ctx context.Context, vector *pc.Vector, field string) (*schema.Document, error) { + return func(ctx context.Context, vector *pc.Vector, field string) (*schema.Document, error) { + data := vector.Metadata.AsMap() + if _, exists := data[field]; !exists { + return nil, fmt.Errorf("[converter] content field not found, field: %s", field) + } + content := data[field].(string) + meta := make(map[string]any) + for k, v := range data { + if k != field { + meta[k] = v + } + } + return &schema.Document{ + ID: vector.Id, + Content: content, + MetaData: meta, + }, nil + } +}