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 🙏

© 2026 – Pkg Stats / Ryan Hefner

synthmind

v1.0.9-mini-dev-2

Published

## Overview

Readme

AI Agent Library Documentation

Overview

This library provides a framework for creating and interacting with AI agents using various models (OpenAI, Azure OpenAI, Groq) and tools. It includes features such as memory management, custom tools, and vector-based knowledge retrieval.

Installation

(Note: Installation steps are not provided in the given code. You should include steps to install the library and its dependencies here.)

Key Components

  1. Agents
  2. Tools
  3. Memory
  4. Vector Store

Usage

1. Setting up the environment

First, set up your environment variables:

MONGODB_URI=your_mongodb_uri
OPENAI_API_KEY=your_openai_api_key
AZURE_OPENAI_API_KEY=your_azure_openai_api_key
OPENAI_API_BASE_URL=your_azure_openai_base_url
GROG_KEY=your_groq_api_key

2. Importing required modules

import OpenAIAgent from "./Agent/OpenaiAgent/openai.js";
import AzureOpenAIAgent from "./Agent/OpenaiAgent/azure.js";
import GroqAgent from "./Agent/GroqAgent/groq.js";
import { createTools, createTool } from "./Agent/tools.js";
import AgentMemory from "./Agent/memory/memory.js";

3. Creating custom tools

You can create custom tools using the createTool function:

const customTool = createTool({
    tool_name: 'tool_name',
    description: 'Tool description',
    parameters: {
        type: 'object',
        properties: {
            // Define tool parameters here
        },
        required: ['required_params'],
    },
    tool_function: (query) => {
        // Implement tool functionality here
    }
});

4. Initializing an agent

You can initialize different types of agents:

OpenAI Agent

const openaiAgent = new OpenAIAgent({
    systemMessage: "Your system message here",
    tools: tools,
    apiKey: process.env.OPENAI_API_KEY,
    memory: true
});

Azure OpenAI Agent

const azureAgent = new AzureOpenAIAgent({
    systemMessage: "Your system message here",
    tools: createTools(),
    apiKey: process.env.AZURE_OPENAI_API_KEY,
    endpoint: process.env.OPENAI_API_BASE_URL,
    apiVersion: "2022-12-01",
    deployment: "gpt-4o",
    memory: true,
});

Groq Agent

const groqAgent = new GroqAgent({
    systemMessage: "Your system message here",
    tools: tools,
    apiKey: process.env.GROG_KEY,
    memory: true
});

5. Sending messages to an agent

const response = await agent.sendMessage("Your message here");
console.log(response);

6. Using the vector store

The library includes functions for embedding text and retrieving similar documents:

import { embedText, embeddingRetrieve } from "./Embedding/mongo/index.js";

// Retrieve similar documents
const documents = await embeddingRetrieve({
    query: "Your query here",
    dbUri: process.env.MONGODB_URI,
    openAIApiKey: process.env.OPENAI_API_KEY
});

7. Using memory

The library includes a memory management system:

AgentMemory.addMessage({ userMessage: "hello", agentMessage: "hello" });

Advanced Features

Human Tool

The library includes a "human tool" that allows for human intervention in the agent's decision-making process:

const humanTool = createTool({
    tool_name: 'human',
    description: 'Useful for invoking a human supervisor.',
    parameters: {
        type: 'object',
        properties: {
            query: {
                type: "string",
                description: "context",
            },
        },
        required: ['query'],
    },
    tool_function: (query, conversationId) => humanTool(query, conversationId, sessions)
});

Interactive Mode

The library supports an interactive mode where users can input queries and receive responses from the agent:

async function main() {
    while (true) {
        const query = await getUserInput();
        if (/exit/i.test(query)) break;
        
        const response = await agent.sendMessage(query);
        console.log(response);
    }
}

Error Handling

(Note: Error handling is not explicitly shown in the provided code. You should include information about how errors are handled and how users should manage exceptions.)

Limitations

(Note: Include any known limitations of the library here.)

Contributing

(Note: Include information about how others can contribute to the library here.)

License

(Note: Include licensing information for the library here.)