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

ggai

v1.1.13

Published

OpenAI LLM Agent Interface

Downloads

38

Readme

GGAI

                      _
   ____ _____ _____ _(_)
  / __ `/ __ `/ __ `/ /
 / /_/ / /_/ / /_/ / /
 \__, /\__, /\__,_/_/ v1.1.13
/____//____/

ggai is a standalone AI assistant that is designed to help you perform tasks on your local system. It provides a wide range of functionalities, including file management, command execution, and system automation.

Prerequisites

  • Node.js v14.0 or higher
  • Mac or Linux based system (has not been tested on Windows)
  • OpenAI API Key, exposed as environment variable OPENAI_API_KEY

Installation

To install ggai, follow these steps:

npm i -g ggai

The ai command should now be available on you local system.

Usage

To use ggai, you can run the following command with the specified options:

ai [options]

Options:

  • -m, --model <model>: Specify the model. Choose from:

    • gpt-3.5-turbo-1106
    • gpt-4
    • gpt-4-1106-preview (Default: gpt-3.5-turbo-1106)
  • -t, --temperature <temp>: Specify the temperature. It should be a float between 0 and 2. (Default: 0.1)

  • -s, --system-prompt <prompt>: A message to be included for system guidance. It should be a string.

  • -tp, --tools-path <path>: Path to a custom tools file. It should be a string.

  • -e, --example-tools: Display an example tools file.

  • -v, --verbose: Display tool calls and results.

The above options allow you to configure the behavior of ggai to suit your needs. For example, you can choose the AI model, set the temperature for randomness in responses, provide a system prompt for context, specify a custom path for tools, and toggle verbose output.

Remember to have your OpenAI API Key set as an environment variable OPENAI_API_KEY before running the command.

Using Custom Tools

ggai allows for the integration of custom tools, which are JavaScript functions that can be invoked during execution. To use custom tools:

  1. Create a Custom Tools File: Define your custom functions in a JavaScript file. Refer to the tools.js in the GGAI package for the format and examples.

  2. Define Functions: Each function should return a Promise and handle the specific task, such as reading or writing files, or executing commands.

  3. Configure the Tools in tools.js: Export your functions and their configurations in tools.js. Ensure each function has a unique name and properly defined parameters.

  4. Invoke Custom Functions: When running ggai, you can use these custom functions as part of your command or scripts.

Using a Custom Agent

Customize your GGAI experience by defining a custom agent. This example shows how to create and integrate a custom agent, allowing you to tailor its capabilities for specific tasks and workflows.

const { Agent, ask } = require("ggai");

(async () => {
  const config = [
    {
      type: "function",
      function: {
        name: "log",
        description: "Log something to console.",
        parameters: {
          type: "object",
          properties: {
            text: {
              type: "string",
              description: "The text to log",
            },
          },
          required: ["text"],
        },
      },
    },
  ];

  const tools = {
    log: async ({ text }) => {
      console.log(`Logging from tool: ${text}`);
      return true;
    },
  };

  const systemPrompt = "You are a helpful assistant";

  const agent = new Agent({
    verbose: true,
    streamingIndicators: true,
    config,
    tools,
    systemPrompt,
  });

  while (true) {
    try {
      const question = await ask(">>>");
      await agent.send(question);
      console.log();
    } catch (err) {
      console.log();
      console.log(`Estimated cost: $${agent.cost.toFixed(5)}`);
      process.exit();
    }
  }
})();

Disclaimer

Please note that ggai provides powerful features that allow direct interaction with your local system. This includes the ability to execute commands and modify files.

By using ggai, you acknowledge and accept the risks associated with these functionalities. The development team holds no liability for any damage, data loss, or other issues that may occur as a result of using this AI assistant.

Use ggai responsibly and at your own risk.

TODO

  • Include more LLM parameters (i.e. top p, max tokens, etc.)