mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-20 04:42:46 +08:00
Migrate to claude 4
This commit is contained in:
@@ -224,7 +224,7 @@ export class ClaudeApi implements LLMApi {
|
|||||||
let chunkJson:
|
let chunkJson:
|
||||||
| undefined
|
| undefined
|
||||||
| {
|
| {
|
||||||
type: "content_block_delta" | "content_block_stop";
|
type: "content_block_delta" | "content_block_stop" | "message_delta" | "message_stop";
|
||||||
content_block?: {
|
content_block?: {
|
||||||
type: "tool_use";
|
type: "tool_use";
|
||||||
id: string;
|
id: string;
|
||||||
@@ -234,11 +234,20 @@ export class ClaudeApi implements LLMApi {
|
|||||||
type: "text_delta" | "input_json_delta";
|
type: "text_delta" | "input_json_delta";
|
||||||
text?: string;
|
text?: string;
|
||||||
partial_json?: string;
|
partial_json?: string;
|
||||||
|
stop_reason?: string;
|
||||||
};
|
};
|
||||||
index: number;
|
index: number;
|
||||||
};
|
};
|
||||||
chunkJson = JSON.parse(text);
|
chunkJson = JSON.parse(text);
|
||||||
|
|
||||||
|
// Handle refusal stop reason in message_delta
|
||||||
|
if (chunkJson?.delta?.stop_reason === "refusal") {
|
||||||
|
// Return a message to display to the user
|
||||||
|
const refusalMessage = "\n\n[Assistant refused to respond. Please modify your request and try again.]";
|
||||||
|
options.onError?.(new Error("Content policy violation: " + refusalMessage));
|
||||||
|
return refusalMessage;
|
||||||
|
}
|
||||||
|
|
||||||
if (chunkJson?.content_block?.type == "tool_use") {
|
if (chunkJson?.content_block?.type == "tool_use") {
|
||||||
index += 1;
|
index += 1;
|
||||||
const id = chunkJson?.content_block.id;
|
const id = chunkJson?.content_block.id;
|
||||||
|
@@ -571,6 +571,8 @@ const anthropicModels = [
|
|||||||
"claude-3-5-sonnet-latest",
|
"claude-3-5-sonnet-latest",
|
||||||
"claude-3-7-sonnet-20250219",
|
"claude-3-7-sonnet-20250219",
|
||||||
"claude-3-7-sonnet-latest",
|
"claude-3-7-sonnet-latest",
|
||||||
|
"claude-sonnet-4-20250514",
|
||||||
|
"claude-opus-4-20250514",
|
||||||
];
|
];
|
||||||
|
|
||||||
const baiduModels = [
|
const baiduModels = [
|
||||||
|
Reference in New Issue
Block a user