utilityInference layer 2
This commit is contained in:
@@ -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 };
|
||||
Reference in New Issue
Block a user