From fb62d731f2069c416ff5dbbd7c8469cf9fd766e3 Mon Sep 17 00:00:00 2001 From: Sunner Sun Date: Mon, 15 Jan 2024 11:59:19 +0800 Subject: [PATCH] Upgrade Claude.ai to the lastest API fix #685 --- src/bots/ClaudeAIBot.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/bots/ClaudeAIBot.js b/src/bots/ClaudeAIBot.js index 9564092750..a0ad60937e 100644 --- a/src/bots/ClaudeAIBot.js +++ b/src/bots/ClaudeAIBot.js @@ -50,26 +50,22 @@ export default class ClaudeAIBot extends Bot { accept: "text/event-stream, text/event-stream", "Content-Type": "application/json", }; + const url = `https://claude.ai/api/organizations/${store.state.claudeAi.org}/chat_conversations/${context.uuid}/completion`; const payload = JSON.stringify({ attachments: [], - completion: { - incremental: true, - model: "claude-2.0", - prompt: prompt, - }, - conversation_uuid: context.uuid, - organization_uuid: store.state.claudeAi.org, - text: prompt, + model: "claude-2.1", + prompt: prompt, + timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, }); return new Promise((resolve, reject) => { try { - const source = new SSE("https://claude.ai/api/append_message", { + const source = new SSE(url, { headers, payload, withCredentials: true, }); let text = ""; - source.addEventListener("message", (event) => { + source.addEventListener("completion", (event) => { try { const data = JSON.parse(event.data); if (data.completion) {