mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 16:23:41 +08:00 
			
		
		
		
	Merge pull request #6552 from hyiip/main
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Run Tests / test (push) Has been cancelled
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Run Tests / test (push) Has been cancelled
				
			Migrate to claude 4
This commit is contained in:
		@@ -224,7 +224,7 @@ export class ClaudeApi implements LLMApi {
 | 
			
		||||
          let chunkJson:
 | 
			
		||||
            | undefined
 | 
			
		||||
            | {
 | 
			
		||||
                type: "content_block_delta" | "content_block_stop";
 | 
			
		||||
                type: "content_block_delta" | "content_block_stop" | "message_delta" | "message_stop";
 | 
			
		||||
                content_block?: {
 | 
			
		||||
                  type: "tool_use";
 | 
			
		||||
                  id: string;
 | 
			
		||||
@@ -234,11 +234,20 @@ export class ClaudeApi implements LLMApi {
 | 
			
		||||
                  type: "text_delta" | "input_json_delta";
 | 
			
		||||
                  text?: string;
 | 
			
		||||
                  partial_json?: string;
 | 
			
		||||
                  stop_reason?: string;
 | 
			
		||||
                };
 | 
			
		||||
                index: number;
 | 
			
		||||
              };
 | 
			
		||||
          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") {
 | 
			
		||||
            index += 1;
 | 
			
		||||
            const id = chunkJson?.content_block.id;
 | 
			
		||||
 
 | 
			
		||||
@@ -571,6 +571,8 @@ const anthropicModels = [
 | 
			
		||||
  "claude-3-5-sonnet-latest",
 | 
			
		||||
  "claude-3-7-sonnet-20250219",
 | 
			
		||||
  "claude-3-7-sonnet-latest",
 | 
			
		||||
  "claude-sonnet-4-20250514",
 | 
			
		||||
  "claude-opus-4-20250514",
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
const baiduModels = [
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user