|
|
@@ -9,7 +9,6 @@ import {
|
|
|
} from "@aws-sdk/client-bedrock-runtime"
|
|
|
import { fromIni } from "@aws-sdk/credential-providers"
|
|
|
import { Anthropic } from "@anthropic-ai/sdk"
|
|
|
-import { SingleCompletionHandler } from "../"
|
|
|
import {
|
|
|
BedrockModelId,
|
|
|
ModelInfo as SharedModelInfo,
|
|
|
@@ -26,6 +25,7 @@ import { MultiPointStrategy } from "../transform/cache-strategy/multi-point-stra
|
|
|
import { ModelInfo as CacheModelInfo } from "../transform/cache-strategy/types"
|
|
|
import { AMAZON_BEDROCK_REGION_INFO } from "../../shared/aws_regions"
|
|
|
import { convertToBedrockConverseMessages as sharedConverter } from "../transform/bedrock-converse-format"
|
|
|
+import type { SingleCompletionHandler, ApiHandlerCreateMessageMetadata } from "../index"
|
|
|
|
|
|
const BEDROCK_DEFAULT_TEMPERATURE = 0.3
|
|
|
const BEDROCK_MAX_TOKENS = 4096
|
|
|
@@ -189,7 +189,11 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
|
|
|
this.client = new BedrockRuntimeClient(clientConfig)
|
|
|
}
|
|
|
|
|
|
- override async *createMessage(systemPrompt: string, messages: Anthropic.Messages.MessageParam[]): ApiStream {
|
|
|
+ override async *createMessage(
|
|
|
+ systemPrompt: string,
|
|
|
+ messages: Anthropic.Messages.MessageParam[],
|
|
|
+ metadata?: ApiHandlerCreateMessageMetadata,
|
|
|
+ ): ApiStream {
|
|
|
let modelConfig = this.getModel()
|
|
|
// Handle cross-region inference
|
|
|
const usePromptCache = Boolean(this.options.awsUsePromptCache && this.supportsAwsPromptCache(modelConfig))
|
|
|
@@ -769,7 +773,7 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
|
|
|
> = {
|
|
|
ACCESS_DENIED: {
|
|
|
patterns: ["access", "denied", "permission"],
|
|
|
- messageTemplate: `You don't have access to the model specified.
|
|
|
+ messageTemplate: `You don't have access to the model specified.
|
|
|
|
|
|
Please verify:
|
|
|
1. Try cross-region inference if you're using a foundation model
|