Enhance encryption security

This commit is contained in:
glay
2024-12-07 20:34:05 +08:00
parent ad49cd0454
commit 5ac651ad8e
3 changed files with 67 additions and 22 deletions

View File

@@ -137,7 +137,8 @@ export class BedrockApi implements LLMApi {
},
},
})),
// toolChoice: { auto: {} }
toolChoice: { auto: {} },
// toolChoice: { any: {} }
};
}
@@ -339,16 +340,11 @@ export class BedrockApi implements LLMApi {
const controller = new AbortController();
options.onController?.(controller);
if (!accessStore.isValidBedrock()) {
throw new Error(
"Invalid AWS credentials. Please check your configuration and ensure ENCRYPTION_KEY is set.",
);
}
let finalRequestBody = this.formatRequestBody(messages, modelConfig);
try {
const isApp = !!getClientConfig()?.isApp;
// const isApp = true;
const bedrockAPIPath = `${BEDROCK_BASE_URL}/model/${
modelConfig.model
}/invoke${shouldStream ? "-with-response-stream" : ""}`;
@@ -699,10 +695,10 @@ function bedrockStream(
responseRes = res;
const contentType = res.headers.get("content-type");
console.log(
"[Bedrock Stream Request] response content type: ",
contentType,
);
// console.log(
// "[Bedrock Stream Request] response content type: ",
// contentType,
// );
if (contentType?.startsWith("text/plain")) {
responseText = await res.text();