/clear or /c - Clear chat history.";
displayCommandBotMessageDiv.appendChild(commandClearP);
const commandRefOnP = document.createElement("p");
commandRefOnP.innerHTML = '/ref on - Turn on "reference current note".';
displayCommandBotMessageDiv.appendChild(commandRefOnP);
const commandRefOffP = document.createElement("p");
commandRefOffP.innerHTML = '/ref off - Turn off "reference current note".';
displayCommandBotMessageDiv.appendChild(commandRefOffP);
const commandMaxTokensP = document.createElement("p");
commandMaxTokensP.innerHTML = "/maxtokens [VALUE] - Set max tokens.";
displayCommandBotMessageDiv.appendChild(commandMaxTokensP);
const commandTempP = document.createElement("p");
commandTempP.innerHTML = "/temp [VALUE] - Change temperature range from 0 to 2.";
displayCommandBotMessageDiv.appendChild(commandTempP);
const profileCommandHeader = document.createElement("h4");
profileCommandHeader.textContent = "Profile Commands";
profileCommandHeader.style.textAlign = "left";
displayCommandBotMessageDiv.appendChild(profileCommandHeader);
const commandProfileListP = document.createElement("p");
commandProfileListP.innerHTML = "/profile - List profile.";
displayCommandBotMessageDiv.appendChild(commandProfileListP);
const commandProfileChangeP = document.createElement("p");
commandProfileChangeP.innerHTML = "/profile [PROFILE-NAME] or [VALUE] - Change profile.";
displayCommandBotMessageDiv.appendChild(commandProfileChangeP);
const modelCommandHeader = document.createElement("h4");
modelCommandHeader.textContent = "Model Commands";
modelCommandHeader.style.textAlign = "left";
displayCommandBotMessageDiv.appendChild(modelCommandHeader);
const commandModelListP = document.createElement("p");
commandModelListP.innerHTML = "/model - List model.";
displayCommandBotMessageDiv.appendChild(commandModelListP);
const commandModelChangeP = document.createElement("p");
commandModelChangeP.innerHTML = "/model [MODEL-NAME] or [VALUE] - Change model.";
displayCommandBotMessageDiv.appendChild(commandModelChangeP);
const promptCommandHeader = document.createElement("h4");
promptCommandHeader.textContent = "Prompt Commands";
promptCommandHeader.style.textAlign = "left";
displayCommandBotMessageDiv.appendChild(promptCommandHeader);
const commandPromptListP = document.createElement("p");
commandPromptListP.innerHTML = "/prompt - List prompts.";
displayCommandBotMessageDiv.appendChild(commandPromptListP);
const commandPromptChangeP = document.createElement("p");
commandPromptChangeP.innerHTML = "/prompt [PROMPT-NAME] or [VALUE] - Change prompts.";
displayCommandBotMessageDiv.appendChild(commandPromptChangeP);
const commandPromptClearP = document.createElement("p");
commandPromptClearP.innerHTML = "/prompt clear - Clear prompt.";
displayCommandBotMessageDiv.appendChild(commandPromptClearP);
const editorCommandHeader = document.createElement("h4");
editorCommandHeader.textContent = "Editor Commands";
editorCommandHeader.style.textAlign = "left";
displayCommandBotMessageDiv.appendChild(editorCommandHeader);
const commandAppendP = document.createElement("p");
commandAppendP.innerHTML = "/append - Append current chat history to current active note.";
displayCommandBotMessageDiv.appendChild(commandAppendP);
const commandSaveP = document.createElement("p");
commandSaveP.innerHTML = "/save - Save current chat history to a note.";
displayCommandBotMessageDiv.appendChild(commandSaveP);
const commandLoadP = document.createElement("p");
commandLoadP.innerHTML = "/load - List or load a chat history into view.";
displayCommandBotMessageDiv.appendChild(commandLoadP);
const streamCommandHeader = document.createElement("h4");
streamCommandHeader.textContent = "Response Commands";
streamCommandHeader.style.textAlign = "left";
displayCommandBotMessageDiv.appendChild(streamCommandHeader);
const commandStopP = document.createElement("p");
commandStopP.innerHTML = "/stop or /s - Stop fetching response. Warning: Anthropric models cannot be aborted. Please use with caution.";
displayCommandBotMessageDiv.appendChild(commandStopP);
messageBlockDiv.appendChild(displayCommandBotMessageDiv);
botMessageToolBarDiv.appendChild(botNameSpan);
botMessageDiv.appendChild(botMessageToolBarDiv);
botMessageDiv.appendChild(messageBlockDiv);
const index2 = messageHistory.length - 1;
addMessage(plugin, messageBlockDiv.innerHTML, "botMessage", settings, index2);
messageContainer.appendChild(botMessageDiv);
}
async function commandModel(input, settings, plugin) {
const messageContainer = document.querySelector("#messageContainer");
const ollamaModels = settings.OllamaConnection.ollamaModels.map((model) => model);
const RESTAPIModels = settings.RESTAPIURLConnection.RESTAPIURLModels.map((model) => model);
const anthropicModels = settings.APIConnections.anthropic.anthropicModels.map((model) => model);
const googleGeminiModels = settings.APIConnections.googleGemini.geminiModels.map((model) => model);
const mistralModels = settings.APIConnections.mistral.mistralModels.map((model) => model);
const openAIBaseModels = settings.APIConnections.openAI.openAIBaseModels.map((model) => model);
const openRouterModels = settings.APIConnections.openRouter.openRouterModels.map((model) => model);
const allModels = [
...settings.OllamaConnection.ollamaModels,
...settings.RESTAPIURLConnection.RESTAPIURLModels,
...settings.APIConnections.anthropic.anthropicModels,
...settings.APIConnections.googleGemini.geminiModels,
...settings.APIConnections.mistral.mistralModels,
...settings.APIConnections.openAI.openAIBaseModels,
...settings.APIConnections.openRouter.openRouterModels
];
if (!input.split(" ")[1]) {
let currentModel = settings.general.model;
if (!currentModel) {
currentModel = "Empty";
}
const botMessageDiv = document.createElement("div");
botMessageDiv.className = "botMessage";
botMessageDiv.style.backgroundColor = colorToHex(settings.appearance.botMessageBackgroundColor || getComputedStyle(document.body).getPropertyValue(DEFAULT_SETTINGS.appearance.botMessageBackgroundColor).trim());
const botMessageToolBarDiv = document.createElement("div");
botMessageToolBarDiv.className = "botMessageToolBar";
const botNameSpan = document.createElement("span");
botNameSpan.textContent = settings.appearance.chatbotName || DEFAULT_SETTINGS.appearance.chatbotName;
botNameSpan.className = "chatbotName";
const messageBlockDiv = document.createElement("div");
messageBlockDiv.className = "messageBlock";
const displayCommandBotMessageDiv = document.createElement("div");
displayCommandBotMessageDiv.className = "commandBotMessage";
const header = document.createElement("h3");
header.textContent = "Model List";
header.style.textAlign = "center";
displayCommandBotMessageDiv.appendChild(header);
const currentModelP = document.createElement("p");
currentModelP.innerHTML = `Current Model: ${currentModel}`;
currentModelP.style.textAlign = "center";
displayCommandBotMessageDiv.appendChild(currentModelP);
const apiLists = [
{ header: "Ollama Models", items: ollamaModels },
{ header: "REST API Models", items: RESTAPIModels },
{ header: "Anthropic Models", items: anthropicModels },
{ header: "Google Gemini Models", items: googleGeminiModels },
{ header: "Mistral Models", items: mistralModels },
{ header: "OpenAI-Based Models", items: openAIBaseModels },
{ header: "OpenRouter Models", items: openRouterModels }
];
let currentStartIndex = 1;
apiLists.forEach((api) => {
if (Array.isArray(api.items) && api.items.length) {
const header2 = document.createElement("h4");
header2.textContent = api.header;
displayCommandBotMessageDiv.appendChild(header2);
const list = document.createElement("ol");
list.setAttribute("start", String(currentStartIndex));
api.items.forEach((item) => {
const listItem = document.createElement("li");
listItem.textContent = item;
list.appendChild(listItem);
});
displayCommandBotMessageDiv.appendChild(list);
currentStartIndex += api.items.length;
}
});
messageBlockDiv.appendChild(displayCommandBotMessageDiv);
botMessageToolBarDiv.appendChild(botNameSpan);
botMessageDiv.appendChild(botMessageToolBarDiv);
botMessageDiv.appendChild(messageBlockDiv);
const index2 = messageHistory.length - 1;
addMessage(plugin, messageBlockDiv.innerHTML, "botMessage", settings, index2);
messageContainer.appendChild(botMessageDiv);
}
if (input.split(" ")[1] !== void 0) {
const inputModel = input.split(" ")[1].replace(/^"(.*)"$/, "$1");
const modelAliases = {};
for (let i = 1; i <= allModels.length; i++) {
const model = allModels[i - 1];
modelAliases[i] = model;
}
if (Object.entries(modelAliases).find(([key, val]) => key === inputModel)) {
settings.general.model = modelAliases[inputModel];
new import_obsidian6.Notice(`Updated model to ${settings.general.model}`);
} else if (Object.entries(modelAliases).find(([key, val]) => val === inputModel)) {
settings.general.model = modelAliases[Object.keys(modelAliases).find((key) => modelAliases[key] === inputModel) || ""];
new import_obsidian6.Notice(`Updated model to ${settings.general.model}`);
} else {
new import_obsidian6.Notice("Invalid model.");
}
await plugin.saveSettings();
}
}
async function commandProfile(input, settings, plugin) {
const messageContainer = document.querySelector("#messageContainer");
if (!settings.profiles.profileFolderPath) {
new import_obsidian6.Notice("Profile folder path not set.");
const commandBotMessage = "Profile folder path not set.
"; const botMessageDiv = displayCommandBotMessage(plugin, settings, messageHistory, commandBotMessage); messageContainer.appendChild(botMessageDiv); return; } const files = plugin.app.vault.getFiles().filter((file) => file.path.startsWith(plugin.settings.profiles.profileFolderPath)); files.sort((a, b) => a.name.localeCompare(b.name)); let currentProfile = settings.profiles.profile.replace(/\.[^/.]+$/, ""); if (!input.split(" ")[1]) { const fileListItems = files.map((file) => { const fileNameWithoutExtension = file.name.replace(/\.[^/.]+$/, ""); return `Current profile: ${currentProfile}
Prompt folder path not set.
"; const botMessageDiv = displayCommandBotMessage(plugin, settings, messageHistory, commandBotMessage); messageContainer.appendChild(botMessageDiv); return; } const files = plugin.app.vault.getFiles().filter((file) => file.path.startsWith(plugin.settings.prompts.promptFolderPath)); files.sort((a, b) => a.name.localeCompare(b.name)); if (!input.split(" ")[1]) { const fileListItems = files.map((file) => { const fileNameWithoutExtension = file.name.replace(/\.[^/.]+$/, ""); return `Current prompt: ${currentPrompt.replace(".md", "")}
Current Chat History: ${settings.profiles.lastLoadedChatHistory[profileIndex] ? settings.profiles.lastLoadedChatHistory[profileIndex] : "Empty"}