Agentica:后端开发者的 AI 快速通道
Agentica 框架支持直接导入 OpenAPI 文档自动生成 AI 应用,大幅降低后端开发者的 AI 开发成本。营销色彩浓但工具实用。
Agentica 框架支持直接导入 OpenAPI 文档自动生成 AI 应用,大幅降低后端开发者的 AI 开发成本。营销色彩浓但工具实用。
带上你的 Swagger/OpenAPI 文档,它就能变成一个 AI 聊天机器人。
从现在起,每一位后端开发者都可以成为 AI 开发者。
考虑到后端开发者日常工作的性质,他们其实比传统的 AI/ML 工程师更适合开发 AI Agent。
后端开发者们,让我们使用 @agentica 成为 AI 开发者吧。
GitHub 仓库:https://github.com/wrtnlabs/agentica
指南文档:https://wrtnlabs.io/agentica
import { Agentica } from "@agentica/core";
import { HttpLlm } from "@samchon/openapi";
import OpenAI from "openai";
import typia from "typia";
const agent = new Agentica({
vendor: {
model: "gpt-4o-mini",
api: new OpenAI({ apiKey: "********" }),
},
controllers: [
{
protocol: "http",
application: HttpLlm.application({
model: "chatgpt",
document: await fetch(
"https://shopping-be.wrtn.ai/editor/swagger.json",
),
}),
connection: {
host: "https://shopping-be.wrtn.ai",
headers: {
Authorization: "Bearer ********",
},
},
},
],
});
await agent.conversate("I want to write an article.");
最近,我的老板向我展示了 Sierra.ai——一家由 OpenAI 董事会成员创办、估值 45 亿美元的公司。他问我,为什么我们不能做出类似的东西,并要求我证明为什么他还应该继续给我发工资。
查看 Sierra.ai 的首页后,我发现他们似乎专注于为电子商务和咨询服务开发 AI Agent。于是,我从一个购物后端服务器中取出 swagger.json 文件,其中包含 289 个 API 函数,然后向他演示了一个购物 AI 聊天机器人。
演示过程中,一切都运行得非常完美:搜索和购买商品、管理订单与配送、提供包含退款功能的客户服务,以及处理优惠券和账户余额。演示结束后,我的老板说:
嘿,我们应该把它开源。
让我们的技术闻名世界吧。
import { Agentica } from "@agentica/core";
import { HttpLlm } from "@samchon/openapi";
import typia from "typia";
const agent = new Agentica({
controllers: [
HttpLlm.application({
model: "chatgpt",
document: await fetch(
"https://shopping-be.wrtn.ai/editor/swagger.json",
).then(r => r.json()),
}),
typia.llm.application<MobileCamera, "chatgpt">(),
typia.llm.application<MobileFileSystem, "chatgpt">(),
typia.llm.application<MobilePhoneCall, "chatgpt">(),
],
});
await agent.conversate("I wanna buy MacBook Pro");
@agentica 是一个专门用于 LLM function calling 的框架。我们在 2023 年开发了这项技术,现在已经将它开源。
使用 @agentica 框架,你可以通过 TypeScript class 类型和 Swagger/OpenAPI 文档提供函数。只需引入后端服务器的 OpenAPI 文档,就可以让用户以对话方式与后端服务器交互,通过自然语言对话执行 API 函数。
如果接入的是商城后端服务器,用户便可以通过对话文本搜索和购买商品。如果接入的是 GitHub 服务器,你可以创建一个能够学习代码并进行实时编程的 Agent。结合 TypeScript class 后,你还可以开发同时与移动设备和后端服务器交互的 Agent。
此外,如果同时提供 arxiv、报纸和 Notion 等多个 OpenAPI 文档,你的 AI Agent 就能通过分析学术论文和新闻报道来撰写 Notion 文档。当你要求 Agent 分析近期韩国经济趋势、发表评论、整理相关论文,并将所有内容记录到 Notion 中时,AI Agent 会流畅地执行所有这些任务。
你也可以通过 TypeScript class 提供函数。
文档示例:IShoppingSaleUnitStock、IShoppingCouponRestriction、ShoppingCustomerOrderController
IShoppingSaleUnitStock
IShoppingCouponRestriction
ShoppingCustomerOrderController
Swagger-UI(editor):https://shopping-be.wrtn.ai/editor/
从后端开发者的日常工作来看,他们实际上比任何人都更适合开发 AI Agent,甚至比传统的 AI/ML 开发者更有优势。
以商城为例。后端开发者会在研究和实现 SKU(Stock Keeping Unit,库存单位)等核心领域概念的同时,设计 API 和 DTO。对于每个 API 和 DTO,他们都会编写详细说明,为客户端开发者提供指引。
后端开发者日常编写的这些清晰定义,以及对 API 函数和 DTO schema 的详细描述,恰好就是理想的 AI prompt。事实上,我只用了 一天时间,就成功构建出了购物聊天机器人;我所做的,只是添加一些描述,解释 API 函数之间的关系。
后端开发者们,你们早已具备成为 AI 开发者所需的一切。让我们运用自己的 API 设计能力来开发 AI Agent。只需拿出你的 swagger.json 文件,它就能直接转化为企业级 AI Agent。
export class ShoppingSaleController {
/**
* List up every summarized sales.
*
* List up every {@link IShoppingSale.ISummary summarized sales}.
*
* As you can see, returned sales are summarized, not detailed. It does not
* contain the SKU (Stock Keeping Unit) information represented by the
* {@link IShoppingSaleUnitOption} and {@link IShoppingSaleUnitStock} types.
* If you want to get such detailed information of a sale, use
* `GET /shoppings/customers/sales/{id}` operation for each sale.
*
* > If you're an A.I. chatbot, and the user wants to buy or compose
* > {@link IShoppingCartCommodity shopping cart} from a sale, please
* > call the `GET /shoppings/customers/sales/{id}` operation at least once
* > to the target sale to get detailed SKU information about the sale.
* > It needs to be run at least once for the next steps.
*
* @param input Request info of pagination, searching and sorting
* @returns Paginated sales with summarized information
* @tag Sale
*
* @author Samchon
*/
@TypedRoute.Patch()
public async index(
@AuthGuard() actor: Actor,
@TypedBody() input: IShoppingSale.IRequest,
): Promise<IPage<IShoppingSale.ISummary>>;
}
如果你刚接触 AI,可能会疑惑:@agentica 如何仅通过函数实现这一切?
反过来,如果你是 AI Agent 开发专家,或许会提出另一个问题。传统的 Agent 开发以 Agent workflow graph 为核心,那么 @agentica 是如何利用 LLM function calling 实现类似能力的?
请访问我们的框架主页,或者阅读我之前的文章,以了解 @agentica 的核心原理。这些资料将向你介绍新的 AI 开发范式:“Compiler-Driven Development”和“Document-Driven Development”。
GitHub 仓库:https://github.com/wrtnlabs/agentica
指南文档:https://wrtnlabs.io/agentica
https://dev.to/samchon/autoview-turning-your-blueprint-into-ui-components-ai-code-generator-fp/edit
下一篇文章将介绍如何根据 Swagger/OpenAPI 文档自动生成前端代码。这个新库名为 @autoview,将它与 @agentica 结合起来,便可以完全自动化前端开发。
如果你的后端服务器拥有 200 个 API 函数,@autoview 就会自动生成 200 个前端组件。如果你的后端服务器拥有 400 个 API 函数,@autoview 就会编写 400 份前端组件代码。
在新的 AI 时代,后端开发者无所不能。
对于后续操作,你可以考虑屏蔽此人和/或举报滥用行为。