pineconego

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 6 Imported by: 1

README

Unofficial Pinecone Go SDK

GoDoc Go Report Card GitHub release

This is Pinecone's unofficial Go client, designed to enable you to use Pinecone's services easily from your own applications.

Pinecone

Pinecone is a managed, cloud-native vector database that allows you to build high-performance vector search applications.

API support

Index Operations Status Vector Operations Status
List Collections 🟢 DescribeIndexStats 🟢
Create Collection 🟢 Query 🟢
Describe Collection 🟢 Delete 🟢
Delete Collection 🟢 Fetch 🟢
List Indexes 🟢 Update 🟢
Create Index 🟢 Upsert 🟢
Describe Index 🟢 Whoami 🟢
Delete Index 🟢
Configure Index 🟢

Getting started

Installation

You can load pinecone-go into your project by using:

go get github.com/henomis/pinecone-go
Configuration

The only thing you need to start using Pinecone's APIs is the developer API key and related environment. Copy and paste them in the corresponding place in the code, select the API and the parameters you want to use, and that's it.

Usage

Please refer to the examples folder to see how to use the SDK.

Here below a simple usage example:

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	pineconego "github.com/henomis/pinecone-go"
	"github.com/henomis/pinecone-go/request"
	"github.com/henomis/pinecone-go/response"
)

func main() {

	apiKey := os.Getenv("PINECONE_API_KEY")
	if apiKey == "" {
		panic("PINECONE_API_KEY is not set")
	}

	environment := os.Getenv("PINECONE_ENVIRONMENT")
	if environment == "" {
		panic("PINECONE_ENVIRONMENT is not set")
	}

	p := pineconego.New(environment, apiKey)

	metric := request.MetricCosine
	pods := 1
	replicas := 1
	podType := "s1.x1"
	req := &request.IndexCreate{
		Name:      "test-index",
		Dimension: 10,
		Metric:    &metric,
		Pods:      &pods,
		Replicas:  &replicas,
		PodType:   &podType,
		MetadataConfig: map[string]interface{}{
			"key1": "value1",
		},
	}
	res := &response.IndexCreate{}
	err := p.IndexCreate(context.Background(), req, res)
	if err != nil {
		panic(err)
	}

	if !res.IsSuccess() {
		if res.Response.Code != nil {
			fmt.Printf("Error: %d -", *res.Response.Code)
		}

		if res.Response.Message != nil {
			fmt.Printf(" %s\n", *res.Response.Message)
		}

		if res.Response.RawBody != nil {
			fmt.Printf(" %s\n", *res.Response.RawBody)
		}

		return
	}

	b, err := json.MarshalIndent(res, "", "  ")
	if err != nil {
		panic(err)
	}

	fmt.Println(string(b))

}

Who uses pinecone-go?

  • LinGoose Go framework for building awesome LLM apps

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PineconeGo

type PineconeGo struct {
	// contains filtered or unexported fields
}

func New

func New(environment, apiKey string) *PineconeGo

func (*PineconeGo) IndexConfigure

func (p *PineconeGo) IndexConfigure(
	ctx context.Context,
	req *request.IndexConfigure,
	res *response.IndexConfigure,
) error

func (*PineconeGo) IndexCreate

func (p *PineconeGo) IndexCreate(
	ctx context.Context,
	req *request.IndexCreate,
	res *response.IndexCreate,
) error

func (*PineconeGo) IndexCreateCollection

func (p *PineconeGo) IndexCreateCollection(
	ctx context.Context,
	req *request.IndexCreateCollection,
	res *response.IndexCreateCollection,
) error

func (*PineconeGo) IndexDelete

func (p *PineconeGo) IndexDelete(
	ctx context.Context,
	req *request.IndexDelete,
	res *response.IndexDelete,
) error

func (*PineconeGo) IndexDeleteCollection

func (p *PineconeGo) IndexDeleteCollection(
	ctx context.Context,
	req *request.IndexDeleteCollection,
	res *response.IndexDeleteCollection,
) error

func (*PineconeGo) IndexDescribe

func (p *PineconeGo) IndexDescribe(
	ctx context.Context,
	req *request.IndexDescribe,
	res *response.IndexDescribe,
) error

func (*PineconeGo) IndexDescribeCollection

func (p *PineconeGo) IndexDescribeCollection(
	ctx context.Context,
	req *request.IndexDescribeCollection,
	res *response.IndexDescribeCollection,
) error

func (*PineconeGo) IndexList

func (p *PineconeGo) IndexList(
	ctx context.Context,
	req *request.IndexList,
	res *response.IndexList,
) error

func (*PineconeGo) IndexListCollections

func (p *PineconeGo) IndexListCollections(
	ctx context.Context,
	req *request.IndexListCollections,
	res *response.IndexListCollections,
) error

func (*PineconeGo) VectorDelete

func (p *PineconeGo) VectorDelete(
	ctx context.Context,
	req *request.VectorDelete,
	res *response.VectorDelete,
) error

func (*PineconeGo) VectorDescribeIndexStats

func (p *PineconeGo) VectorDescribeIndexStats(
	ctx context.Context,
	req *request.VectorDescribeIndexStats,
	res *response.VectorDescribeIndexStats,

) error

func (*PineconeGo) VectorFetch

func (p *PineconeGo) VectorFetch(
	ctx context.Context,
	req *request.VectorFetch,
	res *response.VectorFetch,
) error

func (*PineconeGo) VectorQuery

func (p *PineconeGo) VectorQuery(
	ctx context.Context,
	req *request.VectorQuery,
	res *response.VectorQuery,
) error

func (*PineconeGo) VectorUpdate

func (p *PineconeGo) VectorUpdate(
	ctx context.Context,
	req *request.VectorUpdate,
	res *response.VectorUpdate,
) error

func (*PineconeGo) VectorUpsert

func (p *PineconeGo) VectorUpsert(ctx context.Context, req *request.VectorUpsert, res *response.VectorUpsert) error

func (*PineconeGo) Whoami

func (p *PineconeGo) Whoami(ctx context.Context, req *request.Whoami, res *response.Whoami) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL