Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test New LLMs (Llama2, CodeLlama, etc.) on Aider? #1

Open
wants to merge 101 commits into
base: main
Choose a base branch
from

Conversation

krrishdholakia
Copy link

Hi @cristianoc,

Notice you forked Aider. if you're trying to test other LLMs (codellama, wizardcoder, etc.) with it, I just wrote a 1-click proxy to translate openai calls to huggingface, anthropic, togetherai, etc. api calls.

code

$ pip install litellm

$ litellm --model huggingface/bigcode/starcoder

#INFO:     Uvicorn running on http://0.0.0.0:8000

$ aider --openai-api-base http://0.0.0.0:8000

I'd love to know if this solves a problem for you

… `Coder`.

# Aider chat conversation:

USER: add --voice-language switch with default "en" and pass it into `Coder`

ASSISTANT: To add the `--voice-language` switch, we need to modify the `aider/main.py` file. We will add the argument in the `core_group` section of the argument parser. Then, we will pass this argument to the `Coder` class.

Here are the changes:

```python
aider/main.py
<<<<<<< HEAD
    core_group.add_argument(
        "-3",
        action="store_const",
        dest="model",
        const=models.GPT35_16k.name,
        help=f"Use {models.GPT35_16k.name} model for the main chat (gpt-4 is better)",
    )
=======
    core_group.add_argument(
        "-3",
        action="store_const",
        dest="model",
        const=models.GPT35_16k.name,
        help=f"Use {models.GPT35_16k.name} model for the main chat (gpt-4 is better)",
    )
    core_group.add_argument(
        "--voice-language",
        metavar="VOICE_LANGUAGE",
        default="en",
        help="Specify the language for voice (default: en)",
    )
>>>>>>> updated
```

```python
aider/main.py
<<<<<<< HEAD
    try:
        coder = Coder.create(
            main_model,
            args.edit_format,
            io,
            ##
            fnames=fnames,
            git_dname=git_dname,
            pretty=args.pretty,
            show_diffs=args.show_diffs,
            auto_commits=args.auto_commits,
            dirty_commits=args.dirty_commits,
            dry_run=args.dry_run,
            map_tokens=args.map_tokens,
            verbose=args.verbose,
            assistant_output_color=args.assistant_output_color,
            code_theme=args.code_theme,
            stream=args.stream,
            use_git=args.git,
        )
    except ValueError as err:
        io.tool_error(str(err))
        return 1
=======
    try:
        coder = Coder.create(
            main_model,
            args.edit_format,
            io,
            ##
            fnames=fnames,
            git_dname=git_dname,
            pretty=args.pretty,
            show_diffs=args.show_diffs,
            auto_commits=args.auto_commits,
            dirty_commits=args.dirty_commits,
            dry_run=args.dry_run,
            map_tokens=args.map_tokens,
            verbose=args.verbose,
            assistant_output_color=args.assistant_output_color,
            code_theme=args.code_theme,
            stream=args.stream,
            use_git=args.git,
            voice_language=args.voice_language,
        )
    except ValueError as err:
        io.tool_error(str(err))
        return 1
>>>>>>> updated
```

Please note that the `Coder` class and its subclasses (`EditBlockCoder`, `EditBlockFunctionCoder`, `SingleWholeFileFunctionCoder`, `WholeFileCoder`, `WholeFileFunctionCoder`) need to be updated to accept and use the `voice_language` argument. These changes are not shown here as the `Coder` class and its subclasses are not provided in the *read-write* files.
# Aider chat conversation:

USER: accept voice_language param in __ini__, pass to Commands

ASSISTANT: To implement this change, we need to modify the following files:

1. `aider/coders/base_coder.py`: We need to modify the `__init__` method of the `Coder` class to accept a new parameter `voice_language`. We also need to pass this new parameter to the `Commands` class.

Here are the changes:

```python
aider/coders/base_coder.py
<<<<<<< HEAD
    def __init__(
        self,
        main_model,
        io,
        fnames=None,
        git_dname=None,
        pretty=True,
        show_diffs=False,
        auto_commits=True,
        dirty_commits=True,
        dry_run=False,
        map_tokens=1024,
        verbose=False,
        assistant_output_color="blue",
        code_theme="default",
        stream=True,
        use_git=True,
    ):
=======
    def __init__(
        self,
        main_model,
        io,
        fnames=None,
        git_dname=None,
        pretty=True,
        show_diffs=False,
        auto_commits=True,
        dirty_commits=True,
        dry_run=False,
        map_tokens=1024,
        verbose=False,
        assistant_output_color="blue",
        code_theme="default",
        stream=True,
        use_git=True,
        voice_language=None,
    ):
>>>>>>> updated
```

```python
aider/coders/base_coder.py
<<<<<<< HEAD
        self.commands = Commands(self.io, self)
=======
        self.commands = Commands(self.io, self, voice_language)
>>>>>>> updated
```

Please confirm these changes.
…<a>` tag.

# Aider chat conversation:

USER: have the js add the mdurl as an href on the <a>

ASSISTANT: To add the `mdurl` as an `href` on the `<a>` tag, we need to modify the `share/index.md` file.

Here are the steps:

1. Find the `<a>` tag that we want to modify.
2. Add a JavaScript code snippet that will get the `mdurl` from the URL parameters and set it as the `href` of the `<a>` tag.

Here is the *edit block* for the change:

<source>markdown
share/index.md
<<<<<<< HEAD
A user has shared the following transcript of a pair programming chat session
created using <a href="https://aider.chat">aider</a>.
=======
A user has shared the following
^C KeyboardInterrupt

USER: have the js add the mdurl as an href on the <a>

ASSISTANT: To add the `mdurl` as an `href` on the `<a>` tag, we need to modify the `share/index.md` file.

Here are the steps:

1. Find the `<a>` tag that we want to modify.
2. Add a JavaScript code snippet that will get the `mdurl` from the URL parameters and set it as the `href` of the `<a>` tag.

Here is the *edit block* for the change:

<source>markdown
share/index.md
<<<<<<< HEAD
The transcript is based on <a id="mdurl">this chat transcript data</a>.
=======
The transcript is based on <a id="mdurl" href="">this chat transcript data</a>.
>>>>>>> updated
</source>

<source>javascript
share/index.md
<<<<<<< HEAD
    var conv = urlParams.get('mdurl');
    if (!conv) {
        return;
    }
=======
    var conv = urlParams.get('mdurl');
    if (!conv) {
        return;
    }
    document.getElementById('mdurl').href = conv;
>>>>>>> updated
</source>
# Aider chat conversation:

USER: Add python_requires='>=3.8'

ASSISTANT: To add the `python_requires='>=3.8'` to the `setup
^C KeyboardInterrupt

USER: Add python_requires='>=3.9'

ASSISTANT: To add the `python_requires='>=3.9'` to the `setup.py` file, we need to modify the `setup()` function call to include this new argument.

Here is the *edit block* for this change:

```python
setup.py
<<<<<<< HEAD
setup(
    name="aider-chat",
    version=__version__,
    packages=find_packages(),
    include_package_data=True,
    install_requires=requirements,
    entry_points={
        "console_scripts": [
            "aider = aider.main:main",
        ],
    },
    description="aider is GPT powered coding in your terminal",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/paul-gauthier/aider",
)
=======
setup(
    name="aider-chat",
    version=__version__,
    packages=find_packages(),
    include_package_data=True,
    install_requires=requirements,
    python_requires='>=3.9',
    entry_points={
        "console_scripts": [
            "aider = aider.main:main",
        ],
    },
    description="aider is GPT powered coding in your terminal",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/paul-gauthier/aider",
)
>>>>>>> updated
```
This change ensures that the package will not be installed on Python versions lower than 3.9.
JV and others added 30 commits August 23, 2023 14:39
…is` instead of `==` in `aider/history.py`, `aider/models/__init__.py`, and `aider/models/openrouter.py`.

# Aider chat conversation:

USER: I ran this command:

 pre-commit run --all-files

And got this output:

isort....................................................................Passed
black....................................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

aider/history.py:4:1: F401 'tiktoken' imported but unused
import tiktoken
^
aider/models/__init__.py:2:1: F401 '.openai.OpenAIModel' imported but unused
from .openai import OpenAIModel
^
aider/models/__init__.py:3:1: F401 '.openrouter.OpenRouterModel' imported but unused
from .openrouter import OpenRouterModel
^
aider/models/openrouter.py:26:33: E711 comparison to None should be 'if cond is None:'
        if cached_model_details == None:
                                ^

ASSISTANT: It seems like there are some unused imports and a comparison to None that is not following the Pythonic way. To fix these issues, we need to modify the following files:

1. `aider/history.py`
2. `aider/models/__init__.py`
3. `aider/models/openrouter.py`

Please add these files to the chat so I can propose the necessary changes.

USER: I added these *read-write* files: aider/history.py, aider/models/openrouter.py, aider/models/__init__.py

ASSISTANT: Great! Now, let's make the necessary changes to these files.

First, in `aider/history.py`, we need to remove the unused import `tiktoken`.

```python
aider/history.py
<<<<<<< HEAD
import tiktoken
=======
>>>>>>> updated
```

Next, in `aider/models/__init__.py`, we need to remove the unused imports `OpenAIModel` and `OpenRouterModel`.

```python
aider/models/__init__.py
<<<<<<< HEAD
from .openai import OpenAIModel
from .openrouter import OpenRouterModel
=======
>>>>>>> updated
```

Finally, in `aider/models/openrouter.py`, we need to change the comparison to None to use `is` instead of `==`.

```python
aider/models/openrouter.py
<<<<<<< HEAD
        if cached_model_details == None:
=======
        if cached_model_details is None:
>>>>>>> updated
```

These changes should resolve the issues reported by the `flake8` linter.
…usage

only show token costs if usage exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants