Actually add the prompts to the model

This commit is contained in:
Barrca 2025-01-29 12:59:04 -08:00
parent 102d179b99
commit 75da491f42
2 changed files with 14 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import { InlineAISettings } from "./settings";
import { App, MarkdownView, Notice } from "obsidian";
import { EditorView } from "@codemirror/view";
import { setGeneratedResponseEffect } from "./modules/AIExtension";
import { parseCommand } from "./modules/commands/parser";
/**
* Class to manage interactions with different chat APIs.
@ -164,7 +165,7 @@ export class ChatApiManager {
**Output:**`;
}
return this.handleEditorUpdate(systemPrompt, userPrompt);
return this.handleEditorUpdate(systemPrompt, parseCommand(userPrompt, this.settings.commandPrefix, this.settings.customCommands));
}
/**

View file

@ -0,0 +1,12 @@
import { SlashCommand } from "./source";
export function parseCommand(userInput: string, prefix: string, customCommands: SlashCommand[]): string {
for (const command of customCommands) {
const commandPattern = `${prefix}${command.keyword}`;
if (userInput.startsWith(commandPattern)) {
return userInput.replace(commandPattern, command.prompt).trim();
}
}
return userInput; // Return original text if no command matches
}