For the complete documentation index, see llms.txt. This page is also available as Markdown.

Installing our SDK

This guide will walk you through the essential workflow of using our SDK to interact with the Codeset API. You will learn how to create a session, execute commands within it, verify the outcome, and properly close the session.

Prerequisites

Before you begin, you will need to have the following installed:

  • Python 3.7 or later

  • The codeset library

Step 1: Install the Codeset SDK

You can install the codeset library using pip (or other alternative):

pip install codeset

Step 2: Create a Session

The first step is to create a session. A session represents a sandboxed environment where you can execute commands and run verifications. To create a session, you will need to provide a dataset and sample_id. A sample_id is a unique identifier for a specific task or problem.

from codeset import Codeset
import os

client = Codeset(api_key=os.getenv("CODESET_API_KEY"))

session = client.sessions.create(
    dataset="codeset-gym-python",
    sample_id="matiasb__python-unidiff-19"
)

Step 3: Interact with the Session

Once you have created a session, you can execute commands in the sandboxed environment. For example, you can run tests or explore the codebase:

Step 4: Apply Changes

If you need to modify files in the environment, you can use the str_replace method:

Step 5: Verify the Outcome

After you have executed your commands, you can verify the results. A verification is a process that checks if the task has been completed successfully.

Step 6: Close the Session

Finally, you should close the session to release the resources.

Last updated