页面加载中...
结合 RAG 架构与 Agent Skill,实现从文档嵌入、向量检索到结果生成的完整知识问答链路。
RAG(Retrieval-Augmented Generation)= 检索 + 生成。先从知识库找相关内容,再让 LLM 基于检索结果回答。
核心链路:用户问题 -> Embedding -> 向量搜索 -> Top-K 文档 -> LLM -> 回答
创建一个 document-embedder Skill:
function chunkDocument(text, chunkSize = 500, overlap = 50) { const chunks = []; let start = 0; while (start < text.length) { chunks.push(text.slice(start, start + chunkSize)); start += chunkSize - overlap; } return chunks; }
async function retrieve(query, topK = 5) { const queryEmbedding = await embed(query); const results = await vectorDB.search(queryEmbedding, topK); return results.map(r => r.text); }
将检索结果作为上下文注入 Prompt,并标注来源。如果资料中没有相关信息,明确说明。
Agent 站点首选部署平台,零配置部署 Next.js,全球 CDN
立即体验 →