Convex Agent

作者 get-convex2cfe645c87f9无许可证63 个星标收录于 2026年10月8日更新于 2026年10月8日仓库6天前更新

Add an AI agent / RAG backend (@convex-dev/agent) to the Convex app.

仅含说明AI & Agents
AI 生成的概览

使用 @convex-dev/agent 为 Convex 应用添加 AI 代理与 RAG 后端,支持持久化线程和向量检索。

功能
该技能指导在 Convex 应用中添加 AI 代理与 RAG 后端:安装 @convex-dev/agent 和 @convex-dev/ai-sdk-provider,并在 convex.config.ts 中注册代理组件。内容包括定义带工具和指令的代理、创建线程并流式传输消息且将历史持久化到 Convex,以及将文档嵌入向量索引以供检索。模型调用默认走 Convex AI Gateway,网关不可用时回退到存储在 Convex 环境中的提供商密钥。
适用场景
当 Convex 应用需要内置 AI 代理、持久化对话线程、工具调用或检索增强生成时使用。适合希望无需自行管理 LLM 密钥即可调用模型的 Convex Cloud 项目。
运行要求
AI Gateway 需要 Convex Cloud 付费计划上的 Convex 1.45+;需要 @convex-dev/agent 和 @convex-dev/ai-sdk-provider 包;RAG 需要将嵌入提供商密钥存入 Convex 环境;网关不可用时需要将提供商密钥存入 Convex 环境。仅含说明,无脚本。
<!-- GENERATED from convex-agents content/capabilities/agent.json — do not edit by hand. -->

Add an AI agent / RAG backend

Install @convex-dev/agent for durable threads, message history, tool-calls, and vector search/RAG — the backend for an in-app AI agent. Call models through the Convex AI Gateway by default: Convex holds the provider credentials, so there is no LLM key to obtain, store, or rotate.

Workflow

  1. Install @convex-dev/agent + @convex-dev/ai-sdk-provider; add the agent component to convex.config.ts.
  2. Define the agent (tools, instructions) with languageModel: convexGateway("provider/model") — no API key needed (needs convex 1.45+ on a Convex Cloud deployment, paid plan).
  3. Create threads + stream messages; persist history in Convex.
  4. For RAG: embed docs into a vector index and retrieve in the tool. The gateway does not serve embeddings yet, so store the embedding provider's key via the env micro power.
  5. Only if the gateway is unavailable (free plan, self-hosted, local backend): call the provider SDK with a key stored via the env micro power.

Rules

  • Default to the Convex AI Gateway (convexGateway from @convex-dev/ai-sdk-provider) for model calls; fall back to a provider key in Convex env only where the gateway is unavailable (free plan, self-hosted, local backend).
  • Never expose a provider API key client-side; when one is needed (embeddings, gateway fallback), keep it in Convex env via the env micro power.
  • Run model calls in actions ('use node' if the SDK needs it).
  • Persist threads/messages in Convex for durability + reactivity.

来源与署名

来源:get-convex/agent-skills位于skills/convex-agent提交2cfe645

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架