Table of Content
Prologue
Hello, guys. Nowadays, AI is all the rage, and high schools are teaching Ai, so I'm getting more and more interested in AI.
So I was naturally interested in Agent, which is a more complex behavior beyond just AI.
A Lucky Discovery
Then I was looking for articles on dev.to and found these two articles.
When I saw these two articles, I first realized that there is a concept of function calling in the agent.
It was a fresh shock to me that I could call the API and utilize the result or use the API as a phrase of the AI by sending a request to the AI.
I thought, "If I have this, I can really do everything."
Enter Agentica
Then I came across a library I had never seen before, Agentica
, and I followed the documentation and it was surprisingly simple.
I was able to create my first agent in a few hours, as opposed to the days I spent struggling with LangChain
.
I went from building a chatbot in Python to creating an agent that searches Google for keywords and adds events to my calendar.
Agentica
provides a set of APIs called connectors as a library, which made it even easier.
Here's some example code
import { Agentica } from "@agentica/core";
import typia from "typia";
import dotenv from "dotenv";
import { OpenAI } from "openai";
import { GoogleSearchService } from "@wrtnlabs/connector-google-search";
dotenv.config();
export const agent = new Agentica({
model: "chatgpt",
vendor: {
api: new OpenAI({
apiKey: process.env.OPENAI_API_KEY!,
}),
model: "gpt-4o-mini",
},
controllers: [
{
name: "GoogleSearch Connector",
protocol: "class",
application: typia.llm.application<GoogleSearchService, "chatgpt">(),
execute: new GoogleSearchService(),
},
],
});
const main = async () => {
console.log(await agent.conversate("What can you do?"));
};
main();
The Magic of Swagger Integration
And the most interesting part? You only need to provide an API document called Swagger, and the function call works seamlessly.
That got me thinking—why not try it out with my simple To-Do List project?
Stackblitz Link(Please click this link)
If you follow the link here, you can see the code in action! Just enter the API key into the AgentService and it works.
So I put in the swagger of my todo list project, and the AI understood it and called the API right away!!?!!??!!
I was really surprised to see that when I said add something to do by tomorrow
, it actually added it.
const swagger: OpenApi.IDocument = fs.readFileSync(
"./swagger.json",
"utf-8",
) as unknown as OpenApi.IDocument;
const agent: Agentica<"chatgpt"> = new Agentica({
model: "chatgpt",
vendor: {
api: new OpenAI({ apiKey: MyGlobal.env.OPENAI_API_KEY }),
model: "gpt-4o-mini",
},
controllers: [
{
name: "Todo list",
protocol: "class",
application: HttpLlm.application({
model: "chatgpt",
document: swagger,
}),
connection: {
host: swagger.servers?.[0]?.url ?? "http://localhost:3000",
},
},
],
});
const main = async () => {
console.log(await agent.conversate("What can you do?"));
};
main();
Conclusion
Agentica seems to be really beginner-friendly yet powerful. I'm a high school student and I can do this,
and I think it's amazing what other working developers can do with it.
Top comments (2)
Good explanation provided
Thanks for reading!