Skip to content

Commit

Permalink
📜 update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Oct 22, 2023
1 parent 2789429 commit 2fbd51c
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 85 deletions.
1 change: 1 addition & 0 deletions docs/bitcoin_chart.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Bitcoin Chart

This example creates a CodeInterpreterSession and generates a response to plot the bitcoin chart for year 2023:

```python
Expand Down
1 change: 1 addition & 0 deletions docs/code_interpreter_response.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# CodeInterpreterResponse

The CodeInterpreterResponse contains the AI agent's response.

It contains:
Expand Down
2 changes: 1 addition & 1 deletion docs/code_interpreter_session.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# CodeInterpreterSession

The CodeInterpreterSession is the main class that manages a conversational session between the user and AI agent. It handles starting, stopping and checking status of the secure isolated code execution environment.

Key responsibilities:
Expand All @@ -17,7 +18,6 @@ It provides methods like:
- `log()`: Log messages
- `show_code` - Callback to print code before running.


The response generation happens through a pipeline:

1. User input is parsed
Expand Down
1 change: 1 addition & 0 deletions docs/codebox.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# CodeBox

The CodeBox class provides the isolated secure environment for executing python code. It is used by the CodeInterpreterSession internally.

It provides methods like:
Expand Down
1 change: 1 addition & 0 deletions docs/concepts_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Concepts Overview

| name | description |
|-|-|
| CodeInterpreterSession | Main class that manages a code execution session |
Expand Down
36 changes: 4 additions & 32 deletions docs/deploy.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Deployment

CodeInterpreterAPI can be easily deployed to production using the CodeBox framework.

## Prerequisites

- CodeBox API key
- Get your API key from [CodeBox](https://pay.codeboxapi.com/b/00g3e6dZX2fTg0gaEE) (get 70% with the code `BETA`)
- Get your API key from [CodeBox](https://pay.codeboxapi.com/b/00g3e6dZX2fTg0gaEE) (you get an email with the api-key)
- CodeInterpreterAPI installed
- `pip install codeinterpreterapi`

Expand All @@ -17,36 +19,6 @@ from codeinterpreterapi import settings
settings.CODEBOX_API_KEY = "sk-..."
```

## Starting a Session

To start a code interpreter session using CodeBox:

```python
from uuid import uuid4
from codeinterpreterapi import CodeInterpreterSession

session_id = uuid4()

session = CodeInterpreterSession.from_id(session_id)
session.start()
```

The `session_id` allows restoring the session later after restarting the application.

## Generating Responses

With the session started, you can now generate responses like normal:

```python
response = session.generate_response(
"Plot a histogram of the iris dataset"
)

response.show()
```

This will execute the code securely using CodeBox.

## Stopping the Session

Don't forget to stop the session when finished:
Expand All @@ -61,4 +33,4 @@ This will shutdown the CodeBox instance.

- See the [CodeBox docs](https://codeboxapi.com/docs) for more details on deployment options.
- Look at the [examples](https://github.com/shroominic/codebox-api/tree/main/examples) for more usage ideas.
- Contact [Shroominic](https://twitter.com/shroominic) for assistance with scaling.
- Contact [Shroominic](https://twitter.com/shroominic) for assistance with deployment.
3 changes: 2 additions & 1 deletion docs/file.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# File
# File Object

The File class is used to represent files that are uploaded or downloaded during the session.

It stores the filename and binary content of the file.
Expand Down
35 changes: 7 additions & 28 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
# CodeInterpreterAPI Documentation
# Welcome

CodeInterpreterAPI is a Python-based API designed give LLM Agents access to python and execute code. It provides a session-based conversational chat interface and the agent framework with a tool for executing code in a secure and isolated environment.
This project provides a LangChain implementation of the ChatGPT Code Interpreter. It allows you to have a back and forth chat with the AI assistant to get it to help with programming tasks, data analysis, and more. You can run everything local except the LLM using your own OpenAI API Key.

## Key Classes
Some key features:

### CodeInterpreterSession

This is the main class that manages a code execution session. It provides methods to start, stop, and check the status of the session. It also handles logging and file uploads for the session.

#### Methods

* `from_id(session_id: UUID, **kwargs) -> "CodeInterpreterSession"`: This class method creates a new session from a given UUID.
* `start() -> SessionStatus`: This method starts the session.
* `stop() -> SessionStatus`: This method stops the session.
* `log(msg: str) -> None`: This method logs a message.

### CodeBox

This class represents the code execution environment. It provides methods to upload files, execute code, and check the status of the execution. For more information look into the codebox api documentation.

## Usage

To use this API, create a new `CodeInterpreterSession` and use the `start` method to start the session. You can then use the `generate_response_sync` method to generate an AI response and the `stop` method to stop the session. You can use the generate response method multiple times in a single session to have a conversation with the AI.

## Contributing

Contributions are welcome. Please make sure to write functional Python with full type hinting and only write needed and precise comments.

(This file was half chatgpt generated and not complete - real docs coming soon!)
TODO: Write real docs
- Sandboxed execution of Python code snippets provided by the AI assistant using CodeBox. CodeBox is the simplest cloud infrastructure for your LLM Apps.
- Automatic handling of file uploads/downloads
- Support for stateful conversations with chat history
- Extensible architecture to add custom tools and logic
18 changes: 5 additions & 13 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# Installation
## Install Dependencies

To install, it's recommended to create a virtual environment (using `venv` in the example below):

```bash
python3 -m venv codeinterpreterenv
source codeinterpreterenv/bin/activate
```

Then install the package:
Install the package:

```bash
pip install "codeinterpreterapi[all]"
Expand All @@ -18,18 +10,18 @@ Everything for local experiments are installed with the all extra. For deploymen

## Set Up Environment Variables


You will also need to configure API keys for the AI model you want to use, either OpenAI, Anthropic, or Azure.

For OpenAI, create a `.env` file with:

```bash
OPENAI_API_KEY=sk-...
OPENAI_API_KEY=sk-**********
```
or export as an environment variable in your terminal:

or export as an environment variable in your terminal before running your code:

```bash
export OPENAI_API_KEY=your_openai_api_key
export OPENAI_API_KEY=sk-**********
```

For Azure, use:
Expand Down
1 change: 1 addition & 0 deletions docs/iris_dataset.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Analyzing the Iris Dataset

```python
from codeinterpreterapi import CodeInterpreterSession, File

Expand Down
1 change: 1 addition & 0 deletions docs/streamlit_webapp.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Using the Streamlit Webapp

The streamlit webapp allows interacting with the API through a GUI:

```bash
Expand Down
1 change: 1 addition & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Usage

To create a session and generate a response:

```python
Expand Down
1 change: 1 addition & 0 deletions docs/user_request.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# UserRequest

The UserRequest class represents the user input to the agent.

It contains:
Expand Down
9 changes: 0 additions & 9 deletions docs/welcome.md

This file was deleted.

25 changes: 24 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
site_name: CodeInterpreterAPI - Docs
site_name: CodeInterpreterAPI - Documentation
site_author: Shroominic
site_url: https://shroominic.github.io/codeinterpreter-api/
repo_name: shroominic/codeinterpreter-api
repo_url: https://github.com/shroominic/codeinterpreter-api/

nav:
- 'Getting Started':
- 'Welcome': 'index.md'
- 'Installation': 'installation.md'
- 'Usage': 'usage.md'
- 'Code Interpreter':
- 'Overview': 'concepts_overview.md'
- 'Session': 'code_interpreter_session.md'
- 'CodeBox': 'codebox.md'
- 'File': 'file.md'
- 'Request': 'user_request.md'
- 'Response': 'code_interpreter_response.md'
- 'Deployment': 'deploy.md'
- 'Examples':
- 'Bitcoin Chart': 'bitcoin_chart.md'
- 'Iris Dataset': 'iris_dataset.md'
- 'Streamlit Webapp': 'streamlit_webapp.md'

theme:
name: material
palette:
Expand Down

0 comments on commit 2fbd51c

Please sign in to comment.