1 個回答
- 最新
- 最多得票
- 最多評論
0
In case if any body wants the working code snippet which I made it working in laravel:
Example of any-sessionId: abc or abbc or test
public function retrieveAgentUsingApi() { // AWS Credentials $awsCredentials = new Credentials(env('AWS_ACCESS_KEY_ID'), env('AWS_SECRET_ACCESS_KEY')); $region = 'us-west-1'; $baseUrl = 'https://bedrock-agent-runtime.' $region '.amazonaws.com'; // Create a new PSR-7 request object $request = new Request( 'POST', // HTTP method $baseUrl . '/agents/{your-agentId}/agentAliases/{your-agentAliasID}/sessions/{any-sessionId}/text', // Request URL ['Content-Type' => 'application/json'], // Headers json_encode([ 'inputText' => 'which country won the 2023 soccer game?' ]) );
$signer = new SignatureV4("bedrock", $region);
$signedrequest = $signer->signRequest($request, $awsCredentials);
// Create a Guzzle HTTP client
$client = new Client();
// Send the signed request
$response = $client->send($signedrequest);
// You can then access the response body using:
$responseBody = $response->getBody()->getContents();
return $responseBody;
}
已回答 1 個月前
相關內容
- 已提問 1 年前
- AWS 官方已更新 2 年前