Skip to content

Commit

Permalink
feat: add voyager.ai to supported providers
Browse files Browse the repository at this point in the history
  • Loading branch information
bernard-ng committed Nov 21, 2024
1 parent 01e2fb4 commit dfad6c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Provider/Service/Client/VoyagerClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,19 @@ public function rerank(string $prompt, array $documents, RerankingConfig $config
Assert::notEmpty($prompt);
Assert::allNotEmpty($documents);

$mapper = function (Document|string $document): string {
if ($document instanceof Document) {
return $document->content;
}

return $document;
};

try {
/** @var array{results: array<array{document: string, relevance_score: float}>} $response */
$response = $this->http->request('POST', 'rerank', [
'json' => [
'model' => $config->model,
'top_k' => $config->topK,
'documents' => array_map($mapper(...), $documents),
'documents' => array_map(
fn (Document|string $document): string => match (true) {
$document instanceof Document => $document->content,
default => $document,
},
$documents
),
'query' => $prompt,
],
])->toArray();
Expand Down
1 change: 1 addition & 0 deletions src/Provider/SupportedProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ enum SupportedProvider: string
case OLLAMA = 'ollama';
case GITHUB = 'github';
case ANTHROPIC = 'anthropic';
case VOYAGER = 'voyager';
}

0 comments on commit dfad6c4

Please sign in to comment.