1.1.13 • Published 3 months ago

ggai v1.1.13

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

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.)
1.1.13

3 months ago

1.1.12

4 months ago

1.1.11

4 months ago

1.1.9

5 months ago

1.1.8

5 months ago

1.1.7

5 months ago

1.1.6

5 months ago

1.1.5

5 months ago

1.1.10

5 months ago

1.1.4

5 months ago

1.1.3

5 months ago

1.1.1

5 months ago

1.1.0

5 months ago

1.0.6

6 months ago

1.1.2

5 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago