Add prompt manager setup

This commit is contained in:
maver 2023-05-28 15:55:03 +02:00
parent 77cd51ccaa
commit c6eee88cd4
2 changed files with 32 additions and 1 deletions

View File

@ -79,6 +79,7 @@ import {
import { import {
setOpenAIMessageExamples, setOpenAIMessageExamples,
setOpenAIMessages, setOpenAIMessages,
setupOpenAIPromptManager,
prepareOpenAIMessages, prepareOpenAIMessages,
sendOpenAIRequest, sendOpenAIRequest,
loadOpenAISettings, loadOpenAISettings,
@ -5107,6 +5108,7 @@ async function getSettings(type) {
// OpenAI // OpenAI
loadOpenAISettings(data, settings); loadOpenAISettings(data, settings);
setupOpenAIPromptManager(settings);
// Horde // Horde
loadHordeSettings(settings); loadHordeSettings(settings);

View File

@ -22,7 +22,14 @@ import {
is_send_press, is_send_press,
main_api, main_api,
} from "../script.js"; } from "../script.js";
import { groups, selected_group } from "./group-chats.js"; import {groups, selected_group} from "./group-chats.js";
import {
defaultPromptManagerSettings,
openAiDefaultPromptLists,
openAiDefaultPrompts,
PromptManagerModule as PromptManager
} from "./PromptManager.js";
import { import {
power_user, power_user,
@ -50,6 +57,7 @@ export {
loadOpenAISettings, loadOpenAISettings,
setOpenAIMessages, setOpenAIMessages,
setOpenAIMessageExamples, setOpenAIMessageExamples,
setupOpenAIPromptManager,
generateOpenAIPromptCache, generateOpenAIPromptCache,
prepareOpenAIMessages, prepareOpenAIMessages,
sendOpenAIRequest, sendOpenAIRequest,
@ -188,6 +196,8 @@ export function getTokenCountOpenAI(text) {
return countTokens(message, true); return countTokens(message, true);
} }
let promptManager = null;
function validateReverseProxy() { function validateReverseProxy() {
if (!oai_settings.reverse_proxy) { if (!oai_settings.reverse_proxy) {
return; return;
@ -261,6 +271,25 @@ function setOpenAIMessageExamples(mesExamplesArray) {
} }
} }
function setupOpenAIPromptManager(settings) {
promptManager = new PromptManager();
const configuration = {
prefix: 'openai_',
containerIdentifier: 'openai_prompt_manager',
listIdentifier: 'openai_prompt_manager_list',
draggable: true
};
promptManager.saveServiceSettings = () => {
saveSettingsDebounced();
}
promptManager.init(configuration, settings, default_settings);
promptManager.render();
}
function generateOpenAIPromptCache() { function generateOpenAIPromptCache() {
openai_msgs = openai_msgs.reverse(); openai_msgs = openai_msgs.reverse();
openai_msgs.forEach(function (msg, i, arr) { openai_msgs.forEach(function (msg, i, arr) {