Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pinecone indexer & retriever #25

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added components/indexer/.DS_Store
Binary file not shown.
60 changes: 60 additions & 0 deletions components/indexer/pinecone/examples/create_index/create_index.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2024 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"
"os"

"github.com/pinecone-io/go-pinecone/pinecone"
)

// component does not support create index, you can create index on platform or by codes below

func main() {
ctx := context.Background()
apiKey := os.Getenv("PINECONE_API_KEY")
indexName := "eino-index-test"

pc, err := pinecone.NewClient(pinecone.NewClientParams{
ApiKey: apiKey,
})
if err != nil {
panic(fmt.Errorf("failed to create client: %v", err))
}

// [dimensionality]: https://docs.pinecone.io/guides/indexes/choose-a-pod-type-and-size#dimensionality-of-vectors
// [Serverless]: https://docs.pinecone.io/guides/indexes/understanding-indexes#serverless-indexes
// [similarity]: https://docs.pinecone.io/guides/indexes/understanding-indexes#distance-metrics
// [region]: https://docs.pinecone.io/troubleshooting/available-cloud-regions
// [cloud provider]: https://docs.pinecone.io/troubleshooting/available-cloud-regions#regions-available-for-serverless-indexes
// [deletion protection]: https://docs.pinecone.io/guides/indexes/prevent-index-deletion#enable-deletion-protection
idx, err := pc.CreateServerlessIndex(ctx, &pinecone.CreateServerlessIndexRequest{
Name: indexName,
Dimension: 1024,
Metric: pinecone.Cosine, // use pinecone.Dotproduct if you need hybrid search
Cloud: pinecone.Aws,
Region: "us-east-1",
})
if err != nil {
panic(fmt.Errorf("failed to create serverless index \"%v\": %v", indexName, err))
}

fmt.Printf("Successfully created serverless index: %v", idx.Name)
// Successfully created serverless index: eino-index-test
}
Loading
Loading