Skip to main content

🤖💻 Intercode

Build interactive code environments for training, testing, and augmenting code and decision making agents

Build License

👋 Overview

InterCode is a lightweight, flexible, and easy-to-use framework for designing interactive code environments. Following the popular gym interface definition, InterCode makes it easy to quickly define a code environment and deploy an agent to operate in code within the context of the environment.

For an overview of InterCode, building interactive code tasks with InterCode, and evaluating agents on InterCode environments, please check out our wiki, website and the original paper:

InterCode: Standardizing and Benchmarking Interactive Coding with Execution Feedback

🛠️ Installation

Note InterCode requires the following installations to run:

  • python >= 3.8
  • docker: Learn more here to install.
pip install intercode-bench

🚀 Quick Start

Before running the below code, make sure the Docker daemon/application is running locally.

Bash

Create a python file and copy + paste the following code to interact with the InterCode Bash environment.

import readline
from intercode.assets import bash_build_docker, bash_image_name, bash_test_data
from intercode.envs import BashEnv

if __name__ == '__main__':
    bash_build_docker()
    env = BashEnv(bash_image_name, data_path=bash_test_data, traj_dir="logs/", verbose=True)

    try:
        for idx in range(3):
            env.reset()
            obs, done = env.observation, False
            while not done:
                action = input('> ')
                obs, reward, done, info = env.step(action)
    except KeyboardInterrupt:
        print("Keyboard interrupt detected")
    finally:
        env.close()

If InterCode was installed successfully, the InterCode Bash environment should be started successfully and a CLI interpreter should appear, allowing you to enter bash commands to interact with the task setting's file system. You can ^c at any to time to exit the environment.

SQL

Create a python file and copy + paste the following code to interact with the InterCode SQL environment.

import readline
from intercode.assets import sql_build_docker, sql_image_name, sql_test_data
from intercode.envs import SqlEnv

from typing import Dict
def preprocess(record: Dict) -> str:
    db = record["extra"]["db"]
    return f"use {db}"

if __name__ == '__main__':
    sql_build_docker()
    env = SqlEnv(sql_image_name, data_path=sql_test_data, preprocess=preprocess, traj_dir="logs/", verbose=True)

    try:
        for idx in range(3):
            env.reset()
            obs, done = env.observation, False
            while not done:
                action = input('> ')
                obs, reward, done, info = env.step(action)
    except KeyboardInterrupt:
        print("Keyboard interrupt detected")
    finally:
        env.close()

If InterCode was installed successfully, the InterCode SQL environment should be started successfully and a CLI interpreter should appear, allowing you to enter SQL commands to interact with the task setting's MySQL database. You can ^c at any to time to exit the environment.

🔎 Learn More

To learn more about the InterCode framework, please check out the website and GitHub repository

🪪 License

Check LICENSE.md

Release files for intercode-bench 0.1.22

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for intercode-bench 0.1.22
File Size Uploaded
intercode-bench-0.1.22.tar.gz 141.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for intercode-bench 0.1.22
File Interpreter ABI Platform
intercode_bench-0.1.22-py3-none-any.whl Python 3 none any Details

Total release size: 285.1 kB

Release files / intercode-bench-0.1.22.tar.gz

Download URL intercode-bench-0.1.22.tar.gz
Size 141.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3cbceb06febaf2a1de1c981757d4bd154ec44fe4a344995b6305a3d1d2717e2a
BLAKE2b-256 checksum
How to use checksums
18028d99e54630c8d8bd9c827ae9f80a52def3c0806eb31ee9681226fc8b3fbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / intercode_bench-0.1.22-py3-none-any.whl

Download URL intercode_bench-0.1.22-py3-none-any.whl
Size 143.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3cecd6796bdb70276a5915ca1db725b5e419291638a34383b16747530d95b8cc
BLAKE2b-256 checksum
How to use checksums
e23d2539ef4f919bbb601c4a92eaf27ef66d85f72af4d4ac5f0c1d048389f10f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.1.22 This release

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.19

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page