pinecone 0.1.0 copy "pinecone: ^0.1.0" to clipboard
pinecone: ^0.1.0 copied to clipboard

Unofficial Dart client for Pinecone vector database

pinecone #

Pub

pinecone is an unofficial Dart client for your managed Pinecone vector database instance.

Is this package actively maintained? #

Yes! This package is used in production applications and is actively maintained!

API Reference #

For detailed API information, please see the official Pinecone API reference. This package is a thin wrapper around the official API and aims to have full parity with the official API.

Client Instance #

To create a client instance you will need your API key and the environment name of your Pinecone project. You can find your API key and project environment in the Pinecone console.

final client = PineconeClient(
  apiKey: '123-456-789',
  environment: 'us-west1-gcp-free',
);

Once the client is created, you can access the index and vector operations APIs respectively:

// Access the index operations API
client.index;

// Access the vector operations API
client.vector(host:host);

Index Operations #

List Indexes #

Official Documentation: list_indexes

List<String> names = await client.index.listIndexes();

Create Index #

Official Documentation: create_index

await client.index.createIndex(
  body: IndexDefinition(
    name: 'my-index',
    dimension: 1536,
  ),
);

Describe Index #

Official Documentation: describe_index

final Index index = await client.index.describeIndex(
  indexName: 'my-index',
);

Delete Index #

Official Documentation: delete_index

await client.index.deleteIndex(
  indexName: 'my-index',
);

Configure Index #

Official Documentation: configure_index

await client.index.configureIndex(
  body: IndexConfiguration(
    podType: 's1.x2',
    replicas: 3,
  ),
);

List Collections #

Official Documentation: list_collections

List<String> names = await client.index.listCollections();

Create Collection #

Official Documentation: create_collection

await client.index.createCollection(
  body: CollectionDefinition(
    name: 'my-collection',
    source: 'my-index'
  ),
);

Describe Collection #

Official Documentation: describe_collection

final Collection collection = await client.index.describeCollection(
  collectionName: 'my-collection'
);

Delete Collection #

Official Documentation: delete_collection

await client.index.deleteCollection(
  collectionName: 'my-collection'
);

Vector Operations #

In order to use the vector operations API, you must provide the host name of your specified index. The host name will look something like the following:

my-index-e345e78.svc.us-west1-gcp-free.pinecone.io

To retrieve the host name, you can use the describeIndex method:

final Index index = await client.index.describeIndex(
  indexName: 'my-index',
);

// The host name is the `status.host` property
final String host = index.status.host;

Describe Index Stats #

Official Documentation: describe_index_stats_post

final DescribeIndexStatsResponse res =
    await client.vector(host: host).describeIndexStats(
          body: DescribeIndexStatsRequest(),
        );

Query #

Official Documentation: query

final QueryResponse res = await client.vector(host: host).query(
      body: QueryRequest(
        topK: 5,
        namespace: 'my-namespace',
        includeValues: false,
        includeMetadata: false,
        vector: [1, 2, 3],
      ),
    );

Delete #

Official Documentation: delete

final DeleteResponse res = await client.vector(host: host).delete(
      body: DeleteRequest(
        ids: ['id-1', 'id-2', 'id-3'],
        namespace: 'my-namespace',
      ),
    );

Fetch #

Official Documentation: fetch

final FetchResponse res = await client.vector(host: host).fetch(
      body: FetchRequest(
        ids: [],
        namespace: 'my-namespace',
      ),
    );

Update #

Official Documentation: update

final UpdateResponse res = await client.vector(host: host).update(
      body: UpdateRequest(
        id: 'id-1',
        namespace: 'my-namespace',
        values: [1, 2, 3],
      ),
    );

Upsert #

Official Documentation: upsert

final UpsertResponse res = await client.vector(host: host).upsert(
      body: UpsertRequest(
        vectors: [
          UpsertVector(
            id: 'id-1',
            values: [1, 2, 3],
          ),
          UpsertVector(
            id: 'id-2',
            values: [4, 5, 6],
          ),
        ],
        namespace: 'my-namespace',
      ),
    );

Contributing #

Please see the pinecone Github repository.

6
likes
0
pub points
79%
popularity

Publisher

verified publishertazatechnology.com

Unofficial Dart client for Pinecone vector database

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (LICENSE)

Dependencies

dio, json_annotation, retrofit

More

Packages that depend on pinecone