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 🙏

© 2025 – Pkg Stats / Ryan Hefner

getgenai

v2.0.4

Published

Framework d'intelligence artificielle avec outils

Readme

GetGen AI Agent

Overview

GetGen is a TypeScript-based AI agent library that leverages the Zod schema validation library to create type-safe and reliable AI interactions.

GitHub Repository

Please feel free to contribute, any help is welcome

https://github.com/BoboFr/getgen

Features

  • Supports AI model interactions with schema-based response validation
  • Easy-to-use Agent class for executing AI prompts
  • Built-in type safety with Zod schemas
  • Extensible tool system for custom functionality
  • Chat-based interactions with AI models

Installation

npm install getgenai

Quick Start

import {z} from 'zod'
import { Agent } from 'getgenai';

// Create an agent with a specific model
const agent = new Agent({
    modelName: 'qwen2:latest'
});

// Define a response schema
const searchResponseSchema = z.object({
    capital: z.string(),
    population: z.number(),
});

// Execute an AI prompt with schema validation
const res = await agent.executeWithSchema(searchResponseSchema, {
    prompt: 'What is the capital of France?'
});
console.log(res);

Tool System

GetGen includes a powerful tool system that allows you to create custom tools for your AI agents. Here's how tools are structured:

Tool Usage Example

Here's how to create and use a simple tool:

import { Tool, ToolParameter } from 'getgenai';

// Define a simple calculator tool
const calculatorTool: Tool = {
    name: 'calculator',
    description: 'Performs basic arithmetic operations',
    parameters: [
        {
            name: 'operation',
            type: 'string',
            description: 'The operation to perform (add, subtract, multiply, divide)',
            required: true
        },
        {
            name: 'a',
            type: 'number',
            description: 'First number',
            required: true
        },
        {
            name: 'b',
            type: 'number',
            description: 'Second number',
            required: true
        }
    ],
    // The execute function is required and must return a Promise
    execute: async (params: Record<string, any>): Promise<any> => {
        const { operation, a, b } = params;
        let result;
        
        switch (operation) {
            case 'add':
                result = a + b;
                break;
            case 'subtract':
                result = a - b;
                break;
            case 'multiply':
                result = a * b;
                break;
            case 'divide':
                if (b === 0) throw new Error('Division by zero');
                result = a / b;
                break;
            default:
                throw new Error('Invalid operation');
        }
        
        return {
            success: true,
            data: result
        };
    }
};

// Use the tool
const result = await calculatorTool.execute({
    operation: 'add',
    a: 5,
    b: 3
});
console.log(result); // { success: true, data: 8 }

Chat Functionality

GetGen now supports chat-based interactions with AI models. Here's how to use the chat functionality:

import { Agent } from 'getgenai';

// Create a chat agent
const chatAgent = new Agent({
    modelName: 'llama3.2:latest',
    temperature: 0.8
});

// Simple chat interaction
const chatResponse = await chatAgent.chat([
    { role: 'system', content: 'You are a programming expert.' },
    { role: 'user', content: 'What is TypeScript?' }
]);

// Access the response
console.log(chatResponse.content);  // Latest response
console.log(chatResponse.history);  // Full chat history

// Continue the conversation
const followUpResponse = await chatAgent.chat([
    ...chatResponse.history,
    { role: 'user', content: 'Can you show me an example?' }
]);

Chat with Tools

You can also use tools in your chat interactions:

// Create a tool-enabled agent
const toolAgent = new Agent({
    modelName: 'llama3.2:latest',
    temperature: 0.2
});

// Add tools to the agent
toolAgent.addTools([myTool]);

// Chat with tool usage
const toolChatResponse = await toolAgent.chat([
    { 
        role: 'system', 
        content: 'You are an assistant that can use tools.' 
    },
    { 
        role: 'user', 
        content: 'Help me with a task that requires tools.' 
    }
]);

The chat functionality maintains conversation history and allows for natural, multi-turn interactions with the AI model while supporting tool usage when needed.

Dependencies

  • Zod
  • TypeScript

Contributing

We welcome contributions to GetGenAI! Here's how you can help:

Ways to Contribute

  1. Reporting Bugs

    • Use GitHub Issues to report bugs
    • Provide a clear and detailed description
    • Include steps to reproduce, expected behavior, and actual behavior
    • Attach code samples or screenshots if possible
  2. Feature Requests

    • Open a GitHub Issue for new feature suggestions
    • Describe the proposed feature and its potential benefits
    • Discuss the feature's alignment with the project's goals
  3. Code Contributions

    • Fork the repository
    • Create a new branch for your feature or bugfix
    • Follow our coding standards:
      • Use TypeScript
      • Maintain consistent code style
      • Write comprehensive tests
      • Update documentation

Development Setup

  1. Clone the repository

    git clone https://github.com/BoboFr/getgenai.git
    cd getgenai
  2. Install dependencies

    npm install
  3. Run dev

    npm run dev

Code of Conduct

  • Be respectful and inclusive
  • Provide constructive feedback
  • Collaborate openly and transparently

Questions?

If you have any questions, please open an issue or contact the maintainers directly.