BedrockRerankingGateway
class BedrockRerankingGateway implements RerankingGateway
Traits
Methods
Create an HTTP client with the provider's request options.
Select a boot-registered connection without retaining dynamic provider names.
Create a new Bedrock client instance.
Resolve the configured region, falling back to the default.
Resolve the provider authentication configuration.
Resolve the auth configuration for static, or automatically discovered, credentials.
Create a loader that assumes the configured role.
Create the STS client used to assume the configured role.
Build the parameters for the STS assume role request.
Execute a callback with failoverable error handling.
Get the short Retry-After delay of a rate limited or overloaded response, if it has one.
Determine if the response is a 402, or a 429 insufficient credits or quota error rather than a rate limit.
Get the status codes that indicate a provider is transiently unavailable and the request should fail over.
Get the patterns used to detect insufficient credits or quota errors.
Get the error codes or types that indicate insufficient credits or quota on a 429 response.
Rerank the given documents based on their relevance to the query.
Details
in
CreatesClient at line 21
protected PendingRequest
createClient(string $baseUrl, array $headers = [], array $configuredHeaders = [], int|null $timeout = 60, bool $throw = true)
Create an HTTP client with the provider's request options.
in
CreatesClient at line 43
protected string
httpConnection(Provider $provider)
Select a boot-registered connection without retaining dynamic provider names.
in
CreatesBedrockClient at line 34
protected BedrockRuntimeClient
createBedrockClient(Provider $provider, int|null $timeout = null)
Create a new Bedrock client instance.
in
CreatesBedrockClient at line 89
protected string
bedrockRegion(array $config)
Resolve the configured region, falling back to the default.
in
CreatesBedrockClient at line 101
protected array
resolveAuthConfig(array $credentials, array $config, int|null $timeout = null)
Resolve the provider authentication configuration.
in
CreatesBedrockClient at line 124
protected array
resolveSourceAuthConfig(array $credentials, array $config)
Resolve the auth configuration for static, or automatically discovered, credentials.
in
CreatesBedrockClient at line 153
protected Closure
assumeRoleCredentialProvider(array $credentials, array $config, int|null $timeout = null)
Create a loader that assumes the configured role.
in
CreatesBedrockClient at line 167
protected StsClient
createStsClient(array $credentials, array $config, int|null $timeout = null)
Create the STS client used to assume the configured role.
in
CreatesBedrockClient at line 189
protected array
assumeRoleParameters(array $assumeRole)
Build the parameters for the STS assume role request.
in
HandlesFailoverErrors at line 26
protected mixed
withErrorHandling(string $providerName, Closure $callback)
Execute a callback with failoverable error handling.
in
HandlesFailoverErrors at line 91
protected int|null
retryAfterSeconds(Throwable $exception)
Get the short Retry-After delay of a rate limited or overloaded response, if it has one.
in
HandlesFailoverErrors at line 115
protected bool
isInsufficientCredits(RequestException $exception)
Determine if the response is a 402, or a 429 insufficient credits or quota error rather than a rate limit.
in
HandlesFailoverErrors at line 138
protected array
overloadedStatusCodes()
Get the status codes that indicate a provider is transiently unavailable and the request should fail over.
in
HandlesFailoverErrors at line 148
protected array
insufficientCreditPatterns()
Get the patterns used to detect insufficient credits or quota errors.
in
HandlesFailoverErrors at line 158
protected array
insufficientCreditCodes()
Get the error codes or types that indicate insufficient credits or quota on a 429 response.
at line 31
RerankingResponse
rerank(RerankingProvider $provider, string $model, array $documents, string $query, int|null $limit = null, int $timeout = 30, array $providerOptions = [])
Rerank the given documents based on their relevance to the query.