npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-agency

v0.0.14

Published

A node package for building AI agents

Downloads

126

Readme

npm install node-agency


Node Agency

⚠️ This project is in development and looking for contributors.

Inspired by CrewAI this frameworks goal is to make it easy to use nodejs to build & deploy agents.

This has very basic agent capabilities, and is nowhere near as advanced as many of the other python based libraries, but this will be fun to improve, so anyone who would like to help, you are more than welcome.

Install

npm install node-agency

Features

  • Hierarchy & Sequential agent process
  • Asynchronous Tool Calling
  • Sharing of Context between agents
  • Short Term Memory (RAG)
  • Advanced Chatbot Functionality with streaming support
  • Have agents ask for feedback on planning and next steps.
  • Task delegation and communication between agents
  • Easily add PDF's & websites as resources
  • Easy Defining of custom tools (OpenAI or Claude model required, more support coming soon.)

Quick Start

import "dotenv/config";
import { Agency, Agent, Task, Tool } from "node-agency";
import { Model as OpenAIModel } from "node-agency/models/openai";
import { Model as OllamaModel } from "node-agency/models/ollama";
import { Model as ClaudeModel } from "node-agency/models/claude";

/* Create a simple tool */
const SearchTool = async (searchTerms: string) => {
  console.log("Searching for AI advancements related to:", searchTerms);
  return JSON.stringify([
    {
      id: 1,
      name: "Google Scholar",
      url: "https://scholar.google.com/",
      content:
        "The latest OpenAI Sora Model shocks the internet with its capabilities. The model is capable of generating human-like video with minimal prompts. The model is expected to revolutionize the field of AI and video. The model is available on the OpenAI API.",
    },
    {
      id: 2,
      name: "ArXiv",
      url: "https://arxiv.org/",
      content:
        "The latest Google release Gemini Pro 1.5 have 2 million token context window. They also release vemo for video generation that outputs 1080p long form video.",
    },
    {
      id: 3,
      name: "Semantic Scholar",
      url: "https://www.semanticscholar.org/",
      content:
        "The latest advancements in AI include the release of the OpenAI Sora Model and the Google Gemini Pro 1.5. As well as new ChatGPTo multimodel from OpenAI. That can reason across multiple modalities.",
    },
  ]);
};

/* Register Tool */
const searchTool = Tool({
  name: "search_tool",
  run: SearchTool,
  description: "Search for AI advancements",
  parameters: {
    type: "object",
    properties: {
      searchTerms: {
        type: "string",
        description: "Search query for AI advancements",
      },
    },
    required: ["searchTerms"],
  },
});

/* Create Agents */
const researcher = Agent({
  role: "Senior Research Analyst",
  goal: "Uncover cutting-edge developments in AI and data science",
  tools: [searchTool],
  model: new ClaudeModel({
    ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY || ""
  })
});

const writer = Agent({
  role: "Tech Content Strategis",
  goal: "Craft compelling content on tech advancements",
  model: new OllamaModel({
    model: "llama3",
  }),
});

/* Create Tasks */
const researchTask = Task({
  // agent: researcher, // You can also pass the agent here
  expectOutput: "Full analysis report in bullet points",
  description:
    "Conduct a comprehensive analysis of the latest advancements in AI in 2024. Identify key trends, breakthrough technologies, and potential industry impacts.",
});

const summaryTask = Task({
  expectOutput: "Full blog post of at least 4 paragraphs",
  description: `Using the insights provided, develop an engaging blog
  post that highlights the most significant AI advancements.
  Your post should be informative yet accessible, catering to a tech-savvy audience.
  Make it sound cool, avoid complex words so it doesn't sound like AI.`,
});

/* Create Agency */
const agency = Agency({
  agents: [researcher, writer],
  tasks: [researchTask, summaryTask],
  llm: new OpenAIModel({
    OPENAI_API_KEY: process.env.OPENAI_API_KEY || "",
    model: "gpt-4o", // defaults to gpt-3.5-turbo
    parallelToolCalls: true,
  }),
});

/* Kickoff the Agency */
agency.kickoff().then((response) => {
  console.log(response);
});

Sequential Process

const agency = Agency({
  agents: [researcher, writer],
  tasks: [researchTask, summaryTask],
  process: "sequential",
  memory: true,
  outFile: "./output.txt",
});

Receive requests for your feedback from your agents (default)

const agency = Agency({
  agents: [researcher, writer],
  tasks: [researchTask, summaryTask],
  llm: new Model({
    OPENAI_API_KEY: process.env.OPENAI_API_KEY || "",
    model: "gpt-3.5-turbo",
    parallelToolCalls: true,
  }),
  process: "sequential",
  memory: true,
  humanFeedback: true
});

Add RAG Knowledge with Resources

const agency = Agency({
  agents: [researcher, writer],
  tasks: [researchTask, summaryTask],
  resources: [
    "https://www.wbu.edu/academics/writing-center/documents/Converting%20Google%20and%20Word%20Docs.pdf",
    "https://react.dev/reference/react",
  ],
  memory: true, // memory required for resources
  llm: new Model({
    OPENAI_API_KEY: process.env.OPENAI_API_KEY || "",
    model: "gpt-3.5-turbo",
    parallelToolCalls: true,
  }),
});

Memory (Short-term)

const agency = Agency({
  agents: [researcher, writer],
  tasks: [researchTask, summaryTask],
  memory: true,
  llm: new Model({
    OPENAI_API_KEY: process.env.OPENAI_API_KEY || "",
    model: "gpt-3.5-turbo",
    parallelToolCalls: true,
  }),
});

Advanced: Chatbot Functionality

With Streaming:

agency
  .executeStream(
    "What are the latest AI advancements?, and what advancements are there in self-driving cars?"
  )
  .then(async (response) => {
    for await (const part of response) {
      process.stdout.write(part);
    }
  });

Without Streaming:

agency.execute("hello").then((response) => {
  console.log(response);
});

With External History:

import { History } from "node-agency"; // Import History Type

...

agency
  .execute("hello", [
    { role: "user", content: "Hello" },
    { role: "assistant", content: "How can I help you?" },
    { role: "user", content: "What is the largest city in Florida?" },
    {
      role: "assistant",
      content: "The largest city in Florida is Jacksonville.",
    },
  ] as History)
  .then((response) => {
    console.log(response);
  });

Supported Models

  • OpenAI (Defaults to GPT 3.5-Turbo)
  • Anthropic Claude
  • Ollama (Tools not supported yet)
  • More coming soon.

Road Map

  • [x] Initial working release
  • [x] Self-Reflection
  • [x] Support Ollama Models / Open Source
  • [x] Short term memory (RAG)
  • [x] Chatbot RAG support
  • [x] Claude Support
  • [ ] Allow connecting to external vector store databases (Pinecone, Postgres, Supabase)
  • [ ] Long-term memory (SQLlite)
  • [ ] Ollama Function Calling Support
  • [ ] Groq Support
  • [ ] Documention
  • [ ] Analytics
  • [ ] Chain of thought / Reasoning