Convex Agents Tools by sstobo/convex-skills
npx skills add https://github.com/sstobo/convex-skills --skill 'Convex Agents Tools'赋予智能体超越文本生成的操作能力。工具允许智能体调用 Convex 函数、外部 API 以及复杂的操作。
创建支持 Convex 的工具:
import { createTool } from "@convex-dev/agent";
import { z } from "zod";
export const getUserDataTool = createTool({
description: "通过电子邮件获取用户信息",
args: z.object({
email: z.string().email().describe("用户的电子邮件地址"),
}),
handler: async (ctx, { email }): Promise<string> => {
const user = await ctx.runQuery(api.users.getUserByEmail, { email });
return user ? JSON.stringify(user) : "User not found";
},
});
const agentWithTools = new Agent(components.agent, {
name: "Database Agent",
languageModel: openai.chat("gpt-4o-mini"),
tools: {
getUserData: getUserDataTool,
},
maxSteps: 5, // 允许工具调用
});
export const autonomousAgent = action({
args: { threadId: v.string(), request: v.string() },
handler: async (ctx, { threadId, request }) => {
const { thread } = await agentWithTools.continueThread(ctx, { threadId });
const result = await thread.generateText(
{ prompt: request },
{ maxSteps: 10 } // 最多允许 10 次工具调用
);
return result.text;
},
});
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
.describe() 有助于 LLM 理解参数每周安装次数
–
代码仓库
GitHub 星标数
23
首次出现时间
–
安全审计
Equips agents with the ability to take actions beyond text generation. Tools allow agents to call Convex functions, external APIs, and complex operations.
Create Convex-aware tools:
import { createTool } from "@convex-dev/agent";
import { z } from "zod";
export const getUserDataTool = createTool({
description: "Fetch user information by email",
args: z.object({
email: z.string().email().describe("The user's email address"),
}),
handler: async (ctx, { email }): Promise<string> => {
const user = await ctx.runQuery(api.users.getUserByEmail, { email });
return user ? JSON.stringify(user) : "User not found";
},
});
const agentWithTools = new Agent(components.agent, {
name: "Database Agent",
languageModel: openai.chat("gpt-4o-mini"),
tools: {
getUserData: getUserDataTool,
},
maxSteps: 5, // Allow tool calls
});
export const autonomousAgent = action({
args: { threadId: v.string(), request: v.string() },
handler: async (ctx, { threadId, request }) => {
const { thread } = await agentWithTools.continueThread(ctx, { threadId });
const result = await thread.generateText(
{ prompt: request },
{ maxSteps: 10 } // Allow up to 10 tool calls
);
return result.text;
},
});
.describe() on fields helps LLMs understand parametersWeekly Installs
–
Repository
GitHub Stars
23
First Seen
–
Security Audits
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
58,500 周安装