soukicz/llm-aws-bedrock

There is no license information available for the latest version (dev-main) of this package.

dev-main 2025-03-01 14:15 UTC

This package is auto-updated.

Last update: 2025-03-01 14:16:39 UTC


README

Usage

use Soukicz\Llm\Client\Anthropic\AnthropicEncoder;
use Soukicz\Llm\Cache\FileCache;
use Soukicz\Llm\Message\LLMMessage;
use Soukicz\Llm\Message\LLMMessageText;
use Soukicz\Llm\LLMConversation;
use Soukicz\Llm\LLMRequest;
use Soukicz\LlmAwsBedrock\BedrockClient;

require_once __DIR__ . '/vendor/autoload.php';

$cache = new FileCache(sys_get_temp_dir());
$encoder = new AnthropicEncoder();

$bedrock = new BedrockClient(
    $encoder,
    'eu-central-1',
    \Aws\Credentials\CredentialProvider::defaultProvider()(),
    $cache
);

$response = $bedrock->sendPrompt(new LLMRequest(
    model: BedrockClient::MODEL_ANTHROPIC_SONNET_37_20250219_v10,
    conversation: new LLMConversation([LLMMessage::createFromUser([new LLMMessageText('Hello, how are you?')])]),
));

echo $response->getLastText();