centralize LLM constants more

This commit is contained in:
perf3ct
2025-03-28 23:25:06 +00:00
parent 224cb22fe9
commit 2311c3c049
10 changed files with 116 additions and 111 deletions

View File

@@ -14,99 +14,7 @@ import sql from "../../services/sql.js";
// Import the index service for knowledge base management
import indexService from "../../services/llm/index_service.js";
import { CONTEXT_PROMPTS, ERROR_PROMPTS, FORMATTING_PROMPTS } from '../../services/llm/constants/llm_prompt_constants.js';
// LLM service constants
export const LLM_CONSTANTS = {
// Context window sizes (in characters)
CONTEXT_WINDOW: {
OLLAMA: 8000,
OPENAI: 12000,
ANTHROPIC: 15000,
VOYAGE: 12000,
DEFAULT: 6000
},
// Embedding dimensions (verify these with your actual models)
EMBEDDING_DIMENSIONS: {
OLLAMA: {
DEFAULT: 384,
NOMIC: 768,
MISTRAL: 1024
},
OPENAI: {
ADA: 1536,
DEFAULT: 1536
},
ANTHROPIC: {
CLAUDE: 1024,
DEFAULT: 1024
},
VOYAGE: {
DEFAULT: 1024
}
},
// Model-specific embedding dimensions for Ollama models
OLLAMA_MODEL_DIMENSIONS: {
"llama3": 4096,
"llama3.1": 4096,
"mistral": 4096,
"nomic": 768,
"mxbai": 1024,
"nomic-embed-text": 768,
"mxbai-embed-large": 1024,
"default": 384
},
// Model-specific context windows for Ollama models
OLLAMA_MODEL_CONTEXT_WINDOWS: {
"llama3": 8192,
"llama3.1": 8192,
"llama3.2": 8192,
"mistral": 8192,
"nomic": 32768,
"mxbai": 32768,
"nomic-embed-text": 32768,
"mxbai-embed-large": 32768,
"default": 4096
},
// Batch size configuration
BATCH_SIZE: {
OPENAI: 10, // OpenAI can handle larger batches efficiently
ANTHROPIC: 5, // More conservative for Anthropic
OLLAMA: 1, // Ollama processes one at a time
DEFAULT: 5 // Conservative default
},
// Chunking parameters
CHUNKING: {
DEFAULT_SIZE: 1500,
OLLAMA_SIZE: 1000,
DEFAULT_OVERLAP: 100,
MAX_SIZE_FOR_SINGLE_EMBEDDING: 5000
},
// Search/similarity thresholds
SIMILARITY: {
DEFAULT_THRESHOLD: 0.65,
HIGH_THRESHOLD: 0.75,
LOW_THRESHOLD: 0.5
},
// Session management
SESSION: {
CLEANUP_INTERVAL_MS: 60 * 60 * 1000, // 1 hour
SESSION_EXPIRY_MS: 12 * 60 * 60 * 1000, // 12 hours
MAX_SESSION_MESSAGES: 10
},
// Content limits
CONTENT: {
MAX_NOTE_CONTENT_LENGTH: 1500,
MAX_TOTAL_CONTENT_LENGTH: 10000
}
};
import { LLM_CONSTANTS } from '../../services/llm/constants/provider_constants.js';
// Define basic interfaces
interface ChatMessage {