# Welcome to papertlab

{% embed url="<https://www.youtube.com/watch?v=Y4fFoPwY8Ac>" %}

papertlab is a cutting-edge AI-powered coding assistant designed to revolutionize the way developers write, edit, and understand code. By harnessing the power of advanced language models, papertlab seamlessly integrates into your development workflow, offering intelligent suggestions, automated refactoring, and contextual code understanding across multiple programming languages.

### What is papertlab?

papertlab is more than just a code editor – it's your personal AI programming partner. Whether you're a seasoned developer or just starting your coding journey, papertlab enhances your productivity by:

* Generating code snippets based on natural language descriptions
* Offering intelligent code completion and suggestions
* Providing explanations for complex code sections
* Assisting with bug detection and resolution
* Automating routine coding tasks and refactoring

### Key Features

* **AI-Powered Code Generation**: Transform your ideas into code with natural language prompts.
* **Multi-Language Support**: Work seamlessly across various programming languages.
* **Context-Aware Assistance**: papertlab understands your project structure and coding style.
* **Interactive Chat Interface**: Communicate with the AI assistant in a user-friendly chat environment.
* **Inline AI Editor** is a powerful feature that allows you to make targeted changes to your code directly within the papertlab interface.&#x20;
* **Version Control Integration**: Seamlessly work with Git repositories.
* **Customizable AI Models**: Choose from a range of AI models to suit your needs.
* **Usage Tracking**: Monitor your AI usage and associated costs.

### Why Choose papertlab?

papertlab stands out from traditional coding tools by offering:

* **Efficiency**: Reduce development time by automating repetitive tasks.
* **Learning**: Gain insights into best practices and new coding techniques.
* **Flexibility**: Adapt to your preferred coding style and project requirements.
* **Scalability**: Suitable for individual developers and large teams alike.

By combining the creativity and problem-solving skills of human developers with the processing power and knowledge base of AI, papertlab empowers you to write better code faster. Whether you're tackling complex algorithms, building web applications, or maintaining legacy systems, papertlab is your intelligent companion throughout the development process.

Get ready to experience the future of coding with papertlab – where AI meets human ingenuity to create exceptional software.


# Installation

**Create a Virtual Environment:**

Create and activate a virtual environment to keep your dependencies isolated:

**macOS/Linux:**

```
python3 -m venv papertlab-env
source papertlab-env/bin/activate
```

**Windows:**

```
python -m venv papertlab-env
.\papertlab-env\Scripts\activate
```

### I**nstall Papertlab:**

Install the Papertlab package using pip:

```
pip install papert-lab
```

**Run Papertlab:**

Navigate to your local Git repository or the directory you want to work in, then run:

```
papertlab
```

**Access Papertlab in Your Browser:**

Open your web browser and go to `http://127.0.0.1:5000/` to access the Papertlab interface.

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FirWxdsewcRhbmGVmtDKj%2Fv1.png?alt=media&amp;token=fe8b5421-22bd-4ebc-929c-e5028a62b040" alt=""><figcaption></figcaption></figure>


# &#x20;Prerequisites

### Prerequisites

Papertlab requires Universal Ctags for parsing code and generating tags. Follow the instructions below to install Ctags on your operating system.

### Installing Universal Ctags

#### F**or macOS and Linux (using Homebrew):**

**Install Homebrew (if not already installed):**

* **macOS**

```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

* **Linux:** Follow the [Linuxbrew installation instructions](https://docs.brew.sh/Homebrew-on-Linux).

**Install Universal Ctags:**

```
brew install --HEAD universal-ctags/universal-ctags/universal-ctags
```

**For Windows (using Chocolatey):**

* **Install Chocolatey:** Open an elevated Command Prompt and run:

```
Set-ExecutionPolicy Bypass -Scope Process -Force; `
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
```

* **Install Universal Ctags:**

```
choco install ctags
```

### Verify Ctags Installation

After installation, verify that Ctags is correctly installed by running the following command in your terminal or command prompt:

```
ctags --version
```


# Main Interface

The papertlab main interface is designed for efficiency and ease of use.

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FirWxdsewcRhbmGVmtDKj%2Fv1.png?alt=media&amp;token=fe8b5421-22bd-4ebc-929c-e5028a62b040" alt=""><figcaption></figcaption></figure>

**Key components:**

* Chat window (center)
* File panel (left sidebar)
* Input area (bottom)
* Control buttons (top right)


# File Management

### 2.1 Adding Files to Chat

To add files to the chat context:

1. Click the folder icon in the top right to open the file panel.
2. Check the boxes next to the files you want to include.

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FslxgECB0YfPHKQq77eu5%2Fadding%20the%20files.png?alt=media&amp;token=ac53770d-3143-4292-873d-b3234987c0e1" alt=""><figcaption></figcaption></figure>

### 2.2 Read-Only Files

Files marked as read-only are displayed with a lock icon. These files can be viewed but not edited through papertlab.

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FHxyNtPus8rkvWMYBb7w3%2Fread_only.png?alt=media&amp;token=7ccaa881-1e2a-4904-b04e-679b038e8082" alt=""><figcaption></figcaption></figure>

### 2.3 .papertlabignore

papertlab respects the `.papertlabignore` file in your project root. Files and directories listed in this file will not be shown in the file panel.

Example `.papertlabignore`:

```
node_modules/
*.log
secrets.yml
```

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FdG3SHbhrDcSsbqyKPQlA%2Fpapertignore.png?alt=media&amp;token=4e6a38c6-d90e-481c-8efa-a5869d54c803" alt=""><figcaption></figcaption></figure>


# Chat Interaction

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FMcvHmzV7cZwsKLtXU2Ih%2Fmodes.png?alt=media&amp;token=d4fe4092-9575-49d8-843c-187ba3fd863e" alt=""><figcaption></figcaption></figure>

### 3.1 Code Mode

By default, papertlab operates in "Code" mode, where it can suggest and make changes to your code.

### 3.2 Ask Mode

To switch to "Ask" mode:

1. Click the dropdown next to the input field.
2. Select "Ask".

In this mode, papertlab will answer questions about your code without making changes.

### 3.3 Autopilot Mode (Beta)

For autonomous code changes:

1. Select "Autopilot" from the mode dropdown.
2. Provide a high-level description of the changes you want.

Autopilot will attempt to make multiple changes to achieve the desired result.


# File Editor

The file editor in this application provides a powerful, in-browser code editing experience.

### Accessing the Editor

* In the file tree on the left side of the application, click on any file to open it in the editor.
* The editor will open in a modal window, taking up most of the screen.

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FxVVFVhzc0oAx4e4Vl4Jb%2Ffile%20editor.png?alt=media&amp;token=3b3afc78-b585-4013-92ac-dcdd827c5d97" alt=""><figcaption></figcaption></figure>

### Editor Features

#### 1. Syntax Highlighting

* The editor automatically detects the file type based on its extension and applies appropriate syntax highlighting.
* Supported languages include JavaScript, Python, HTML, and CSS.

#### 2. Line Numbers

* Line numbers are displayed on the left side of the editor for easy reference.

#### 3. Auto-Closing Brackets

* The editor automatically closes brackets, parentheses, and quotes as you type.

#### 4. Code Folding

* Click on the arrow icons in the gutter to fold or unfold sections of code.

#### 5. Search and Replace

* Use Ctrl-F (or Cmd-F on Mac) to open the search bar.
* Use Ctrl-H (or Cmd-Option-F on Mac) to open the replace function.

#### 6. Multiple Cursors

* Hold Ctrl (or Cmd on Mac) and click to add multiple cursors.

#### 8. Comment Toggling

* Use Ctrl-/ (or Cmd-/ on Mac) to toggle comments for the selected lines.

#### 9. Indentation

* The editor maintains proper indentation as you type.
* Use Tab to indent and Shift-Tab to un-indent.

### Saving Changes

* Changes are automatically saved when you close the editor.
* Click the "Close" button in the top-right corner of the editor to save and close.

### Keyboard Shortcuts

* Ctrl-F / Cmd-F: Find
* Ctrl-H / Cmd-Option-F: Replace
* Ctrl-/ / Cmd-/: Toggle comment
* Ctrl-Z / Cmd-Z: Undo
* Ctrl-Y / Cmd-Shift-Z: Redo
* Tab: Indent
* Shift-Tab: Un-indent

### Language Support

The editor provides enhanced support for:

* JavaScript
* Python
* HTML
* CSS

For other file types, basic syntax highlighting and editing features are still available.

### Best Practices

1. The editor auto-saves on close
2. Use code folding for long files to improve navigation.
3. Utilize multiple cursors for efficient batch editing.

### Troubleshooting

* If syntax highlighting isn't working correctly, check if the file has the correct extension.
* If you encounter any issues, try refreshing the page or reopening the file.

For any persistent issues or feature requests, please contact the development team.

### Auto-Commit Feature

When enabled, papertlab automatically commits changes to your Git repository. To toggle:

1. Go to Settings.
2. Find the "Auto-Commit" toggle.
3. Turn it on or off as desired.


# Inline AI Editor

The inline editor is a powerful feature that allows you to make targeted changes to your code directly within the papertlab interface. This document explains how to use the inline editor effectively.

### How to Use the Inline Editor

1. **Select Code**: In the main editor, select the block of code you want to modify.
2. **Initiate Inline Edit**: Press `Ctrl+I` (or `Cmd+I` on Mac) to open the inline edit dialog.
3. **Describe Changes**: In the dialog that appears, describe the changes you want to make to the selected code. Be as specific as possible.
4. **Review Suggested Changes**: The AI will analyze your request and present a diff view showing the&#x20;
5. **Accept or Reject Changes**:
   * Click "Accept" to apply the changes to your code.
   * Click "Reject" to discard the changes and return to the main editor.

### Best Practices

1. **Be Specific**: When describing desired changes, be as clear and specific as possible. For example, instead of "make this better", say "replace the for loop with a list comprehension".
2. **Review Carefully**: Always review the suggested changes carefully before accepting them. The AI is a tool to assist you, not replace your judgment.
3. **Start Small**: For complex changes, it's often better to make several small, focused edits rather than trying to change everything at once.
4. **Maintain Context**: The inline editor works best when it has full context. Try to select complete functions or logical blocks of code when making edits.

### Tips and Tricks

* **Multiple Changes**: You can request multiple changes in a single edit. For example, "Rename the variable 'x' to 'total' and add error handling to the division operation."
* **Formatting**: The inline editor will attempt to maintain the original code formatting. If you need to change the formatting, make that part of your request.
* **Comments**: You can ask the inline editor to add, modify, or remove comments in your code.
* **Refactoring**: Use the inline editor for quick refactoring tasks like renaming variables, extracting methods, or simplifying complex expressions.

### Troubleshooting

* **No Changes Applied**: If you accept changes but don't see them reflected in your code, check the console for any error messages. There might be issues with file permissions or the exact matching of the code block.
* **Unexpected Changes**: If the changes are not what you expected, simply reject them and try again with a more specific description of what you want to change.
* **Performance Issues**: For very large files or complex changes, the inline editor might take a moment to process. Be patient, and if issues persist, try breaking your changes into smaller steps.

### Limitations

* The inline editor works on a single file at a time. For changes across multiple files, you'll need to use it multiple times.
* While powerful, the AI is not perfect. Always review suggested changes for correctness and unintended side effects.
* The inline editor requires an active internet connection to function, as it relies on AI services.

### Feedback and Support

If you encounter any issues or have suggestions for improving the inline editor, please open an issue on our GitHub repository or contact our support team.

Remember, the inline editor is a tool to enhance your productivity, not replace your expertise. Use it wisely, and happy coding!


# Settings

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FirWxdsewcRhbmGVmtDKj%2Fv1.png?alt=media&amp;token=fe8b5421-22bd-4ebc-929c-e5028a62b040" alt=""><figcaption></figcaption></figure>

Access settings by clicking the gear icon in the top right.<br>

### API Key Management

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2F4ojEDaXhCiuQUc6QrYEr%2Fapi.png?alt=media&amp;token=e0c6c910-8c14-4949-9807-3cfaa8524fd9" alt=""><figcaption></figcaption></figure>

**To add or update API keys:**

1. Navigate to the "API Keys" section in Settings.
2. Enter your OpenAI API key.
3. Enter your Anthropic API key (if using Claude models).
4. Click "Save".


# Token & Usage Reporting Management

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FI7So1hpAF1RnHEehbFGM%2Fusage.png?alt=media&amp;token=123850c5-e8f5-402e-a4fe-262e5d73f488" alt=""><figcaption></figcaption></figure>

View and manage your token and usage:

* Click the "Usage" button in the top navigation.
* View token consumption by date, model, and project.
* See associated costs for your API usage.


# Auto Commit On/Off

Auto Commit is a feature that allows for automatic committing of changes to your version control system (e.g., Git) whenever certain actions are performed in the application. This can be particularly useful in environments where frequent, small changes are made and immediate version tracking is desired. However, in some cases, users may prefer to have more control over when commits are made, in which case the Auto Commit feature can be turned off.

### Functionality

#### Auto Commit On

When Auto Commit is **enabled**:

* Any changes made through the application that affect the project files (e.g., code modifications, configuration changes) are automatically committed to the version control system.
* The commit messages are typically generated automatically and may include details about the change or action that triggered the commit.
* This feature ensures that every change is tracked immediately without requiring manual intervention, reducing the risk of losing work and maintaining a comprehensive history of modifications.

#### Auto Commit Off

When Auto Commit is **disabled**:

* Changes made through the application will not be automatically committed.
* The user has full control over when and what to commit. This is useful for:
  * Reviewing multiple changes before committing.
  * Grouping related changes into a single commit.
  * Writing custom commit messages.
* Users will need to manually commit changes using the version control system's interface or command line.

### How to Enable/Disable Auto Commit

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FGXkWGHzQWzGC865ru3yf%2Fautocommit.png?alt=media&amp;token=a6ede8fe-18e4-445c-b705-d3549e5e7d3f" alt=""><figcaption></figcaption></figure>

#### 1. Via the Settings Interface

The Auto Commit feature can be toggled from the application's settings interface:

* **Enable Auto Commit:**
  1. Navigate to the "Config" section in the application settings.
  2. Check the box labeled "Enable Auto Commit."
  3. Click the "Save" button to apply the changes.
  4. A notification will appear confirming that Auto Commit has been enabled.
* **Disable Auto Commit:**
  1. Navigate to the "Config" section in the application settings.
  2. Uncheck the box labeled "Enable Auto Commit."
  3. Click the "Save" button to apply the changes.
  4. A notification will appear confirming that Auto Commit has been disabled.


# Model Selection

papertlab supports both OpenAI and Anthropic models:

1. Click the model dropdown in the top right.
2. Choose from available from OpenAI and Antropics models

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FJtPgaNG6DJAu5RJrb4rO%2Fmodel%20change.png?alt=media&amp;token=238dfd98-40d8-4f6d-a501-3aee986f2f09" alt=""><figcaption></figcaption></figure>


# Terminal Integration

Use the inline terminal by prefixing commands with "/":

1. Type "/" in the chat input.
2. Enter your terminal command (e.g., "/ls -la").
3. Press Enter to execute.

The command output will appear in the chat.

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2F8y8YVHwqE3gNQQ3iF7NB%2Fterminal.png?alt=media&amp;token=9d4b36c1-2122-443a-bc58-ce4a06f1aafe" alt=""><figcaption></figcaption></figure>


# Connecting to LLMs

#### Best Models for PapertLab

PapertLab is optimized to work with several advanced language models that are particularly effective at code editing. These models bring a range of capabilities that enhance the development process:

* **GPT-4o**: Known for its robust understanding of complex code structures, GPT-4o offers advanced editing capabilities that make it a top choice for developers using PapertLab.
* **Claude 3.5 Sonnet**: This model excels in understanding and generating code, providing powerful assistance for intricate coding tasks, making it highly compatible with PapertLab’s features.
* **Claude 3 Opus**: With its deep learning architecture, Claude 3 Opus offers superior code comprehension and editing, making it an ideal partner for PapertLab in handling large and complex projects.

#### Utilizing Free Models with PapertLab

PapertLab also supports several free API providers, allowing users to leverage powerful models without additional costs:

* **Google’s Gemini 1.5 Pro**: This model integrates well with PapertLab, offering capabilities similar to GPT-3.5 in code editing. It’s an excellent choice for developers looking for a cost-effective solution with robust performance.
* **Llama 3 70B on Groq**: For those seeking a free yet powerful alternative, Llama 3 70B provides a level of code editing performance comparable to GPT-3.5, and works seamlessly with PapertLab.
* **Cohere’s Command-R+**: While more basic, Cohere’s Command-R+ model provides a free option for coding assistance. It’s compatible with PapertLab, making it a viable choice for simpler coding tasks or as a starting point for developers.

#### Local Models with PapertLab

PapertLab is also designed to work with local models, offering flexibility for developers who prefer or require local processing:

* **Ollama Integration**: PapertLab supports the use of local models through platforms like Ollama. This allows developers to run code editing tasks locally, providing greater control over their environment and potentially enhancing performance and security.


# OpenAI

To utilize OpenAI’s powerful models with PapertLab, you need to provide your OpenAI API key. You can do this in two ways: by setting the `OPENAI_API_KEY` environment variable or by adding the key directly through the API section of the settings page in PapertLab. Additionally, you can specify the API key via the `--openai-api-key` command line option.

#### Adding API Keys via PapertLab Settings

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FQ26BaaEAU9bzccvdzGxb%2Fapi.png?alt=media&amp;token=860a196c-19d5-4b4d-b770-f273e8898459" alt=""><figcaption></figcaption></figure>

You can also connect PapertLab to OpenAI by adding your API key directly through the PapertLab settings page:

1. **Navigate to the Settings Page**: Open PapertLab and go to the settings page.
2. **Locate the API Section**: In the API section, enter your OpenAI API key in the designated field.
3. **Save Your Changes**: Click "Save" to apply the settings. PapertLab will now be connected to OpenAI using the provided API key.

This method is particularly useful if you prefer managing your keys through the user interface rather than using environment variables or command line options.

PapertLab is optimized to work seamlessly with the most popular OpenAI models, and it has been thoroughly tested and benchmarked to ensure smooth performance:

1. **Installation**: First, ensure that PapertLab is installed on your system.

   ```bash
   python -m pip install papert-lab
   ```
2. **Set the OpenAI API Key**:
   * **Mac/Linux**:

     ```bash
     export OPENAI_API_KEY=<your-api-key>
     ```
   * **Windows**:

     ```cmd
     setx OPENAI_API_KEY <your-api-key>
     ```

     *(Note: After running `setx`, restart your shell for the changes to take effect.)*
3. **Using PapertLab with OpenAI Models**:
   * **Default Model**: By default, PapertLab uses the **GPT-4o** model, which offers advanced capabilities for code editing.

     ```bash
     papertlab
     ```
   * **GPT-4 Turbo (1106)**: If you prefer to use a specific version of GPT-4 Turbo, you can do so by specifying the model.

     ```bash
     papertlab --4-turbo
     ```
   * **GPT-3.5 Turbo**: You can switch to using GPT-3.5 Turbo if needed.

     ```bash
     papertlab --35-turbo
     ```
4. **Listing Available Models**: To see all the models available from OpenAI that PapertLab can connect with, use the following command:

   ```bash
   papertlab --models openai/
   ```
5. **Using Other OpenAI Models**: If you want to use a specific OpenAI model, simply pass the model name to the `--model` option. For example, to use a specific preview version of GPT-4 Turbo, you can run:

   ```bash
   papertlab --model gpt-4-0125-preview
   ```


# Anthropic

To harness the capabilities of Anthropic’s models within PapertLab, you’ll need to provide your Anthropic API key. You can do this by setting the `ANTHROPIC_API_KEY` environment variable, adding the key directly through the API section in the PapertLab settings page, or using the `--anthropic-api-key` command line option.

#### Adding API Keys via PapertLab Settings

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FQ26BaaEAU9bzccvdzGxb%2Fapi.png?alt=media&amp;token=860a196c-19d5-4b4d-b770-f273e8898459" alt=""><figcaption></figcaption></figure>

Alternatively, you can connect PapertLab to Anthropic by entering your API key directly in the PapertLab settings page:

1. **Navigate to the Settings Page**: Open PapertLab and go to the settings page.
2. **Locate the API Section**: In the API section, enter your Anthropic API key in the appropriate field.
3. **Save Your Changes**: Click "Save" to apply the settings. PapertLab will now be configured to use the Anthropic models with your provided API key.

This method is particularly useful if you prefer managing your keys through the user interface instead of using environment variables or command line options.

PapertLab is optimized for smooth interaction with Anthropic’s most popular models. These models have been thoroughly tested and benchmarked to ensure they perform exceptionally well for various tasks:

1. **Installation**: Begin by installing PapertLab on your system if you haven't already.

   ```bash
   python -m pip install papert-lab
   ```
2. **Set the Anthropic API Key**:
   * **Mac/Linux**:

     ```bash
     export ANTHROPIC_API_KEY=<your-api-key>
     ```
   * **Windows**:

     ```cmd
     setx ANTHROPIC_API_KEY <your-api-key>
     ```

     *(Note: After running `setx`, restart your shell for the changes to take effect.)*
3. **Using PapertLab with Anthropic Models**:
   * **Default Model**: PapertLab uses the **Claude 3.5 Sonnet** model by default, which is particularly adept at handling complex tasks.

     ```bash
     papertlab
     ```
   * **Claude 3 Opus**: If you prefer the Claude 3 Opus model, you can easily switch by specifying it with the `--opus` flag.

     ```bash
     papertlab --opus
     ```
4. **Listing Available Models**: To view all the Anthropic models that PapertLab can connect with, use the following command:

   ```bash
   papertlab --models anthropic/
   ```
5. **Using Other Anthropic Models**: If you want to use a specific Anthropic model, pass the model name to the `--model` option. For example, to use a specific version of Opus, you could run:

   ```bash
   papertlab --model claude-3-opus-20240229
   ```


# Cohere&#x20;

Cohere provides free API access to its models, making it an accessible option for those looking to leverage AI in their projects. One of the most effective models for basic coding assistance within PapertLab is Cohere’s **Command-R+** model. To get started, you’ll need to obtain a Cohere API key.

**Adding API Keys via PapertLab Settings**

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FQ26BaaEAU9bzccvdzGxb%2Fapi.png?alt=media&amp;token=860a196c-19d5-4b4d-b770-f273e8898459" alt=""><figcaption></figcaption></figure>

In addition to setting the API key through environment variables, you can conveniently add your Cohere API key directly through the PapertLab settings page:

1. **Open PapertLab and Navigate to Settings**: Start PapertLab and go to the settings page.
2. **Find the API Section**: Locate the API section where you can enter your Cohere API key.
3. **Enter Your API Key**: Input your Cohere API key into the designated field.
4. **Save Your Settings**: After entering the key, click "Save" to apply the changes. PapertLab will now use the Cohere models with the provided API key.

By following these steps, you can quickly integrate Cohere’s Command-R+ model with PapertLab and begin utilizing its capabilities for your coding needs. Whether you prefer setting the API key via the command line or through the user-friendly settings page, PapertLab makes it easy to connect and start working with Cohere’s AI models.

**Steps to Use Command-R+ with PapertLab**

1. **Install PapertLab**: Ensure that you have PapertLab installed on your system. If not, you can install it using pip:

   ```bash
   python -m pip install papert-lab
   ```
2. **Set Your Cohere API Key**:
   * **Mac/Linux**:

     ```bash
     export COHERE_API_KEY=<your-api-key>
     ```
   * **Windows**:

     ```cmd
     setx COHERE_API_KEY <your-api-key>
     ```

     *(Note: After setting the environment variable with `setx`, restart your shell for the changes to take effect.)*
3. **Using PapertLab with the Command-R+ Model**:
   * By default, you can specify the **Command-R+** model when running PapertLab:

     ```bash
     papertlab --model command-r-plus
     ```
4. **Listing Available Cohere Models**: If you want to explore other models provided by Cohere, you can list them with the following command:

   ```bash
   papertlab --models cohere_chat/
   ```


# Gemini

Google currently provides free API access to the **Gemini 1.5 Pro** model, one of the most powerful models available for free. This model offers code editing capabilities comparable to GPT-3.5, making it an excellent choice for use with PapertLab. To get started, you’ll need to obtain a Gemini API key.

**Adding API Keys via PapertLab Settings**

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FQ26BaaEAU9bzccvdzGxb%2Fapi.png?alt=media&amp;token=860a196c-19d5-4b4d-b770-f273e8898459" alt=""><figcaption></figcaption></figure>

In addition to setting the API key via environment variables, you can also add your Gemini API key directly through PapertLab’s settings page for easier management:

1. **Open PapertLab and Go to Settings**: Start PapertLab and navigate to the settings page.
2. **Locate the API Section**: Find the section dedicated to API key management.
3. **Enter Your API Key**: Input your Gemini API key in the provided field.
4. **Save Your Changes**: After entering the key, save your settings. PapertLab will now use the Gemini models with the provided API key.

By following these steps, you can seamlessly integrate the Gemini 1.5 Pro model with PapertLab and take full advantage of its powerful code editing capabilities. Whether you prefer setting up via the command line or using the convenient settings page, PapertLab offers flexibility in how you connect and use Gemini’s AI models.

**Steps to Use Gemini 1.5 Pro with PapertLab**

1. **Install PapertLab**: First, ensure that PapertLab is installed on your system. If it’s not, you can install it easily using pip:

   ```bash
   python -m pip install papert-lab
   ```
2. **Set Your Gemini API Key**:
   * **Mac/Linux**:

     ```bash
     export GEMINI_API_KEY=<your-api-key>
     ```
   * **Windows**:

     ```cmd
     setx GEMINI_API_KEY <your-api-key>
     ```

     *(Note: After using `setx`, restart your shell for the changes to take effect.)*
3. **Using PapertLab with the Gemini 1.5 Pro Model**:
   * To utilize the **Gemini 1.5 Pro** model, specify it when running PapertLab:

     ```bash
     papertlab --model gemini/gemini-1.5-pro-latest
     ```
4. **Listing Available Gemini Models**: To explore other models offered by Gemini, list them with the following command:

   ```bash
   papertlab --models gemini/
   ```


# Groq

Groq currently provides free API access to the models they host. Among these, the **Llama 3 70B** model is particularly effective when used with PapertLab, offering code editing capabilities comparable to GPT-3.5. To get started, you'll need to obtain a Groq API key.

**Adding API Keys via PapertLab Settings**

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FQ26BaaEAU9bzccvdzGxb%2Fapi.png?alt=media&amp;token=860a196c-19d5-4b4d-b770-f273e8898459" alt=""><figcaption></figcaption></figure>

Instead of setting the API key through environment variables, you can also add your Groq API key directly through PapertLab’s settings page:

1. **Open PapertLab and Access Settings**: Start PapertLab and navigate to the settings page.
2. **Find the API Section**: Locate the section dedicated to API key management.
3. **Input Your API Key**: Enter your Groq API key in the designated field.
4. **Save Your Settings**: After entering the key, save your settings. PapertLab will now be configured to use the Groq models with your provided API key.

By following these instructions, you can easily integrate the Llama 3 70B model with PapertLab, leveraging its powerful code editing features. Whether you prefer using the command line or the user-friendly settings page, PapertLab provides the flexibility you need to connect and use Groq’s AI models effectively.

**Steps to Use Llama 3 70B with PapertLab**

1. **Install PapertLab**: Make sure PapertLab is installed on your system. If it’s not already installed, you can do so easily using pip:

   ```bash
   python -m pip install papert-lab
   ```
2. **Set Your Groq API Key**:
   * **Mac/Linux**:

     ```bash
     export GROQ_API_KEY=<your-api-key>
     ```
   * **Windows**:

     ```cmd
     setx GROQ_API_KEY <your-api-key>
     ```

     *(Note: After using `setx`, restart your shell for the changes to take effect.)*
3. **Using PapertLab with the Llama 3 70B Model**:
   * To use the **Llama 3 70B** model, specify it when launching PapertLab:

     ```bash
     papertlab --model groq/llama3-70b-8192
     ```
4. **Listing Available Groq Models**: To view other models offered by Groq, list them with the following command:

   ```bash
   papertlab --models groq/
   ```


# Ollama

PapertLab can seamlessly connect to local Ollama models, providing robust AI-driven coding assistance directly from your machine.

**Adding API Keys via PapertLab Settings**

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FQ26BaaEAU9bzccvdzGxb%2Fapi.png?alt=media&amp;token=860a196c-19d5-4b4d-b770-f273e8898459" alt=""><figcaption></figcaption></figure>

Instead of setting the API base through environment variables, you can also configure your Ollama API directly through PapertLab’s settings page:

1. **Open PapertLab and Access Settings**: Start PapertLab and navigate to the settings page.
2. **Locate the API Section**: Find the section where you can manage API keys.
3. **Input Your API Base**: Enter your Ollama API base in the designated field (e.g., `http://127.0.0.1:11434`).
4. **Save Your Settings**: Once entered, save your settings. PapertLab will now connect to your local Ollama models using the provided API base.

By following these steps, you can effortlessly integrate local Ollama models with PapertLab, taking advantage of powerful code editing capabilities. Whether you choose to set up through the command line or directly via the settings page, PapertLab offers flexibility and ease of use to meet your development needs.<br>

**Steps to Use Ollama Models with PapertLab**

1. **Pull the Ollama Model**: Begin by pulling the model you intend to use:

   ```bash
   ollama pull <model>
   ```
2. **Start the Ollama Server**: Once the model is pulled, start the Ollama server:

   ```bash
   ollama serve
   ```
3. **Install PapertLab**: Ensure PapertLab is installed on your system. If not, install it using pip:

   ```bash
   python -m pip install papert-lab
   ```
4. **Set Your Ollama API Base**:
   * **Mac/Linux**:

     ```bash
     export OLLAMA_API_BASE=http://127.0.0.1:11434
     ```
   * **Windows**:

     ```cmd
     setx OLLAMA_API_BASE http://127.0.0.1:11434
     ```

     *(Note: After using `setx`, restart your shell for the changes to take effect.)*
5. **Using PapertLab with Ollama Models**:
   * To use a specific Ollama model, such as **llama3:70b**, specify it when launching PapertLab:

     ```bash
     papertlab --model ollama/llama3:70b
     ```
6. **Manage Model Warnings**: PapertLab may issue warnings when working with unfamiliar models. Refer to the model warnings section for details.


# Main Options

**Options Overview:**

```
--help
```

Displays a help message outlining all available options and their usage. This is useful if you're unsure about the correct syntax or need a quick reference for what commands are available.\
Aliases:

```
-h
--help
```

**Main Configuration Options:**

```
--openai-api-key OPENAI_API_KEY
```

This option allows you to specify the OpenAI API key directly via the command line. The key is required for authenticating requests to OpenAI's services.

&#x20;If you prefer, you can also set this key using the environment variable `PAPERTLAB_OPENAI_API_KEY`, which allows you to avoid hard-coding sensitive information in your scripts.

```
--anthropic-api-key ANTHROPIC_API_KEY
```

Similar to the OpenAI key, this option lets you provide the Anthropic API key, which is necessary to access Anthropic’s models.&#x20;

The key can be specified on the command line or set as an environment variable `PAPERTLAB_ANTHROPIC_API_KEY` to keep it secure and easily configurable across different environments.

```
--model MODEL
```

This option specifies which AI model you want PapertLab to use for the main chat. Different models can have various capabilities and performance characteristics.&#x20;

By setting this option, you can tailor the behavior of PapertLab to better suit your needs. The model can be specified via the command line or by using the environment variable `PAPERTLAB_MODEL`.

```
--opus
```

If you want to use the `claude-3-opus-20240229` model for your main chat interactions, you can select this option.&#x20;

This model might be optimized for specific types of conversations or performance parameters. You can also set this option using the `PAPERTLAB_OPUS` environment variable to make it your default choice without having to specify it each time.

```
--sonnet
```

This option selects the `claude-3-5-sonnet-20240620` model for your main chat. This model may have different strengths or features compared to others.

&#x20;If you frequently use this model, setting it via the `PAPERTLAB_SONNET` environment variable could save you time.

```
--4
```

This allows you to choose the `gpt-4-0613` model for the main chat. GPT-4 is a powerful language model known for its extensive capabilities in natural language understanding and generation. This model can be selected directly or by setting the `PAPERTLAB_4` environment variable.\
Aliases:

```
--4
-4
```

```
--4o
```

If you prefer the `gpt-4o-2024-08-06` variant for your main chat, use this option. The `gpt-4o` might offer different performance or be better suited to specific tasks. This model can also be set as the default using the `PAPERTLAB_4O` environment variable.

```
--mini
```

This option selects the `gpt-4o-mini` model, which could be a lighter version of the GPT-4 family, offering faster response times or lower resource usage. Ideal for scenarios where efficiency is more critical than the expansive capabilities of the full GPT-4 models. This can be specified via the `PAPERTLAB_MINI` environment variable.

```
--4-turbo
```

The `gpt-4-1106-preview` model can be selected with this option. This variant may be in a preview phase, offering access to the latest features and improvements before they are widely available. You can also set this as your default model using the `PAPERTLAB_4_TURBO` environment variable.

```
--35turbo
```

This option is used to select the `gpt-3.5-turbo` model for the main chat. The `gpt-3.5-turbo` is a streamlined version of GPT-3, optimized for performance. This is a good choice if you need a balance between power and efficiency. You can set this model as your default by using the `PAPERTLAB_35TURBO` environment variable.\
Aliases:

```
--35turbo
--35-turbo
--3
-3
```


# Terminal Args

```
--terminal --dark-mode
```

Use colors suitable for a dark terminal background (default: False)\
Default: False\
Environment variable: `PAPERTLAB_DARK_MODE`

```
--terminal --light-mode
```

Use colors suitable for a light terminal background (default: False)\
Default: False\
Environment variable: `PAPERTLAB_LIGHT_MODE`

```
--terminal --pretty
```

Enable/disable pretty, colorized output (default: True)\
Default: True\
Environment variable: `PAPERTLAB_PRETTY`\
Aliases:

```
--pretty
--no-pretty
```

```
--terminal --stream
```

Enable/disable streaming responses (default: True)\
Default: True\
Environment variable: `PAPERTLAB_STREAM`\
Aliases:

```
--stream
--no-stream
```

```
--terminal --user-input-color VALUE
```

Set the color for user input (default: #00cc00)\
Default: #00cc00\
Environment variable: `PAPERTLAB_USER_INPUT_COLOR`

```
--terminal --tool-output-color VALUE
```

Set the color for tool output (default: None)\
Environment variable: `PAPERTLAB_TOOL_OUTPUT_COLOR`

```
--terminal --tool-error-color VALUE
```

Set the color for tool error messages (default: red)\
Default: #FF2222\
Environment variable: `PAPERTLAB_TOOL_ERROR_COLOR`

```
--terminal --assistant-output-color VALUE
```

Set the color for assistant output (default: #0088ff)\
Default: #0088ff\
Environment variable: `PAPERTLAB_ASSISTANT_OUTPUT_COLOR`

```
--terminal --code-theme VALUE
```

Set the markdown code theme (default: default, other options include monokai, solarized-dark, solarized-light)\
Default: default\
Environment variable: `PAPERTLAB_CODE_THEME`

```
--terminal --show-diffs
```

Show diffs when committing changes (default: False)\
Default: False\
Environment variable: `PAPERTLAB_SHOW_DIFFS`


# Git Settings

```
--git
```

Enable/disable looking for a git repo (default: True)\
Default: True\
Environment variable: `PAPERTLAB_GIT`\
Aliases:

```
--git
--no-git
```

```
--gitignore
```

Enable/disable adding .papertlab\* to .gitignore (default: True)\
Default: True\
Environment variable: `PAPERTLAB_GITIGNORE`\
Aliases:

```
--gitignore
--no-gitignore
```

```
--auto-commits
```

Enable/disable auto commit of LLM changes (default: True)\
Default: True\
Environment variable: `PAPERTLAB_AUTO_COMMITS`\
Aliases:

```
--auto-commits
--no-auto-commits
```

```
--dirty-commits
```

Enable/disable commits when repo is found dirty (default: True)\
Default: True\
Environment variable: `PAPERTLAB_DIRTY_COMMITS`\
Aliases:

```
--dirty-commits
--no-dirty-commits
```

```
--attribute-author
```

Attribute papertlab code changes in the git author name (default: True)\
Default: True\
Environment variable: `PAPERTLAB_ATTRIBUTE_AUTHOR`\
Aliases:

```
--attribute-author
--no-attribute-author
```

```
--attribute-committer
```

Attribute papertlab commits in the git committer name (default: True)\
Default: True\
Environment variable: `PAPERTLAB_ATTRIBUTE_COMMITTER`\
Aliases:

```
--attribute-committer
--no-attribute-committer
```

```
--attribute-commit-message-author
```

Prefix commit messages with ‘papertlab: ‘ if papertlab authored the changes (default: False)\
Default: False\
Environment variable: `PAPERTLAB_ATTRIBUTE_COMMIT_MESSAGE_AUTHOR`\
Aliases:

```
--attribute-commit-message-author
--no-attribute-commit-message-author
```

```
--attribute-commit-message-committer
```

Prefix all commit messages with ‘papertlab: ‘ (default: False)\
Default: False\
Environment variable: `PAPERTLAB_ATTRIBUTE_COMMIT_MESSAGE_COMMITTER`\
Aliases:

```
--attribute-commit-message-committer
--no-attribute-commit-message-committer
```

```
--commit
```

Commit all pending changes with a suitable commit message, then exit\
Default: False\
Environment variable: `PAPERTLAB_COMMIT`

```
--commit-prompt PROMPT
```

Specify a custom prompt for generating commit messages\
Environment variable: `PAPERTLAB_COMMIT_PROMPT`

```
--dry-run
```

Perform a dry run without modifying files (default: False)\
Default: False\
Environment variable: `PAPERTLAB_DRY_RUN`\
Aliases:

```
--dry-run
--no-dry-run
```


# Other settings

1. **Chaning the port number for papertlab GUI**

By default, the papertlab GUI runs on port 5000. However, you can easily change this to a different port if needed. This can be useful if port 5000 is already in use on your system or if you need to run multiple instances of papertlab.

### Using the --port Command-line Option

To change the port number, use the `--port` option when starting papertlab. Here's the syntax:

```
papertlab --port=8000
```

2. **Checking the papertlab Version You can easily check which version of papertlab you're currently using. This is useful when reporting issues, following tutorials, or verifying your installation.**

Using the --version Command-line Option To display the version information, use the `--version` option when running papertlab. Here's the syntax:&#x20;

```
papertlab --version
```

This command will output the current version of papertlab and exit immediately. For example: papertlab version 1.0.8


# File Editing Problems

### Understanding the Issue

Sometimes, the Large Language Model (LLM) may suggest code changes that don't get applied to your local files. You might see error messages like:

* "Failed to apply edit to *filename*"
* Other similar error notifications

This typically occurs when the LLM deviates from the system prompts and attempts to make edits in an unexpected format. While Papertlab strives to ensure LLM conformity and handles "almost" correctly formatted edits, occasional issues may arise.

### Troubleshooting Steps

If you encounter file editing problems, try the following solutions:

#### 1. Use a Capable Model

* Opt for powerful models like GPT-4o, Claude 3.5 Sonnet, or Claude 3 Opus when possible.
* These models are more adept at following system prompt instructions.
* Note that weaker models, especially local ones, are more prone to editing errors.

#### 2. Reduce Distractions

Even with large context windows, irrelevant code or conversations can confuse the model:

* **Limit File Selection**: Add only the files you believe need editing to the chat.
* **Remove Unnecessary Files**: Clear files from the chat session that aren't crucial for the current task.
* **Clear Conversation History**: This helps the LLM focus on the task at hand.

Remember, Papertlab sends the LLM a map of your entire Git repository, ensuring other relevant code is included automatically.

#### 3. Seek Additional Assistance

If problems persist:

1. Check our GitHub issues for similar problems and solutions.
2. If your issue isn't addressed, please file a new issue on our GitHub repository.

By following these steps, you can minimize file editing problems and ensure a smoother experience with Papertlab.


# large\_repos

## Using Papertlab in Large (Mono) Repositories

Papertlab is compatible with repositories of any size. However, it's not optimized for quick performance and response time in very large repositories. Here are some strategies to improve performance:

### papertlabignore

papertlab respects the `.papertlabignore` file in your project root. Files and directories listed in this file will not be shown in the file panel.

Example `.papertlabignore`:

```
node_modules/
*.log
secrets.yml
```

<figure><img src="https://323147515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDxsCSiLtcLEhVsYJxaEU%2Fuploads%2FdG3SHbhrDcSsbqyKPQlA%2Fpapertignore.png?alt=media&amp;token=4e6a38c6-d90e-481c-8efa-a5869d54c803" alt=""><figcaption></figcaption></figure>


# model\_warnings

## Model Warnings

### Unknown Context Window Size and Token Costs

When using Papertlab, you might encounter a warning message like this:

```
Model foobar: Unknown context window size and costs, using sane defaults.
```

#### What This Means

This warning appears when you specify a model that Papertlab isn't familiar with. In such cases:

* Papertlab doesn't know the context window size for the model.
* The token costs for the model are unknown to Papertlab.

#### Default Behavior

When this occurs, Papertlab will:

1. Assume an unlimited context window for the model.
2. Treat the model usage as free (no cost calculation).

#### Impact

In most cases, this warning doesn't significantly affect functionality. Papertlab will continue to operate with these default assumptions.

#### Resolving the Warning

To remove this warning and provide Papertlab with accurate information:

1. Refer to our documentation on configuring advanced model settings.
2. Follow the instructions to specify the correct context window size and token costs for your model.

By providing this information, you can ensure Papertlab operates with accurate parameters for your chosen model.


# token\_limits

Every Large Language Model (LLM) has constraints on the number of tokens it can process per request:

* The model's **context window** limits the total tokens of *input and output* it can process.
* Each model has a limit on how many **output tokens** it can produce.

### Error Reporting

Papertlab will report an error if a model indicates it has exceeded a token limit. The error message will include suggested actions to avoid hitting these limits. Here's an example:

```
Model gpt-3.5-turbo has hit a token limit!

Input tokens: 768 of 16385
Output tokens: 4096 of 4096 -- exceeded output limit!
Total tokens: 4864 of 16385

To reduce output tokens:
- Ask for smaller changes in each request.
- Break your code into smaller source files.
- Try using a stronger model like gpt-4o or opus that can return diffs.
```

### Input Tokens & Context Window Size

#### The Problem

The most common issue is sending too much data to a model, overflowing its context window. This can happen if:

* The input is too large
* The combined input and output are too large

#### Solutions

1. Reduce input tokens by removing files from the chat
2. Only add files that Papertlab needs to *edit* for your request
3. Use stronger models like GPT-4o and Opus, which have larger context windows

#### Additional Tips

* Break your code into smaller source files

### Output Token Limits

#### The Problem

Most models have small output limits, often around 4k tokens. Large changes affecting a lot of code may hit these limits.

#### Solutions

1. Request smaller changes in each interaction
2. Break your code into smaller source files
3. Use strong models like gpt-4o, sonnet, or opus that can return diffs

### Other Causes

Token limit errors might also be caused by:

* Non-compliant API proxy servers
* Bugs in the API server hosting a local model

#### Troubleshooting

* Try using Papertlab without an API proxy server
* Connect directly with recommended cloud APIs

If you encounter persistent token limit problems, try these steps to resolve the issue.


