0.4.2 • Published 8 months ago

@gensx/core v0.4.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

GenSX ⚡️

GenSX is a framework for building LLM workflows and AI agents with TypeScript. Every GenSX component is a pure function, and thus easily shareable by default.

Getting started

📦 Installing

pnpm install @gensx/core
yarn add @gensx/core
npm install @gensx/core

Building a workflow

import * as gensx from "@gensx/core";
import { openai } from "@ai-sdk/openai";
import { generateText } from "@gensx/vercel-ai";

// input interface
interface WriteDraftInput {
  research: string[];
  prompt: string;
}

// components are pure functions that are reusable by default
const WriteDraft = gensx.Component(
  "WriteDraft",
  async ({ prompt, research }: WriteDraftInput) => {
    const systemMessage = `You're an expert technical writer.
    Use the information when responding to users: ${research.join("\n")}`;

    const result = await generateText({
      messages: [
        {
          role: "system",
          content: systemMessage,
        },
        {
          role: "user",
          content: `Write a blog post about ${prompt}`,
        },
      ],
      model: openai("gpt-4.1-mini"),
    });

    return result.text;
  },
);

Components can be composed together to create more complex agents and workflows:

import * as gensx from "@gensx/core";
import { OpenAIProvider } from "gensx/openai";
import { Research, WriteDraft, EditDraft } from "./writeBlog";

interface WriteBlogInput {
  title: string;
  description: string;
}

const WriteBlog = gensx.Workflow(
  "WriteBlog",
  async ({ title, description }: WriteBlogInput) => {
    const queries = await GenerateQueries({
      title,
      description,
    });
    const research = await ResearchBlog({ queries });
    const draft = await WriteDraft({ title, context: research });
    const final = await EditDraft({ title, content: draft });
    return final;
  },
);

const result = await WriteBlog({
  title: "How AI broke modern infra",
  description: "Long-running workflows require a new approach to infra",
});
0.4.2

8 months ago

0.4.1

8 months ago

0.4.0

8 months ago

0.4.0-alpha.5

8 months ago

0.4.0-alpha.4

8 months ago

0.4.0-alpha.3

8 months ago

0.4.0-alpha.2

8 months ago

0.4.0-alpha.1

8 months ago

0.3.13

8 months ago

0.3.12

9 months ago

0.3.11

9 months ago

0.3.10

9 months ago

0.3.9

9 months ago

0.3.8

9 months ago

0.3.7

10 months ago

0.3.6

10 months ago

0.3.5

10 months ago

0.3.4

10 months ago

0.3.3

10 months ago

0.3.2

10 months ago

0.3.1

11 months ago

0.3.0

11 months ago

0.2.16

11 months ago