Giter VIP home page Giter VIP logo

reagent's Introduction

Reagent logo


Reagentai twitter npm package MIT

Reagent

Graph based AI agent framework

Reagent is an open-source Javascript framework to build AI agents. It allows you to build AI agents with multi-step workflows by combining nodes into an agent graph.

It supports rendering custom UI components directly from the workflow nodes and seamlessly integrates with any frontend frameworks like NextJs, Remix, Solid-start, Svelte Kit, etc.

Demo

Agent UI demo

Features

  • Auto generate workflow graph: Generate the agent graph automatically
  • Supports Any AI Model: Use OpenAI, Anthropic, Mistral, Groq or any other model provider
  • Framework Agnostic: Works with any modern JavaScript framework: React, Solid, Svelte and Vue
  • Easy Integration: Easily integrate into your existing application
  • Full type safety: It is written in Typescript and supoprts type inference when building an agent graph

Use cases

  • AI Chat: Build custom AI chat applications
  • Workflows: Easily build custom AI powered workflows
  • AI Agent: Build custom AI agents with backend/frontend tool calling

Getting Started

Installation

npm install @reagentai/reagent @reagentai/cli

Example: Simple chat application

Here's a very simple AI chat application.

import "dotenv/config";
import { GraphAgent } from "@reagentai/reagent/agent";
import {
  ChatCompletion,
  ChatInput,
  User,
} from "@reagentai/reagent/agent/nodes";
import { Groq } from "@reagentai/reagent/llm/integrations/models";
import { DummyModel } from "@reagentai/reagent/llm/models/dummy";

// create a new agent
const agent = new GraphAgent({
  name: "Simple AI Chat",
  description: "A simple AI chat agent.",
});

// add an input node; each agent must have an input node and user node for final output
const input = agent.addNode("input", new ChatInput());

// add a chat completion node
const chat1 = agent.addNode("chat-1", new ChatCompletion(), {
  config: {
    systemPrompt: "You are an amazing AI assistant called Jarvis",
    temperature: 0.9,
    stream: true,
  },
});

// add user node; this is a mandatory node for output
const user = agent.addNode("user", new User());

// bind chat completion node's inputs
chat1.bind({
  // TODO: replace model with an actual model
  model: new Groq({ model: "llama3-8b-8192" }),
  query: input.output.query,
});

// bind user node's inputs
user.bind({
  markdown: chat1.output.markdown,
  markdownStream: chat1.output.stream,
});

// export agent as default to run this agent with reagentai cli
export default agent;
export const nodes = [];
export const __reagentai_exports__ = true;

To run this chat agent, copy the above code to a agent.ts, add .env file with GROQ_API_KEY={groq_api_key}, and run the following command:

pnpm reagent dev agent.ts

The following agent graph is auto generated for the above chat agent:

Agent UI demo

LICENSE

MIT

reagent's People

Contributors

poudels14 avatar bookofbash avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.