mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-23 22:20:23 +09:00
Update app/client/platforms/bedrock.ts
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
parent
4b2f447474
commit
93337b2b92
@ -51,6 +51,11 @@ async function getBedrockHeaders(
|
|||||||
shouldStream: boolean,
|
shouldStream: boolean,
|
||||||
): Promise<Record<string, string>> {
|
): Promise<Record<string, string>> {
|
||||||
const accessStore = useAccessStore.getState();
|
const accessStore = useAccessStore.getState();
|
||||||
|
// Validate credentials
|
||||||
|
if (!accessStore.awsAccessKey || !accessStore.awsSecretKey || !accessStore.awsRegion) {
|
||||||
|
throw new Error("Missing required AWS credentials");
|
||||||
|
}
|
||||||
|
|
||||||
const bedrockHeaders = isApp
|
const bedrockHeaders = isApp
|
||||||
? await sign({
|
? await sign({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -66,19 +71,24 @@ async function getBedrockHeaders(
|
|||||||
: getHeaders();
|
: getHeaders();
|
||||||
|
|
||||||
if (!isApp) {
|
if (!isApp) {
|
||||||
const { awsRegion, awsAccessKey, awsSecretKey, encryptionKey } =
|
const { awsRegion, awsAccessKey, awsSecretKey, encryptionKey } = accessStore;
|
||||||
accessStore;
|
if (!encryptionKey) {
|
||||||
|
throw new Error("Missing encryption key");
|
||||||
|
}
|
||||||
|
|
||||||
const bedrockHeadersConfig = {
|
const bedrockHeadersConfig = {
|
||||||
XModelID: modelId,
|
XModelID: modelId,
|
||||||
XEncryptionKey: encryptionKey,
|
XEncryptionKey: encryptionKey,
|
||||||
ShouldStream: String(shouldStream),
|
ShouldStream: String(shouldStream),
|
||||||
Authorization: await createAuthHeader(
|
Authorization: await createAuthHeader({
|
||||||
awsRegion,
|
region: awsRegion,
|
||||||
awsAccessKey,
|
accessKey: awsAccessKey,
|
||||||
awsSecretKey,
|
secretKey: awsSecretKey,
|
||||||
encryptionKey,
|
encryptionKey,
|
||||||
),
|
}).catch(error => {
|
||||||
|
console.error("[Bedrock] Failed to create auth header:", error);
|
||||||
|
throw new Error("Failed to create authorization header");
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(bedrockHeaders, bedrockHeadersConfig);
|
Object.assign(bedrockHeaders, bedrockHeadersConfig);
|
||||||
|
Loading…
Reference in New Issue
Block a user