utilityInference layer 2

This commit is contained in:
Storme-bit
2026-08-17 07:41:41 -07:00
parent fab8f32395
commit 2bee4b23d6
4 changed files with 58 additions and 56 deletions
+2
View File
@@ -17,6 +17,7 @@ const {
} = require('./config/constants');
const {parseRow, formatEpisodeText, isTrivialTurn} = require('./utils')
const logger = require('./utils/logger');
const utilityInference = require('./utils/utilityInference');
module.exports = {
getEnv,
@@ -38,4 +39,5 @@ module.exports = {
logger,
RETRIEVAL,
UTILITY,
utilityInference,
};
@@ -0,0 +1,20 @@
const { getEnv } = require('../config/env');
const { SERVICES } = require('../config/constants');
// Client for the inference service's /utility/complete route.
// Resolved at call time (not module load) so each service's .env applies.
async function utilityInference({ system, user, json = false, temperature, maxTokens }) {
const base = getEnv('INFERENCE_SERVICE_URL', SERVICES.INFERENCE_URL);
const res = await fetch(`${base}/utility/complete`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ system, user, json, temperature, maxTokens }),
});
if (!res.ok) throw new Error(`Utility inference error: ${res.status}`);
const data = await res.json();
return data.text;
}
module.exports = { utilityInference };