Created
February 24, 2024 05:14
-
-
Save hkulekci/c113012a865161b88eaa70dc7da89f25 to your computer and use it in GitHub Desktop.
Qdrant Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
'host' => env('QDRANT_HOST', 'http://127.0.0.1:6333'), | |
'api_key' => env('QDRANT_API_KEY', null), | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @since Apr 2023 | |
* @author Haydar KULEKCI <[email protected]> | |
*/ | |
namespace App\Providers; | |
use Illuminate\Contracts\Support\DeferrableProvider; | |
use Illuminate\Support\ServiceProvider; | |
use Qdrant\Config; | |
use Qdrant\Http\GuzzleClient; | |
use Qdrant\Qdrant; | |
class QdrantServiceProvider extends ServiceProvider implements DeferrableProvider | |
{ | |
/** | |
* Register the service provider. | |
* | |
* @return void | |
*/ | |
public function register(): void | |
{ | |
$this->app->singleton('qdrant.connection', function ($app) { | |
$config = new Config(config('qdrant.host')); | |
if (config('qdrant.api_key')) { | |
$config->setApiKey(config('qdrant.api_key')); | |
} | |
return new GuzzleClient($config); | |
}); | |
$this->app->singleton(Qdrant::class, function ($app) { | |
return new Qdrant($app['qdrant.connection']); | |
}); | |
} | |
/** | |
* Get the services provided by the provider. | |
* | |
* @return array | |
*/ | |
public function provides(): array | |
{ | |
return [Qdrant::class, 'qdrant.connection']; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment