* refactor settings * refactor constants * add settings for native/learning language * setup langugage for transcribe * use 2 letter code for echogarden * AI commands support multiple language * update languages constant * fix sentry error * fix context menu * show camdict when only learning English * add en-GB * recording assess support multiple languages * fix ai command * refactor
29 lines
929 B
TypeScript
29 lines
929 B
TypeScript
import { ChatPromptTemplate } from "@langchain/core/prompts";
|
|
import { textCommand } from "./text.command";
|
|
import { LANGUAGES } from "@/constants";
|
|
|
|
export const summarizeTopicCommand = async (
|
|
text: string,
|
|
learningLanguage: string,
|
|
options: {
|
|
key: string;
|
|
modelName?: string;
|
|
temperature?: number;
|
|
baseUrl?: string;
|
|
}
|
|
): Promise<string> => {
|
|
if (!text) throw new Error("Text is required");
|
|
|
|
const prompt = await ChatPromptTemplate.fromMessages([
|
|
["system", SYSTEM_PROMPT],
|
|
["human", text],
|
|
]).format({
|
|
learning_language: LANGUAGES.find((l) => l.code === learningLanguage).name,
|
|
});
|
|
|
|
return textCommand(prompt, options);
|
|
};
|
|
|
|
const SYSTEM_PROMPT =
|
|
"Please generate a four to five words title summarizing our conversation in {learning_language} without any lead-in, punctuation, quotation marks, periods, symbols, bold text, or additional text. Remove enclosing quotation marks.";
|