Files
nexusAI/packages/orchestration-service/src/services/embedding.js
2026-04-05 21:49:31 -07:00

18 lines
506 B
JavaScript

const {getEnv, SERVICES } = require('@nexusai/shared')
const BASE_URL = getEnv('EMBEDDING_SERVICE_URL', SERVICES.EMBEDDING_URL);
async function embed(text) {
const res = await fetch(`${BASE_URL}/embed`, {
method: 'POST',
headers: { 'Content-Type': 'application/json'},
body: JSON.stringify({text}),
})
if (!res.ok) throw new Error(`Embedding service error: ${res.status}`);
const data = await res.json();
return data.embedding;
}
module.exports = { embed };