File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
src/lib/server/endpoints/aws Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { z } from "zod" ;
2
2
import type { Endpoint } from "../endpoints" ;
3
3
import type { TextGenerationStreamOutput } from "@huggingface/inference" ;
4
- import {
5
- BedrockRuntimeClient ,
6
- InvokeModelWithResponseStreamCommand ,
7
- } from "@aws-sdk/client-bedrock-runtime" ;
8
4
import { createImageProcessorOptionsValidator , makeImageProcessor } from "../images" ;
9
5
import type { EndpointMessage } from "../endpoints" ;
10
6
import type { MessageFile } from "$lib/types/Message" ;
@@ -40,6 +36,16 @@ export async function endpointBedrock(
40
36
) : Promise < Endpoint > {
41
37
const { region, model, anthropicVersion, multimodal } =
42
38
endpointBedrockParametersSchema . parse ( input ) ;
39
+
40
+ let BedrockRuntimeClient , InvokeModelWithResponseStreamCommand ;
41
+ try {
42
+ ( { BedrockRuntimeClient, InvokeModelWithResponseStreamCommand } = await import (
43
+ "@aws-sdk/client-bedrock-runtime"
44
+ ) ) ;
45
+ } catch ( error ) {
46
+ throw new Error ( "Failed to import @aws-sdk/client-bedrock-runtime. Make sure it's installed." ) ;
47
+ }
48
+
43
49
const client = new BedrockRuntimeClient ( {
44
50
region,
45
51
} ) ;
You can’t perform that action at this time.
0 commit comments