feat: solution for 'Повторный экзамен: FAQ-бот — ChromaDB + один MCP-tool'

This commit is contained in:
2026-06-29 17:47:00 +03:00
parent 473f040da9
commit f7c159346a
6 changed files with 221 additions and 21 deletions
+50
View File
@@ -0,0 +1,50 @@
import dotenv from "dotenv";
import readline from "readline";
import { createAgent } from "./agent.js";
import { addDocument } from "./vectorstore.js";
dotenv.config();
const COLLECTION = "faq_collection";
async function main() {
// Optional: add some sample documents
await addDocument(
COLLECTION,
"What is the return policy?",
{ source: "FAQ" }
);
await addDocument(
COLLECTION,
"How can I track my order?",
{ source: "FAQ" }
);
const agent = await createAgent(COLLECTION);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
prompt: "You: ",
});
console.log("FAQ Bot is ready. Type your question and press Enter.");
rl.prompt();
rl.on("line", async (line) => {
const question = line.trim();
if (!question) {
rl.prompt();
return;
}
try {
const result = await agent.call({ input: question });
console.log(`Bot: ${result.output}`);
} catch (err) {
console.error("Error:", err);
}
rl.prompt();
});
}
main().catch((err) => console.error(err));