Skip to content

Commit bc7be9f

Browse files
committed
fix http client baseUri
1 parent b5690ca commit bc7be9f

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/RAG/PostProcessor/JinaRerankerPostProcessor.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
use NeuronAI\RAG\Document;
1414

1515
use function array_map;
16-
use function trim;
1716

1817
class JinaRerankerPostProcessor implements PostProcessorInterface
1918
{
2019
use HasHttpClient;
2120

22-
protected string $host = 'https://api.jina.ai/v1/';
21+
protected string $host = 'https://api.jina.ai/v1';
2322

2423
public function __construct(
2524
protected string $key,
@@ -28,7 +27,7 @@ public function __construct(
2827
?HttpClientInterface $httpClient = null,
2928
) {
3029
$this->httpClient = ($httpClient ?? new GuzzleHttpClient())
31-
->withBaseUri(trim($this->host, '/').'/')
30+
->withBaseUri($this->host)
3231
->withHeaders([
3332
'Accept' => 'application/json',
3433
'Content-Type' => 'application/json',

src/RAG/PostProcessor/LocalAIRerankerPostProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(
2727
?HttpClientInterface $httpClient = null,
2828
) {
2929
$this->httpClient = ($httpClient ?? new GuzzleHttpClient())
30-
->withBaseUri(trim($host, '/').'/v1/')
30+
->withBaseUri(trim($host, '/').'/v1')
3131
->withHeaders([
3232
'Accept' => 'application/json',
3333
'Content-Type' => 'application/json',

src/RAG/VectorStore/QdrantVectorStore.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use function array_map;
1515
use function in_array;
1616
use function is_null;
17-
use function trim;
1817
use function array_chunk;
1918

2019
class QdrantVectorStore implements VectorStoreInterface
@@ -32,7 +31,7 @@ public function __construct(
3231
?HttpClientInterface $httpClient = null,
3332
) {
3433
$this->httpClient = ($httpClient ?? new GuzzleHttpClient())
35-
->withBaseUri(trim($this->collectionUrl, '/').'/')
34+
->withBaseUri($this->collectionUrl)
3635
->withHeaders([
3736
'Content-Type' => 'application/json',
3837
...(!is_null($this->key) && $this->key !== '' ? ['api-key' => $this->key] : [])
@@ -47,7 +46,7 @@ public function __construct(
4746
protected function initialize(): void
4847
{
4948
$response = $this->httpClient->request(
50-
HttpRequest::get('exists')
49+
HttpRequest::get(uri: 'exists')
5150
)->json();
5251

5352
if ($response['result']['exists']) {
@@ -62,7 +61,7 @@ protected function initialize(): void
6261
*/
6362
public function destroy(): void
6463
{
65-
$this->httpClient->request(HttpRequest::delete(''));
64+
$this->httpClient->request(HttpRequest::delete(uri: ''));
6665
}
6766

6867
/**
@@ -96,7 +95,7 @@ public function addDocuments(array $documents): VectorStoreInterface
9695

9796
foreach ($chunks as $chunk) {
9897
$this->httpClient->request(
99-
HttpRequest::put('points', ['points' => $chunk])
98+
HttpRequest::put(uri: 'points', body: ['points' => $chunk])
10099
);
101100
}
102101

@@ -173,6 +172,9 @@ public function similaritySearch(array $embedding): iterable
173172
}, $response['result']['points']);
174173
}
175174

175+
/**
176+
* @throws HttpException
177+
*/
176178
protected function createCollection(): void
177179
{
178180
$this->httpClient->request(

0 commit comments

Comments
 (0)