Skip to content

humanloop/asap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ASAP - Autonomous Shell Assistant Program

Fix bugs and understand issues in your codebase. Powered by GPT-4.

Run something like asap do "fix my type errors" and the agent will:

  • attempt to understand the issue
  • read the relevant code
  • figure out the fix
  • apply a patch to your files
  • checkout a fresh git branch
  • and, commit the changes.

You'll be able to step in with assistance or confirmations at various stages to help guide the process.

Prerequisites

To run asap, you'll need:

Setup

To start using asap, do the following:

  1. Clone this repo
  2. cd to the project directory
  3. Run npm install to install dependencies
  4. If you want to be able to invoke asap from any other directory on your machine (suggested) run npm install -g .
  5. Run npm build (required as the project is written in TypeScript and needs to be compiled)
  6. By this point, you should be able to directly invoke asap help from the command line.
    • If the asap executable is not found, you may need to add your global npm binary directory to your PATH. To find this directory, run echo $(npm config get prefix)/bin
  7. Next, configure your installation by running asap init. You'll be asked to provide your API keys for both Humanloop and OpenAI.
    • The program will then install a project called asap in your Humanloop account and deploy the relevant model config to that project.

Developing

If you want to work on developing asap, run npm run dev in a new terminal. This will run the TypeScript compiler in watch mode so that next time you run asap do "..." you'll get the latest behaviour. To work on improving your prompts, we recommend using the Humanloop editor and environment deployments to control which model configuration you target.

How it works

Tool Calling

asap works by including a "tool call" in the prompt which tells GPT-4 that it can request running any command in your terminal to help debug the issues and answer the questions you ask. Tool calls correspond to function calling for OpenAI models. The basic concept is that you can define certain functions that the model is allowed to call by providing a description and function signature; if the model calls your function, you perform whatever processing is necessary to determine the output and provide this back to the model in the next chat message.

As an example, if you ask asap to fix your TypeScript type errors, the model is likely to first ask to run tsc (the TypeScript compiler). The asap program then actually executes the desired tsc command on your machine, and then passes the output from stdout back to the model. This process continues in an infinite while-loop until the model is satisfied that it has resolved your issue.

In addition to the CLI tool call, there are a couple more tool calls exposed to the model. The three tools which are:

  • cli_call: Run a CLI command with the specified arguments in the project directory.
  • done: Call this when satisfied that the problem is resolved.
  • patch: Call this to apply a modification to a file in the project.

You can inspect the exact definition of these tools in the Humanloop Editor (after you have setup with asap init).

Examples

Try running asap on the examples in the /examples directory in the project repo. For instance:

  1. Navigate to examples/1
  2. Run asap do "fix the typescript errors"
  3. You should find that asap attempts to run tsc --noEmit, or something similiar, to determine the errors it needs to fix, and then reads the output of the command before proceeding to explore the relevant files and apply fixes.

Usage

Usage: asap [options] [command]

Autonomous Shell Assistant Program

Options:
  -V, --version               output the version number
  -h, --help                  display help for command

Commands:
  init [options]              set up your `asap` installation
  do [options] <instruction>  ask asap to do something
  help [command]              display help for command

About

Autonomous Shell Assistant Program

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published