Skip to content

Commit 9b599f3

Browse files
committed
aws bedrock embeddings
1 parent b92b2eb commit 9b599f3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/RAG/Embeddings/AwsBedrockEmbeddingsProvider.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace NeuronAI\RAG\Embeddings;
46

57
use Aws\BedrockRuntime\BedrockRuntimeClient;
@@ -9,20 +11,20 @@ class AwsBedrockEmbeddingsProvider extends AbstractEmbeddingsProvider
911
public function __construct(
1012
protected BedrockRuntimeClient $bedrockRuntimeClient,
1113
protected string $model = 'amazon.titan-embed-text-v2:0',
12-
){
14+
) {
1315
}
1416

1517
public function embedText(string $text): array
1618
{
1719
$response = $this->bedrockRuntimeClient->invokeModel([
1820
'modelId' => $this->model,
1921
'contentType' => 'application/json',
20-
'body' => json_encode([
22+
'body' => \json_encode([
2123
'inputText' => $text,
2224
]),
2325
]);
2426

25-
$response = json_decode($response['body'], true);
27+
$response = \json_decode((string) $response['body'], true);
2628

2729
return $response['embedding'];
2830
}

0 commit comments

Comments
 (0)