承接 adrianmtanase/laravel-vector-store 相关项目开发

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

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

adrianmtanase/laravel-vector-store

最新稳定版本:1.0.1

Composer 安装命令:

composer require adrianmtanase/laravel-vector-store

包简介

Vector store abstraction layer for the Laravel framework.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides an implementation of multiple vector databases (e.g. Pinecone.io).

Support us

If this helped you, consider supporting my development over on Patreon or on Github.

Installation

Requires PHP ^8.1

composer require adrianmtanase/laravel-vector-store

Currently supports

Plans to implement

  • MySql - once it's ready

❗ If you're coming from version 0.0.25 ❗

  • Coming from version 0.0.25 you'll have to re-publish the config, as the Pinecone environment variable has been replaced with pinecone_host
php artisan vendor:publish

Usage

Using the VectorStore facade, you can easily access any provider and execute operations.

Pinecone indexes

VectorStore::instance()
           ->namespace('general')
           ->upsert(
               PineconeUpsertRequest::build()
                   ->id('1')
                   ->values([
                       -0.002739503,
                       -0.01970483,
                       -0.011307885,
                       -0.011125952,
                       -0.023119587,
                       0.0016207852,
                       -0.003981551,
                       -0.029249357,
                       0.00983842,
                       -0.023721369
                   ])
                   ->metadata([
                       'text' => 'Vector store is lit!'
                   ])
           );

The default provider is Pinecone.io, this can be easily switched using the facade VectorStore::provider(VectorStoreProviderType::PINECONE), or directly in the vector-store config.

Weaviate

As Weaviate runs through GraphQL, the query language is complex. There are several useful methods in WeaviateQueryRequest that will help you query data more efficiently. For example:

VectorStore::provider(VectorStoreProviderType::WEAVIATE)
           ->instance()
           ->namespace('general')
           ->query(
               WeaviateQueryRequest::build()
                   ->vector([
                       -0.002739503,
                       -0.01970483,
                       -0.011307885,
                       -0.011125952,
                       -0.023119587,
                       0.0016207852,
                       -0.003981551,
                       -0.029249357,
                       0.00983842,
                       -0.023721369
                   ])
                   ->properties(['text'])
                   ->withId()
                   ->withParameters(WeaviateQueryParameters::build()->group('type: closest, force: 1'))
           );

As the system is complex, the package also supports a rawQuery form, or even getting access to the underlying client.

Weaviate raw query

VectorStore::provider(VectorStoreProviderType::WEAVIATE)
           ->instance()
           ->namespace('general')
           ->rawQuery('
               {
                Get {
                  General(nearVector: {
                    vector: [
                        -0.002739503,
                       -0.01970483,
                       -0.011307885,
                       -0.011125952,
                       -0.023119587,
                       0.0016207852,
                       -0.003981551,
                       -0.029249357,
                       0.00983842,
                       -0.023721369
                    ]  
                  }) {
                    text
                  }
                }
            }
           ');

Underlying Weaviate client

VectorStore::provider(VectorStoreProviderType::WEAVIATE)
           ->instance()
           ->client()
           ->batchDelete('general') 

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-23