DEV Community

Cover image for I found interesting agent builder library
Bengaluru Kiran
Bengaluru Kiran

Posted on

9 5 5 5 5

I found interesting agent builder library

You can execute my code this link!(Please click this link)

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();
Enter fullscreen mode Exit fullscreen mode

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();
Enter fullscreen mode Exit fullscreen mode

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.

Heroku

Amplify your impact where it matters most — building exceptional apps.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (2)

Collapse
 
nadeem_zia_257af7e986ffc6 profile image
nadeem zia

Good explanation provided

Collapse
 
bengaluru_kiran_5f026f476 profile image
Bengaluru Kiran

Thanks for reading!

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay