{% youtube RAzYo02HTXA %}
帶上您的 Swagger/OpenAPI 文件,它將轉變為 AI 聊天機器人。
從現在開始,每個後端開發人員都可以成為AI開發人員。
考慮到後端開發人員的工作性質,他們實際上比傳統的 AI/ML 工程師更適合進行 AI 代理開發。
後端開發人員,讓我們與@agentica
一起成為 AI 開發人員
Github 倉庫:https://github.com/wrtnlabs/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 代理開發。於是我從購物後端伺服器中取得了一個包含 289 個 API 函數的swagger.json
文件,並向他示範了購物 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 函數呼叫的框架。我們在 2023 年開發了這項技術,現在我們已將其作為開源發布。
使用@agentica
框架,您可以透過 TypeScript 類別類型和 Swagger/OpenAPI 文件提供功能。透過攜帶您後端伺服器的OpenAPI文件,您可以與您的後端伺服器進行對話交互,透過自然對話執行API功能。
透過購物中心後端伺服器,使用者可以使用對話文字搜尋和購買商品。使用 GitHub 伺服器,您可以建立一個從您的程式碼中學習並執行即時編碼的代理。透過組合 TypeScript 類,您可以開發與行動裝置和後端伺服器互動的代理程式。
此外,如果你同時提供多個 OpenAPI 文件,例如arxiv
、 newspaper
和notion
,你的 AI 代理可以透過分析學術論文和新聞文章來撰寫 Notion 文件。當你要求代理分析最近的韓國經濟趨勢、對其進行評論、組織相關論文並在 Notion 中記錄所有內容時,AI 代理將無縫執行所有這些任務。
也可以從 TypeScript 類別提供函數
{% youtube hzkNNt7bvUQ %}
- [`IShoppingSaleUnitStock`](https://github.com/samchon/shopping-backend/blob/master/src/api/structures/shoppings/sales/IShoppingSaleUnitStock.ts)
- [`IShoppingCouponRestriction`](https://github.com/samchon/shopping-backend/blob/master/src/api/structures/shoppings/coupons/IShoppingCouponRestriction.ts)
- [`ShoppingCustomerOrderController`](https://github.com/samchon/shopping-backend/blob/master/src/controllers/shoppings/customers/orders/ShoppingCustomerOrderController.ts)
考慮到他們的典型工作,後端開發人員實際上比其他任何人都更適合開發人工智慧代理,甚至是傳統的人工智慧/機器學習開發人員。
考慮購物中心的例子。後端開發人員在研究和實現 SKU(庫存單位)等核心領域概念的同時設計 API 和 DTO。對於每個API和DTO,他們都寫了詳細的解釋來指導客戶端開發人員。
這些後端開發人員經常建立的 API 函數和 DTO 模式的清晰定義和詳細描述可作為理想的 AI 提示。事實上,我透過加入解釋 API 函數之間關係的描述,僅用一天時間就成功建立了一個購物聊天機器人。
後端開發人員,您已經具備成為 AI 開發人員的條件。讓我們使用我們的 API 設計技能來開發 AI 代理程式。只需取得您的swagger.json
文件,它就可以直接轉換為企業級 AI 代理。
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>>;
}
{% youtube 4kohpDkhV5w %}
如果您是 AI 新手,您可能會想知道@agentica
如何透過函數完成所有事情。
相反,如果您是 AI 代理開發的專家,您可能會有不同的問題。傳統代理開發圍繞著代理工作流程圖展開,那麼@agentica
如何利用 LLM 函數呼叫來實現類似的功能?
請造訪我們的框架主頁或閱讀我之前的文章以了解@agentica
的關鍵原則。這些資源將向您介紹新的 AI 開發範式:「編譯器驅動開發」和「文件驅動開發」。
Github 倉庫:https://github.com/wrtnlabs/agentica
原文出處:https://dev.to/samchon/every-backend-developer-is-a-great-ai-developer-338m