set system prompt at the top

This commit is contained in:
Christian Rute 2024-12-15 15:16:38 +01:00
parent d031c8ce86
commit e98dad71e5

View File

@ -3,6 +3,7 @@ import { showAlert } from './shared_functions.js';
let chatCount = 0; // Zähler für Chat-Sessions let chatCount = 0; // Zähler für Chat-Sessions
let currentChatId = null; // Aktuell angezeigte Chat-ID let currentChatId = null; // Aktuell angezeigte Chat-ID
let useMarkdown = true; let useMarkdown = true;
let sysprompt = "You are a knowledgeable assistant.";
document.getElementById('newChatButton').addEventListener('click', () => { document.getElementById('newChatButton').addEventListener('click', () => {
createNewChat(); createNewChat();
@ -268,7 +269,7 @@ async function stream_api_open_ai(userMessage) {
botMessageDiv.className = 'chat-message assistant'; botMessageDiv.className = 'chat-message assistant';
chatBox.prepend(botMessageDiv); chatBox.prepend(botMessageDiv);
let send_message_system = [{ role: "system", content: "You are a knowledgeable assistant." }]; let send_message_system = [{ role: "system", content: sysprompt }];
let send_message_user = getAllCurrentChatMessages(); let send_message_user = getAllCurrentChatMessages();
let send_message_final = send_message_system.concat(send_message_user) let send_message_final = send_message_system.concat(send_message_user)
console.log(send_message_final) console.log(send_message_final)
@ -342,7 +343,7 @@ function formatArrayToCustomString(array) {
// Tokenizer // Tokenizer
async function tokenize_api_open_ai() { async function tokenize_api_open_ai() {
let send_message_system = [{ role: "system", content: "You are a knowledgeable assistant." }]; let send_message_system = [{ role: "system", content: sysprompt }];
let send_message_user = getAllCurrentChatMessages(); let send_message_user = getAllCurrentChatMessages();
let send_message_final = send_message_system.concat(send_message_user) let send_message_final = send_message_system.concat(send_message_user)
let formattedString = `"${formatArrayToCustomString(send_message_final)}"`; let formattedString = `"${formatArrayToCustomString(send_message_final)}"`;