Files
agent-s-rag-pamyatyu/src/agent.js
T
2026-06-24 14:28:11 +03:00

14 lines
485 B
JavaScript

const { getChatCompletion } = require('./utils');
const retriever = require('./retriever');
async function ask(question) {
const passages = await retriever.getRelevantPassages(question, 3);
const context = passages.join('\n---\n');
const prompt = `You are an assistant. Use the following context to answer the question.\n\nContext:\n${context}\n\nQuestion: ${question}\nAnswer:`;
const answer = await getChatCompletion(prompt);
return answer;
}
module.exports = {
ask,
};