Any code snippet or example in laravel can I get to invokeAgent

0

Is there a laravel equivalent to invoke the following. Can someone please help? POST /agents/agentId/agentAliases/agentAliasId/sessions/sessionId/text HTTP/1.1 Content-type: application/json

{ "enableTrace": boolean, "endSession": boolean, "inputText": "string", "sessionState": { "promptSessionAttributes": { "string" : "string" }, "sessionAttributes": { "string" : "string" } } }

Guru
질문됨 한 달 전58회 조회
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;
}
Guru
답변함 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠