code cleanup/hardening
This commit is contained in:
@@ -26,7 +26,7 @@ const ORCHESTRATION = {
|
||||
SEMANTIC_LIMIT: 5,
|
||||
SCORE_THRESHOLD: 0.5,
|
||||
ENTITIES_LIMIT: 5,
|
||||
ENTITIES_THRESHOLD: 0.6,
|
||||
ENTITIES_THRESHOLD: 0.55,
|
||||
TEMPERATURE: 0.7,
|
||||
CORS_ORIGIN: 'http://localhost:5173',
|
||||
SYSTEM_PROMPT: `You are a helpful, context-aware AI assistant. You have access to memories of past conversations with the user. Use them to provide consistent, personalised responses.`
|
||||
@@ -70,14 +70,17 @@ const SQLITE = {
|
||||
}
|
||||
|
||||
const SUMMARIES = {
|
||||
THRESHOLD_TOKENS: 200, //trigger summary when session hits this many tokens
|
||||
THRESHOLD_TOKENS: 200, //trigger summary when session hits this many tokens
|
||||
MAX_SUMMARY_TOKENS: 800, //if existing summary exceeds this, create new instead of update
|
||||
MIN_EPISODES_SINCE: 5, // don't resummarize until N new episodes since last summary
|
||||
MAX_SUMMARY_CHARS: 8000, // max chars to include from recent episodes when generating summary (to control prompt size)
|
||||
MAX_PROJECT_EPISODE_LIMIT: 200, // max number of episodes to consider from the entire project when generating summary (to control prompt size)
|
||||
}
|
||||
|
||||
const ENTITIES = {
|
||||
TEMPERATURE: 0.1,
|
||||
NUM_PREDICT: 1024,
|
||||
TEMPERATURE: 0.1, // Low temperature, more precise extraction, less creative
|
||||
NUM_PREDICT: 1024, // Max tokens to consider for entity extraction (e.g. recent conversation)
|
||||
THRESHOLD: 0.55, // Minimum confidence score for an extracted entity to be included in the results
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const {getEnv} = require('./config/env');
|
||||
const {QDRANT, COLLECTIONS, EPISODIC, SERVICES, OLLAMA, PORTS, LLAMACPP, INFERENCE_DEFAULTS, SQLITE, ORCHESTRATION, SUMMARIES, ENTITIES } = require('./config/constants');
|
||||
const {parseRow, formatEpisodeText} = require('./utils')
|
||||
const {logger} = require('./utils/logger');
|
||||
|
||||
module.exports = {
|
||||
getEnv,
|
||||
@@ -18,4 +19,5 @@ module.exports = {
|
||||
formatEpisodeText,
|
||||
SUMMARIES,
|
||||
ENTITIES,
|
||||
logger,
|
||||
};
|
||||
12
packages/shared/src/utils/logger.js
Normal file
12
packages/shared/src/utils/logger.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const LEVELS = { error: 0, warn: 1, info: 2, debug: 3 };
|
||||
|
||||
const current = LEVELS[process.env.LOG_LEVEL?.toLowerCase()] ?? LEVELS.info;
|
||||
|
||||
const logger = {
|
||||
error: (...args) => current >= LEVELS.error && console.error('[ERROR]', ...args),
|
||||
warn: (...args) => current >= LEVELS.warn && console.warn( '[WARN]', ...args),
|
||||
info: (...args) => current >= LEVELS.info && console.log( '[INFO]', ...args),
|
||||
debug: (...args) => current >= LEVELS.debug && console.log( '[DEBUG]', ...args),
|
||||
};
|
||||
|
||||
module.exports = logger;
|
||||
Reference in New Issue
Block a user