mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-22 05:30:19 +09:00
Merge feature/update-bedrock-api into main
This commit is contained in:
parent
1164e1bdf6
commit
1998cf5ced
@ -41,10 +41,7 @@ export interface ConverseRequest {
|
||||
|
||||
function supportsToolUse(modelId: string): boolean {
|
||||
// llama和mistral模型不支持工具调用
|
||||
return (
|
||||
modelId.toLowerCase().includes("claude-3") &&
|
||||
modelId.toLowerCase().includes("claude-3-5")
|
||||
);
|
||||
return modelId.toLowerCase().includes("claude-3");
|
||||
}
|
||||
|
||||
function formatRequestBody(
|
||||
|
@ -38,11 +38,9 @@ export class BedrockApi implements LLMApi {
|
||||
}
|
||||
|
||||
extractMessage(res: any) {
|
||||
console.log("[Response] bedrock response: ", res);
|
||||
if (Array.isArray(res?.content)) {
|
||||
return res.content;
|
||||
}
|
||||
return res;
|
||||
console.log("[Response] claude response: ", res);
|
||||
|
||||
return res?.content?.[0]?.text;
|
||||
}
|
||||
|
||||
async chat(options: ChatOptions): Promise<void> {
|
||||
@ -173,7 +171,6 @@ export class BedrockApi implements LLMApi {
|
||||
funcs,
|
||||
controller,
|
||||
// parseSSE
|
||||
// parseSSE
|
||||
(text: string, runTools: ChatMessageTool[]) => {
|
||||
// console.log("parseSSE", text, runTools);
|
||||
let chunkJson:
|
||||
@ -269,13 +266,14 @@ export class BedrockApi implements LLMApi {
|
||||
};
|
||||
|
||||
try {
|
||||
controller.signal.onabort = () => options.onFinish("");
|
||||
controller.signal.onabort = () =>
|
||||
options.onFinish("", new Response(null, { status: 400 }));
|
||||
|
||||
const res = await fetch(conversePath, payload);
|
||||
const resJson = await res.json();
|
||||
|
||||
const message = this.extractMessage(resJson);
|
||||
options.onFinish(message);
|
||||
options.onFinish(message, res);
|
||||
} catch (e) {
|
||||
console.error("failed to chat", e);
|
||||
options.onError?.(e as Error);
|
||||
|
Loading…
Reference in New Issue
Block a user