DEV Community

Cover image for Every TypeScript Developer is an AI Developer
Jeongho Nam
Jeongho Nam

Posted on • Edited on

85 11 12 11 12

Every TypeScript Developer is an AI Developer

1. Preface

Create TypeScript classes, and transform them into AI chatbots.

From now on, every TypeScript developer can become an AI developer.

TypeScript developers, let us become AI developers with @agentica.

import { Agentica } from "@agentica/core";
import OpenAI from "openai";
import typia from "typia";

const agent = new Agentica({
  vendor: {
    model: "gpt-4o-mini",
    api: new OpenAI({ apiKey: "********" }),
  },
  controllers: [
    {
      protocol: "class",
      application: typia.llm.application<BbsArticleService, "chatgpt">(),
      execute: new BbsArticleService(),
    },
  ],
});
await agent.conversate("I want to write an article.");
Enter fullscreen mode Exit fullscreen mode

2. Agentica Framework

@agentica is a framework specialized in LLM function calling.

You can provide functions through TypeScript class types. If you create the FileSystem class below and integrate it with @agentica, it becomes a filesystem chatbot. You can manage your filesystem through conversational text in the chatbot.

If you simultaneously provide multiple TypeScript classes such as GoogleScholarService, NaverNewsService, and NotionService, your AI agent can write a Notion document by analyzing scholarly papers and news articles. When you ask the agent to analyze recent Korean economic trends, comment on them, organize related papers, and write them in Notion, the AI agent will execute these tasks.

Simply define your TypeScript classes, and you can create any AI agent you desire.

import fs from "fs";

export class FileSystem {
  public __dirname(): string {
    return __dirname;
  }

  public readdir(input: {
    path: string;
    options?:
      | {
          encoding: "utf-8";
          withFileTypes?: false | undefined;
          recursive?: boolean | undefined;
        }
      | "utf-8"
      | null;
  }): Promise<string[]> {
    return fs.promises.readdir(input.path, input.options);
  }

  public readFile(input: { path: string }): Promise<string> {
    return fs.promises.readFile(input.path, "utf8");
  }

  public writeFileSync(input: { 
    file: string; 
    data: string;
  }): Promise<void> {
    return fs.promises.writeFile(input.file, input.data);
  }
}
Enter fullscreen mode Exit fullscreen mode

3. Enterprise Demonstration

Some may wonder: Don't the BbsArticleService or FileSystem classes have only a few functions? Is this merely a toy project that functions well in limited scenarios? Is it possible to create an enterprise-level chatbot with @agentica?

The answer is yes, it is indeed possible to create enterprise-grade chatbots.

Here is an enterprise-level shopping mall chatbot comprising 289 API functions. It supports most features of standard e-commerce platforms, and as demonstrated, it operates without issues.

For reference, @agentica can also acquire functions from Swagger/OpenAPI documentation. The demonstration below originates from a @samchon/shopping-backend.

import { Agentica } from "@agentica/core";
import { HttpLlm, OpenApi } from "@samchon/openapi";
import typia from "typia";

const agent = new Agentica({
  model: "chatgpt",
  vendor: {
    api: new OpenAI({ apiKey: "*****" }),
    model: "gpt-4o-mini",
  },
  controllers: [
    {
      protocol: "http",
      name: "shopping",
      application: HttpLlm.application({
        model: "chatgpt",
        document: await fetch(
          "https://shopping-be.wrtn.ai/editor/swagger.json",
        ).then((r) => r.json()),
      }),
      connection: {
        host: "https://shopping-be.wrtn.ai",
        headers: {
          Authorization: "Bearer *****",
        },
      },
    },
    {
      protocol: "class",
      name: "counselor",
      application: typia.llm.application<ShoppingCounselor, "chatgpt">(),
      execute: new ShoppingCounselor(),
    },
    {
      protocol: "class",
      name: "policy",
      application: typia.llm.application<ShoppingPolicy, "chatgpt">(),
      execute: new ShoppingPolicy(),
    },
    {
      protocol: "class",
      name: "rag",
      application: typia.llm.application<ShoppingSearchRag, "chatgpt">(),
      execute: new ShoppingSearchRag(),
    },
  ],
});
await agent.conversate("I want to buy a MacBook Pro");
Enter fullscreen mode Exit fullscreen mode

4. Principles

If you are not familiar with AI, you may wonder how @agentica can accomplish everything through functions.

Alternatively, if you are an expert in AI agent development, you might have a different question. Traditional agent development centers around agent workflow graphs, so how does @agentica utilize LLM function calling to achieve similar capabilities?

Visit our framework homepage or read my previous article to understand the key principles of @agentica. In these resources, you will learn about new AI development paradigms: "Compiler-Driven Development" and "Document-Driven Development."

5. Next Article

https://dev.to/samchon/every-backend-developer-is-a-great-ai-developer-338m

Every backend developer is also AI developer.

Considering the nature of work that backend developers do, they are actually better positioned for AI agent development than traditional AI/ML engineers.

Let's take swagger.json file to the @agentica, so that make an AI chatbot executing the API functions during the conversation.

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (4)

Collapse
 
samchon profile image
Jeongho Nam • Edited

Traffic is growing so much, and many people are bookmarking, but no one is commenting, so it's boring.

Do you have any articles you'd like to read at the next time?

  1. Every backend developer is also an AI developer.
  2. I succeeded to make a shopping mall AI agent with 289 API functions that no one could do.
  3. New AI paradigms: Compiler Driven Development and Document Driven Development
  4. Just about @agentica framework
Collapse
 
ritzdev profile image
mohammad shareef • Edited

This article is good, we can also use transformers (hugging face) and use any pretrained models(eg: BERT, GPT) based on the use case.

Collapse
 
samchon profile image
Jeongho Nam

You may like our roadmap - wrtnlabs.io/agentica/docs/roadmap/...

Collapse
 
hans_joo_109bc627faa7b0dc profile image
HANS JOO

우와 신기합니다. 항상 좋은글 감사합니다!

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please show some love ❤️ or share a kind word in the comments if you found this useful!

Got it!