hyperf / qdrant-client
Fund package maintenance!
Open Collective
hyperf.wiki/#/zh-cn/donate
Installs: 1 588
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 4
Forks: 2
Open Issues: 0
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^7.7
- guzzlehttp/psr7: ^2.5
- hyperf/utils: ~2.2.0 || ~3.0.0 || ~3.1.0
- psr/http-client: ^1.0
- psr/http-message: ^1.0|^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: >=7.0
- vlucas/phpdotenv: ^5.0
This package is auto-updated.
Last update: 2024-10-15 21:57:00 UTC
README
Install
composer require hyperf/qdrant-client
Usage
An example to create a collection:
use App\VectorStore\Qdrant\Config; use Hyperf\Qdrant\Api\Collections; use Hyperf\Qdrant\Api\Points; use Hyperf\Qdrant\Connection\HttpClient; use Hyperf\Qdrant\Struct\Collections\Enums\Distance; use Hyperf\Qdrant\Struct\Collections\VectorParams; use Hyperf\Qdrant\Struct\Points\ExtendedPointId; use Hyperf\Qdrant\Struct\Points\Point\PointStruct; use Hyperf\Qdrant\Struct\Points\SearchCondition\FieldCondition; use Hyperf\Qdrant\Struct\Points\SearchCondition\Filter; use Hyperf\Qdrant\Struct\Points\SearchCondition\Match\MatchValue; use Hyperf\Qdrant\Struct\Points\VectorStruct; $client = new HttpClient(new Config(...)); $collections = new Collections($client); $collections->createCollection('test_collection', new VectorParams(1536, Distance::COSINE)); # insert vector data $points = new Points($client); $points->setWait(true); $points->upsertPoints('test_collection', [ new PointStruct( new ExtendedPointId($key + 10000), new VectorStruct($data['embeddings'][0]), [ # payload 'name' => $data['name'], 'description' => $data['description'], 'image' => $data['image'], ], ), ]); # similarity search $result = $points->searchPoints( 'test_collection', new VectorStruct($data['embeddings'][0]), 3, withPayload: new WithPayload(true), ); print_r($result); # payload filter $result = $points->searchPoints( 'test_collection', new VectorStruct($data['embeddings'][0]), 3, new Filter( must: [ new FieldCondition('name', new MatchValue('qdrant')), ] ), withPayload: new WithPayload(true), ); print_r($result);