refactoring and clean up

This commit is contained in:
Storme-bit
2026-04-07 01:30:35 -07:00
parent 0aea052311
commit 2b75f75733
18 changed files with 191 additions and 115 deletions

View File

@@ -1,7 +1,6 @@
const fetch = require('node-fetch');
const { getEnv } = require('@nexusai/shared');
const { getEnv, SERVICES } = require('@nexusai/shared');
const BASE_URL = getEnv('INFERENCE_SERVICE_URL', 'http://localhost:3001');
const BASE_URL = getEnv('INFERENCE_SERVICE_URL', SERVICES.INFERENCE_URL);
async function complete(prompt, options ={}) {
const res = await fetch(`${BASE_URL}/complete`, {

View File

@@ -1,7 +1,6 @@
const fetch = require('node-fetch');
const { getEnv } = require('@nexusai/shared');
const { getEnv, SERVICES, EPISODIC } = require('@nexusai/shared');
const BASE_URL = getEnv('MEMORY_SERVICE_URL', 'http://localhost:3002');
const BASE_URL = getEnv('MEMORY_SERVICE_URL', SERVICES.MEMORY_URL);
//function to get session by external id, returns null if not found, throws error for other issues
async function getSessionByExternalId(externalId) {
@@ -24,7 +23,7 @@ async function createSession(externalId) {
return res.json();
}
async function getRecentEpisodes(sessionId, limit = 10) {
async function getRecentEpisodes(sessionId, limit = EPISODIC.DEFAULT_SESSIONS_LIMIT) {
const res = await fetch(`${BASE_URL}/sessions/${sessionId}/episodes?limit=${limit}`);
if (!res.ok) throw new Error(`Failed to fetch episodes: ${res.status} ${res.statusText}`);
return res.json();
@@ -47,7 +46,7 @@ async function getEpisodeById(episodeId) {
return res.json();
}
async function getSessionHistory(sessionId, limit = 20, offset = 0) {
async function getSessionHistory(sessionId, limit = EPISODIC.DEFAULT_SESSIONS_LIMIT, offset = EPISODIC.DEFAULT_OFFSET) {
const res = await fetch(
`${BASE_URL}/sessions/${sessionId}/episodes?limit=${limit}&offset=${offset}`
);
@@ -56,9 +55,9 @@ async function getSessionHistory(sessionId, limit = 20, offset = 0) {
return res.json();
}
async function getSessions(limit = 20, offset = 0) {
async function getSessions(limit = EPISODIC.DEFAULT_SESSIONS_LIMIT, offset = EPISODIC.DEFAULT_OFFSET) {
const res = await fetch(
`${BASE_URL}/sessions?limit${limit}&offset=${offset}`
`${BASE_URL}/sessions?limit=${limit}&offset=${offset}`
);
if (!res.ok) throw new Error(`Failed to fetch sessions: ${res.status}`);
return res.json();

View File

@@ -1,8 +1,8 @@
const {getEnv, QDRANT, COLLECTIONS } = require('@nexusai/shared')
const {getEnv, QDRANT, COLLECTIONS, ORCHESTRATION } = require('@nexusai/shared')
const BASE_URL = getEnv('QDRANT_URL', QDRANT.DEFAULT_URL);
async function searchEpisodes( vector, {limit = 5, scoreThreshold = 0.75, sessionId } = {}) {
async function searchEpisodes( vector, {limit = ORCHESTRATION.RECENT_EPISODE_LIMIT, scoreThreshold = ORCHESTRATION.SCORE_THRESHOLD, sessionId } = {}) {
const body = {vector, limit, score_threshold: scoreThreshold, with_payload: true};
if (sessionId) {