From 4e9f025619fb92cb6f8230bd86d6dac67e79db7e Mon Sep 17 00:00:00 2001 From: Zaki-1052 Date: Sun, 1 Dec 2024 16:33:59 -0800 Subject: [PATCH] fix o1 history --- .env.example | 2 +- server.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index d5205ba..5c49877 100644 --- a/.env.example +++ b/.env.example @@ -20,7 +20,7 @@ CODESTRAL_API_KEY=your_codestral_ai_key_here # DEFAULT_MODEL=your_preferred_model ### EXAMPLE: -#DEFAULT_MODEL=claude-3-5-sonnet-20240620 +#DEFAULT_MODEL=claude-3-5-sonnet-latest DEFAULT_MODEL='gpt-4o' diff --git a/server.js b/server.js index 34f7a73..5e53104 100644 --- a/server.js +++ b/server.js @@ -644,7 +644,10 @@ app.post('/setSummariesOnly', (req, res) => { let chatHistory; let isClaudeChat = false; - if (containsAssistantMessage) { + if (o1History.length > 0) { + console.log("Using O1 conversation history because it's non-empty."); + chatHistory = o1History; + } else if (containsAssistantMessage && conversationHistory.length > 0) { console.log("Using GPT conversation history because it's non-empty."); chatHistory = conversationHistory; } else { @@ -667,7 +670,7 @@ app.post('/setSummariesOnly', (req, res) => { chatType = 'chat'; const tokens = await tokenizeHistory(chatHistory, modelID, chatType); - console.log("Total Tokens: ", tokens); + // console.log("Total Tokens: ", tokens); const cost = await calculateCost(tokens, modelID); console.log("Total Cost: ", cost); @@ -2226,6 +2229,10 @@ if (modelID.startsWith('llama-3.1')) { claudeHistory.push({ role: "assistant", content: lastMessageContent[0].text }); console.log("Claude History"); res.json({ text: lastMessageContent[0].text }); + } else if (modelID === 'o1-preview' || modelID === 'o1-mini') { + o1History.push({ role: "assistant", content: lastMessageContent }); + console.log("O1 History"); + res.json({ text: lastMessageContent }); } else { // Add assistant's message to the conversation history conversationHistory.push({ role: "assistant", content: lastMessageContent });