From 2db0ff2462b9cef04b1f194a119c86dd8a59e54b Mon Sep 17 00:00:00 2001 From: perf3ct Date: Tue, 1 Apr 2025 18:49:37 +0000 Subject: [PATCH] move prompt constants from JS to TS --- .../llm/constants/llm_prompt_constants.js | 70 ------------------- .../llm/constants/llm_prompt_constants.ts | 44 +++++++++++- 2 files changed, 42 insertions(+), 72 deletions(-) delete mode 100644 src/services/llm/constants/llm_prompt_constants.js diff --git a/src/services/llm/constants/llm_prompt_constants.js b/src/services/llm/constants/llm_prompt_constants.js deleted file mode 100644 index 1e4881517..000000000 --- a/src/services/llm/constants/llm_prompt_constants.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Constants related to LLM prompts and messaging - */ - -/** - * System prompts for different use cases - */ -export const SYSTEM_PROMPTS = { - DEFAULT_SYSTEM_PROMPT: - "You are an intelligent AI assistant for Trilium Notes, a hierarchical note-taking application. " + - "Help the user with their notes, knowledge management, and questions. " + - "When referencing their notes, be clear about which note you're referring to. " + - "Be concise but thorough in your responses.", - - AGENT_TOOLS_PROMPT: - "You are an intelligent AI assistant for Trilium Notes with access to special tools. " + - "You can use these tools to search through the user's notes and find relevant information. " + - "Always be helpful, accurate, and respect the user's privacy and security.", - - CONTEXT_AWARE_PROMPT: - "You are an intelligent AI assistant for Trilium Notes. " + - "You have access to the context from the user's notes. " + - "Use this context to provide accurate and helpful responses. " + - "Be specific when referencing information from their notes." -}; - -/** - * Prompts related to context handling - */ -export const CONTEXT_PROMPTS = { - NOTE_CONTEXT_PROMPT: - "Here is context from my current note to help you understand what I'm working on: {context}", - - SEMANTIC_NOTE_CONTEXT_PROMPT: - "I'm asking about: {query}\n\nHere's relevant information from my notes: {context}", - - AGENT_TOOLS_CONTEXT_PROMPT: - "You have access to the following tools to help answer the user's question: {tools}", - - INDEX_NO_NOTES_CONTEXT: - "I couldn't find any directly relevant information in your notes about this query. " + - "I'll try to help based on my general knowledge, but please note that I may not have all the specific details you need." -}; - -/** - * Error prompts for different scenarios - */ -export const ERROR_PROMPTS = { - USER_ERRORS: { - GENERAL_ERROR: - "I'm sorry, but I encountered an error while processing your request. " + - "Please try again or rephrase your question.", - - CONTEXT_ERROR: - "I'm sorry, but I encountered an error while retrieving context from your notes. " + - "I'll try to help based on what I know, but I might be missing important context.", - - PROVIDER_ERROR: - "I'm sorry, but there seems to be an issue with the AI service provider. " + - "Please check your connection and API settings, or try again later." - }, - - SYSTEM_ERRORS: { - NO_PROVIDER_AVAILABLE: - "No AI provider is available. Please check your AI settings and ensure at least one provider is configured properly.", - - UNAUTHORIZED: - "The AI provider returned an authorization error. Please check your API key settings." - } -}; \ No newline at end of file diff --git a/src/services/llm/constants/llm_prompt_constants.ts b/src/services/llm/constants/llm_prompt_constants.ts index 5633dca3a..d99b461f9 100644 --- a/src/services/llm/constants/llm_prompt_constants.ts +++ b/src/services/llm/constants/llm_prompt_constants.ts @@ -34,6 +34,28 @@ const loadSystemPrompt = (): string => { // Base system prompt loaded from markdown file export const DEFAULT_SYSTEM_PROMPT = loadSystemPrompt(); +/** + * System prompts for different use cases + */ +export const SYSTEM_PROMPTS = { + DEFAULT_SYSTEM_PROMPT: + "You are an intelligent AI assistant for Trilium Notes, a hierarchical note-taking application. " + + "Help the user with their notes, knowledge management, and questions. " + + "When referencing their notes, be clear about which note you're referring to. " + + "Be concise but thorough in your responses.", + + AGENT_TOOLS_PROMPT: + "You are an intelligent AI assistant for Trilium Notes with access to special tools. " + + "You can use these tools to search through the user's notes and find relevant information. " + + "Always be helpful, accurate, and respect the user's privacy and security.", + + CONTEXT_AWARE_PROMPT: + "You are an intelligent AI assistant for Trilium Notes. " + + "You have access to the context from the user's notes. " + + "Use this context to provide accurate and helpful responses. " + + "Be specific when referencing information from their notes." +}; + // Context-specific prompts export const CONTEXT_PROMPTS = { // Query enhancer prompt for generating better search terms @@ -108,7 +130,11 @@ Please help me understand this information in relation to my query.`, ERROR_MESSAGES: { GENERAL_ERROR: `Error: Failed to generate response. {errorMessage}`, CONTEXT_ERROR: `Error: Failed to generate response with note context. {errorMessage}` - } + }, + + // Merged from JS file + AGENT_TOOLS_CONTEXT_PROMPT: + "You have access to the following tools to help answer the user's question: {tools}" }; // Agent tool prompts @@ -234,7 +260,12 @@ export const ERROR_PROMPTS = { GENERAL_ERROR: "I encountered an error processing your request. Please try again or rephrase your question.", CONTEXT_ERROR: "I couldn't retrieve context from your notes. Please check your query or try a different question.", NETWORK_ERROR: "There was a network error connecting to the AI service. Please check your connection and try again.", - RATE_LIMIT: "The AI service is currently experiencing high demand. Please try again in a moment." + RATE_LIMIT: "The AI service is currently experiencing high demand. Please try again in a moment.", + + // Merged from JS file + PROVIDER_ERROR: + "I'm sorry, but there seems to be an issue with the AI service provider. " + + "Please check your connection and API settings, or try again later." }, // Internal error handling @@ -242,5 +273,14 @@ export const ERROR_PROMPTS = { CONTEXT_PROCESSING: "Error processing context data", MESSAGE_FORMATTING: "Error formatting messages for LLM", RESPONSE_PARSING: "Error parsing LLM response" + }, + + // Merged from JS file + SYSTEM_ERRORS: { + NO_PROVIDER_AVAILABLE: + "No AI provider is available. Please check your AI settings and ensure at least one provider is configured properly.", + + UNAUTHORIZED: + "The AI provider returned an authorization error. Please check your API key settings." } };