1 Respuesta
- Más nuevo
- Más votos
- Más comentarios
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;
}
respondido hace un mes
Contenido relevante
- OFICIAL DE AWSActualizada hace 3 años
- OFICIAL DE AWSActualizada hace 8 meses