主题
实战案例
(1) 构建一个问答系统
使用 LangChain.js 加载文档并回答问题。
示例:
javascript
import { VectorStoreIndexCreator, TextLoader } from "langchain/indexes";
const loader = new TextLoader("example.txt");
const docs = await loader.load();
const index = VectorStoreIndexCreator().fromDocuments(docs);
const result = await index.query("What is the main topic?");
console.log(result);
(2) 构建一个对话机器人
使用 ConversationalAgent
和 ConversationBufferMemory
构建对话机器人。
(3) 自动化工作流
使用 LangChain.js 自动化复杂任务(如数据提取、报告生成)。