Skip to content

Commit 0ddf231

Browse files
authored
fix(endpoints): make bedrock import optional (#1468)
1 parent b85e6e3 commit 0ddf231

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/lib/server/endpoints/aws/endpointBedrock.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { z } from "zod";
22
import type { Endpoint } from "../endpoints";
33
import type { TextGenerationStreamOutput } from "@huggingface/inference";
4-
import {
5-
BedrockRuntimeClient,
6-
InvokeModelWithResponseStreamCommand,
7-
} from "@aws-sdk/client-bedrock-runtime";
84
import { createImageProcessorOptionsValidator, makeImageProcessor } from "../images";
95
import type { EndpointMessage } from "../endpoints";
106
import type { MessageFile } from "$lib/types/Message";
@@ -40,6 +36,16 @@ export async function endpointBedrock(
4036
): Promise<Endpoint> {
4137
const { region, model, anthropicVersion, multimodal } =
4238
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+
4349
const client = new BedrockRuntimeClient({
4450
region,
4551
});

0 commit comments

Comments
 (0)