Replies: 2 comments
-
You can use the current SDK and the following code <?php
use Aws\Credentials\Credentials;
use Aws\Signature\SignatureV4;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
function callBedRock($prompt) {
$endpoint = 'https://bedrock.us-east-1.amazonaws.com/model/amazon.titan-tg1-large/invoke';
$access_key = 'secrets';
$secret_key = 'secrets';
$model = 'amazon.titan-tg1-large';
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'modelId' => $model,
];
$version = '1.1';
$body = [
'inputText' => $prompt,
'textGenerationConfig' => [
'maxTokenCount' => 4000,
'stopSequences' => [],
'temperature' => 0,
'topP' => 1,
],
];
$client = new Client([
'timeout' => 30,
]);
$request = new Request('POST', $endpoint, $headers, json_encode($body), $version);
$region = 'us-east-1';
$service = 'bedrock';
$signature = new SignatureV4($service, $region);
$credentials = new Credentials($access_key, $secret_key);
$request = $signature->signRequest($request, $credentials);
$response = $client->send($request);
$body = $response->getBody() . '';
return json_decode($body, TRUE);
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
The official Bedrock and BedrockRuntime clients was released today with 3.282.0 :) I'm not sure where it says that only python supports bedrock, but they released today too. All SDKs generally release a given service on the same day when the service has its public release to the SDKs. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
Are there plans to add support for Bedrock and Sagemaker to the SDK? I see it mentioned that only the Python SDK supports Bedrock, though it looks like a straightforward REST API so curious as to why it requires Python?
Any thoughts appreciated, best,
Hans
Beta Was this translation helpful? Give feedback.
All reactions