orchestration fixes
This commit is contained in:
@@ -10,6 +10,6 @@
|
||||
"@nexusai/shared": "^1.0.0",
|
||||
"dotenv": "^17.4.0",
|
||||
"express": "^5.2.1",
|
||||
"node-fetch": "^3.3.2"
|
||||
"node-fetch": "^2.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const memory = require('./memory');
|
||||
const inference = require('./inference');
|
||||
const memory = require('../services/memory');
|
||||
const inference = require('../services/inference');
|
||||
|
||||
const SYSTEM_PROMPT = `You are a helpful, context-aware AI assistant.
|
||||
You have access to memories of past conversations with the user.
|
||||
@@ -7,10 +7,10 @@ Use them to provide consistent, personalised responses.`;
|
||||
|
||||
const RECENT_EPISODE_LIMIT = 10; // Number of recent episodes to retrieve for context
|
||||
|
||||
function buildPrompt(getRecentEpisodes, userMessage) {
|
||||
function buildPrompt(recentEpisodes, userMessage) {
|
||||
const parts = [SYSTEM_PROMPT];
|
||||
|
||||
if (getRecentEpisodes.length > 0) {
|
||||
if (recentEpisodes.length > 0) {
|
||||
parts.push(`Here are some relevant memories from your past conversations:`);
|
||||
for (const ep of recentEpisodes) {
|
||||
parts.push(`User: ${ep.user_message}\nAssistant: ${ep.ai_response}`);
|
||||
|
||||
@@ -3,7 +3,7 @@ const { chat } = require('../chat/index');
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.post('/chat', async (req, res) => {
|
||||
router.post('/', async (req, res) => {
|
||||
const { sessionId, message } = req.body;
|
||||
|
||||
if (!sessionId) return res.status(400).json({ error: 'sessionId is required'});
|
||||
|
||||
@@ -7,7 +7,7 @@ const BASE_URL = getEnv('MEMORY_SERVICE_URL', 'http://localhost:3002');
|
||||
async function getSessionByExternalId(externalId) {
|
||||
const res = await fetch(`${BASE_URL}/sessions/by-external/${externalId}`);
|
||||
|
||||
if (!res.status === 400) return null; // Not found or bad request
|
||||
if (!res.status === 404) return null; // Not found or bad request
|
||||
if (!res.ok) throw new Error(`Memory service error: ${res.status} ${res.statusText}`); // Other errors
|
||||
|
||||
return res.json();
|
||||
|
||||
Reference in New Issue
Block a user