The Agent Skills Directory
npx skills add https://smithery.ai/skills/Sstobo/convex-agents-rag使智能体能够搜索自定义内容和知识库,以提供准确、基于上下文的回答。RAG 结合了大型语言模型(LLM)的能力与语义搜索。
在您的 convex.config.ts 中安装并配置 RAG:
import { defineApp } from "convex/server";
import agent from "@convex-dev/agent/convex.config";
import rag from "@convex-dev/rag/convex.config";
const app = defineApp();
app.use(agent);
app.use(rag);
export default app;
将文档摄取到命名空间中:
import { rag } from "@convex-dev/rag";
export const addContent = action({
args: { userId: v.string(), key: v.string(), text: v.string() },
handler: async (ctx, { userId, key, text }) => {
const namespace = `user:${userId}`;
await rag.addContent(ctx, components.rag, {
namespace,
key,
text,
filters: { filterNames: [filename] },
});
},
});
与智能体一起使用 RAG:
export const answerWithContext = action({
args: { threadId: v.string(), userId: v.string(), question: v.string() },
handler: async (ctx, { threadId, userId, question }) => {
const { thread } = await myAgent.continueThread(ctx, { threadId });
const context = await rag.search(ctx, components.rag, {
namespace: `user:${userId}`,
query: question,
limit: 10,
});
const augmentedPrompt = `# Context:\n\n${context.text}\n\n# Question:\n\n${question}`;
const result = await thread.generateText({ prompt: augmentedPrompt });
return result.text;
},
});
user:userId 或 team:teamId 以确保多租户安全filterNames 来定位特定文档每周安装次数
–
来源
首次出现
–
Enables agents to search through custom content and knowledge bases to provide accurate, context-grounded responses. RAG combines LLM capabilities with semantic search.
Install and configure RAG in your convex.config.ts:
import { defineApp } from "convex/server";
import agent from "@convex-dev/agent/convex.config";
import rag from "@convex-dev/rag/convex.config";
const app = defineApp();
app.use(agent);
app.use(rag);
export default app;
Ingest documents into a namespace:
import { rag } from "@convex-dev/rag";
export const addContent = action({
args: { userId: v.string(), key: v.string(), text: v.string() },
handler: async (ctx, { userId, key, text }) => {
const namespace = `user:${userId}`;
await rag.addContent(ctx, components.rag, {
namespace,
key,
text,
filters: { filterNames: [filename] },
});
},
});
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
Use RAG with agents:
export const answerWithContext = action({
args: { threadId: v.string(), userId: v.string(), question: v.string() },
handler: async (ctx, { threadId, userId, question }) => {
const { thread } = await myAgent.continueThread(ctx, { threadId });
const context = await rag.search(ctx, components.rag, {
namespace: `user:${userId}`,
query: question,
limit: 10,
});
const augmentedPrompt = `# Context:\n\n${context.text}\n\n# Question:\n\n${question}`;
const result = await thread.generateText({ prompt: augmentedPrompt });
return result.text;
},
});
user:userId or team:teamId for multi-tenant safetyfilterNames to target specific documentsWeekly Installs
–
Source
First Seen
–
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
58,500 周安装