refactoring and clean up
This commit is contained in:
@@ -17,15 +17,64 @@ const EPISODIC = {
|
||||
DEFAULT_RECENT_LIMIT: 10, // Default number of recent episodes to retrieve
|
||||
DEFAULT_PAGE_SIZE: 20, // Default number of episodes per page for pagination
|
||||
DEFAULT_SEARCH_LIMIT: 10, // Default number of search results to return
|
||||
DEFAULT_OFFSET: 0,
|
||||
DEFAULT_SESSIONS_LIMIT: 20,
|
||||
};
|
||||
|
||||
const ORCHESTRATION = {
|
||||
RECENT_EPISODE_LIMIT: 5,
|
||||
SEMANTIC_LIMIT: 5,
|
||||
SCORE_THRESHOLD: 0.75,
|
||||
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.`
|
||||
}
|
||||
|
||||
const OLLAMA = {
|
||||
DEFAULT_URL: 'http://localhost:11434',
|
||||
EMBED_MODEL: 'nomic-embed-text',
|
||||
OLLAMA_MODEL: 'companion:latest',
|
||||
};
|
||||
|
||||
const LLAMACPP = {
|
||||
DEFAULT_URL: 'http://localhost:8080',
|
||||
DEFAULT_MODEL: 'local-model',
|
||||
}
|
||||
|
||||
const PORTS = {
|
||||
INFERENCE: '3001',
|
||||
MEMORY: '3002',
|
||||
EMBEDDING: '3003',
|
||||
ORCHESTRATION: '4000',
|
||||
};
|
||||
|
||||
const SERVICES = {
|
||||
EMBEDDING_URL: 'http://localhost:3003'
|
||||
EMBEDDING_URL: `http://localhost:${PORTS.EMBEDDING}`,
|
||||
MEMORY_URL: `http://localhost:${PORTS.MEMORY}`,
|
||||
INFERENCE_URL: `http://localhost:${PORTS.INFERENCE}`,
|
||||
};
|
||||
|
||||
const INFERENCE_DEFAULTS = {
|
||||
TEMPERATURE: 0.7, // Controls randomness. 0 = deterministic, 1 = creative
|
||||
MAX_TOKENS: 1024, // Max tokens to generate in a response
|
||||
TOP_P: 0.9, // Nucleus sampling — considers tokens comprising top 90% probability mass
|
||||
TOP_K: 40, // Limits token selection to top K candidates at each step
|
||||
REPEAT_PENALTY: 1.1, // Penalizes recently used tokens to reduce repetition
|
||||
SEED: null, // null = random. Set to an integer for reproducible outputs
|
||||
};
|
||||
|
||||
const SQLITE = {
|
||||
DEFAULT_PATH: './data/nexusai.db'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
QDRANT,
|
||||
COLLECTIONS,
|
||||
EPISODIC,
|
||||
SERVICES
|
||||
SERVICES,
|
||||
OLLAMA,
|
||||
PORTS,
|
||||
LLAMACPP,
|
||||
INFERENCE_DEFAULTS,
|
||||
SQLITE,
|
||||
ORCHESTRATION
|
||||
};
|
||||
@@ -1,4 +1,19 @@
|
||||
const {getEnv} = require('./config/env');
|
||||
const {QDRANT, COLLECTIONS, EPISODIC, SERVICES } = require('./config/constants');
|
||||
const {QDRANT, COLLECTIONS, EPISODIC, SERVICES, OLLAMA, PORTS, LLAMACPP, INFERENCE_DEFAULTS, SQLITE, ORCHESTRATION } = require('./config/constants');
|
||||
const {parseRow, formatEpisodeText} = require('./utils')
|
||||
|
||||
module.exports = {getEnv, QDRANT, COLLECTIONS, EPISODIC, SERVICES};
|
||||
module.exports = {
|
||||
getEnv,
|
||||
QDRANT,
|
||||
COLLECTIONS,
|
||||
EPISODIC,
|
||||
SERVICES,
|
||||
OLLAMA,
|
||||
PORTS,
|
||||
LLAMACPP,
|
||||
INFERENCE_DEFAULTS,
|
||||
SQLITE,
|
||||
ORCHESTRATION,
|
||||
parseRow,
|
||||
formatEpisodeText,
|
||||
};
|
||||
13
packages/shared/src/utils.js
Normal file
13
packages/shared/src/utils.js
Normal file
@@ -0,0 +1,13 @@
|
||||
function parseRow(row) {
|
||||
if (!row) return null;
|
||||
return {
|
||||
...row,
|
||||
metadata: row.metadata ? JSON.parse(row.metadata) : null
|
||||
};
|
||||
}
|
||||
|
||||
function formatEpisodeText(userMessage, aiResponse) {
|
||||
return `User: ${userMessage}\nAssistant: ${aiResponse}`;
|
||||
}
|
||||
|
||||
module.exports = { parseRow, formatEpisodeText };
|
||||
Reference in New Issue
Block a user