Code Monkey home page Code Monkey logo

autocoder's Introduction

autocoder

Code that basically writes itself.

Quickstart

To run with a prompt

python start.py

To use autocoder inside other projects and agents

from autocoder import autocoder
data = {
    "project_name": "random_midi_generator", # name of the project
    "goal": "Generate a 2 minute midi track with multiple instruments. The track must contain at least 500 notes, but can contain any number of notes. The track should be polyphonic and have multiple simultaneous instruments", # goal of the project
    "project_dir": "random_midi_generator", # name of the project directory
    "log_level": "normal", # normal, debug, or quiet
    "step": False, # whether to step through the loop manually, False by default
    "model": "gpt-3.5-turbo", # default
    "api_key": <your openai api key> # can also be passed in via env var OPENAI_API_KEY
}

autocoder(project_data)

Core Concepts

Autocoder is a ReAct-style python coding agent. It is designed to be run standalone with a CLI or programmatically by other agents.

More information on ReAct (Reasoning and Acting) agents can be found here.

Loop

Autocoder works by looping between a "reason"" and "act" step until the project is validated and tested. The loop runs forever but you can enable "step" mode in options to step through the loop manually.

Actions

Autocoder uses OpenAI function calling to select and call what we call actions. Actions are functions that take in a context object and return a context object. They are called during the "act" step of the loop.

Context

Over the course of the loop, a context object gets built up which contains all of the data from the previous steps. This can be injeced into prompt templates using the compose_prompt function.

Here is the data that is available in the context object at each step:

# Initial context object
context = {
    epoch,
    name,
    goal,
    project_dir,
    project_path
}

# Added by reasoning step
context = {
    reasoning,
    file_count,
    filetree,
    filetree_formatted,
    python_files,
    main_success,
    main_error,
    backup,
    project_code: [{
        rel_path,
        file_path,
        content,
        validation_success,
        validation_error,
        test_success,
        test_error,
    }],
    project_code_formatted
}

# Action step context
context = {
    name, # project name
    goal, # project goal
    project_dir,
    project_path,
    file_count,
    filetree,
    filetree_formatted, # formatted for prompt template
    python_files,
    main_success, # included in project_code_formatted
    main_error, # included in project_code_formatted
    backup,
    available_actions, # list of available actions
    available_action_names, # list of just the action names
    project_code_formatted, # formatted for prompt template
    action_name,
    reasoning, # formatted for prompt template
    project_code: [{
        rel_path,
        file_path,
        content,
        validation_success,
        validation_error,
        test_success,
        test_error,
    }]
}

autocoder's People

Contributors

lalalune avatar solaasan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.