承接 darcher/pinecone-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

darcher/pinecone-php

Composer 安装命令:

composer require darcher/pinecone-php

包简介

Pinecode API Client in PHP

README 文档

README

This PHP Pinecone API Client is a powerful and easy-to-use library that allows you to interact with the Pinecone vector database. Pinecone is a scalable and high-performance vector database designed to store, search, and manage large volumes of high-dimensional vectors.

This library offers a convenient and efficient way to interact with Pinecone using PHP.

Getting Started

Prerequisites

To use this package, you will need to have PHP 8.1 or higher installed on your machine. You will also need to have a Pinecone account and an API key.

Installation

To install the package, you can use composer:

composer require darcher/pinecone-php

Usage

Index

To get started, you will need to create an instance of the IndexApi class:

use Darcher\PineconePhp\IndexApi;

$apiKey = 'your-api-key';
$environment = 'us-west1-gcp';

$pinecone = IndexApi::build($apiKey, $environment);

Once you have an instance of the IndexApi class, you can use it to perform various operations on your Pinecone indexes. For example, you can list all of your indexes:

$indexes = $pinecone->list();

You can also create a new index:

$name = 'my-new-index';
$dimension = 256;

$response = $pinecone->create($name, $dimension);

For more information on the available methods and their parameters, please refer to the inline documentation in the IndexApi class.

Usage To get started, you will need to create an instance of the VectorApi class:

Vectors

If you don't know the host

use Darcher\PineconePhp\VectorApi;

$apiKey = 'your-api-key';
$environment = 'us-west1-gcp';
$indexName = 'your-index-name';

$pinecone = VectorApi::build($apiKey, null, $indexName, $environment);

Once you have an instance of the VectorApi class, you can use it to perform various operations on your Pinecone vectors. For example, you can query vectors by their ID:

$id = 'your-vector-id';
$topK = 10;

$response = $pinecone->queryById($id, $topK);

You can also upsert a collection of vectors:

use Darcher\PineconePhp\Vector;
use Darcher\PineconePhp\VectorCollection;

$vectors = new VectorCollection([
    new Vector('vector-id-1', [1, 2, 3]),
    new Vector('vector-id-2', [4, 5, 6]),
]);

$response = $pinecone->upsertCollection($vectors);

Or using the factory class

use Darcher\PineconePhp\VectorCollectionFactory;

$response = $pinecone->upsertCollection(VectorCollectionFactory::create([
    ['vector-id-1', [1, 2, 3]],
    ['vector-id-2', [3, 4, 5]],
]));

You can also use the upsert for a single vector

use Darcher\PineconePhp\Vector;

$response = $pinecone->upsertOne(new Vector('vector-id-1', [1, 2, 3]));

For more information on the available methods and their parameters, please refer to the inline documentation in the VectorApi class.

Contributing

If you would like to contribute to this package, please feel free to open a pull request or an issue on the GitHub repository.

License

This package is licensed under the MIT License.

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-17