wontonee/laravel-qdrant-sdk
最新稳定版本:1.0.1
Composer 安装命令:
composer require wontonee/laravel-qdrant-sdk
包简介
Laravel SDK for Qdrant vector database with embedders like OpenAI and Gemini
README 文档
README
Laravel Qdrant SDK is a Laravel package that provides a simple, expressive interface for working with the Qdrant vector database. It supports collection management, vector upserts, similarity search, and integration with embedders like OpenAI and Gemini.
Features
- Create, update, delete, and list Qdrant collections
- Upsert and manage vector points
- Perform similarity search and recommendations
- Easily integrate with OpenAI or Gemini for vector embeddings
- Simple trait for adding vector support to Eloquent models
Installation
-
Require the package:
composer require wontonee/laravel-qdrant-sdk
-
Publish the config:
php artisan vendor:publish --provider="Wontonee\LarQ\Providers\LarQServiceProvider" --tag=larq-config -
Set your .env variables:
LARQ_HOST=http://localhost:6333 LARQ_API_KEY= OPENAI_API_KEY=sk-... OPENAI_MODEL=text-embedding-ada-002 GEMINI_API_KEY=... GEMINI_MODEL=models/embedding-001
-
Run Qdrant with persistent storage (recommended for local dev):
docker run -p 6333:6333 -v $(pwd)/qdrant_storage:/qdrant/storage qdrant/qdrant
Usage
Creating a Collection
use Wontonee\LarQ\Qdrant\Collections\CreateCollection; $vectorParams = [ 'size' => 3, 'distance' => 'Cosine', ]; $response = (new CreateCollection())->handle('my_collection', $vectorParams);
Upserting Points
use Wontonee\LarQ\Qdrant\Points\UpsertPoints; $points = [ [ 'id' => 1, 'vector' => [0.1, 0.2, 0.3], 'payload' => ['label' => 'A'], ], ]; $response = (new UpsertPoints())->handle('my_collection', $points);
Scrolling Points
use Wontonee\LarQ\Qdrant\Points\ScrollPoints; $response = (new ScrollPoints())->handle('my_collection', 10);
Listing All Collections
use Wontonee\LarQ\Qdrant\Collections\ListCollections; $response = (new ListCollections())->handle();
Using the HasVectors Trait
Add vector support to your Eloquent model:
use Wontonee\LarQ\Traits\HasVectors; class Product extends Model { use HasVectors; // Optionally override vectorText(), vectorPayload(), etc. }
Example Controller Test
See QdrantDemoController for a full example of creating a collection, upserting points, and listing them.
Troubleshooting
- Data disappears after restart: Make sure Qdrant is running with persistent storage (see above).
- Connection issues: Check your
LARQ_HOSTand API key settings in.env.
License
MIT
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-27