Commit graph

203 commits

Author SHA1 Message Date
Paul Gauthier (aider)
bd9e6d7f58 refactor: Move format_tokens function to utils.py 2024-08-26 15:46:26 -07:00
Paul Gauthier (aider)
547d7533c2 fix: Remove unused import of 'json' in 'aider/utils.py' 2024-08-25 09:39:58 -07:00
Paul Gauthier
b67914d74e fix: Improve model info caching and fallback logic 2024-08-25 09:39:26 -07:00
Paul Gauthier
b7a9925cea fix: Remove unused import 'requests' from 'aider/models.py' 2024-08-25 08:22:20 -07:00
Paul Gauthier (aider)
fa7d92a117 fix: Move import statement to top of file 2024-08-25 07:55:22 -07:00
Paul Gauthier (aider)
2570a4d193 style: Format code with black 2024-08-25 07:55:08 -07:00
Paul Gauthier (aider)
7f1f2cb7ba feat: Add safe_read_json and safe_write_json functions to aider/utils.py 2024-08-25 07:55:02 -07:00
Paul Gauthier (aider)
5e93dcf2cc feat: Use safe_abs_path in find_common_root function 2024-08-22 13:57:40 -07:00
Paul Gauthier (aider)
1a50a8cc5e fix: remove unnecessary import in aider/utils.py 2024-08-22 13:55:52 -07:00
Paul Gauthier (aider)
880ade4f12 style: Run linter 2024-08-22 13:55:36 -07:00
Paul Gauthier (aider)
221cde0fed refactor: Move find_common_root into aider/utils.py and update Coder class to use it 2024-08-22 13:55:32 -07:00
Paul Gauthier
9fb3a6f8e1 fix: Update string formatting in confirm_ask calls 2024-08-21 05:38:33 -07:00
Paul Gauthier
ba746dd211 fix: Improve confirm dialog messages 2024-08-21 05:38:13 -07:00
Paul Gauthier (aider)
0ec7f8c0c4 feat: add Python version check for TemporaryDirectory 2024-08-20 08:18:38 -07:00
Paul Gauthier
4db6e28118 ignore_cleanup_errors 2024-08-20 08:10:32 -07:00
Paul Gauthier (aider)
45d85b1419 fix: Ignore recursion errors in cleanup method 2024-08-20 08:06:28 -07:00
Paul Gauthier
cb24f8c6d4 attempt to fix windows tests in CI 2024-08-12 14:09:52 -07:00
Paul Gauthier
5bf36002ec Try and use a normalized dirname to avoid windows test issues in CI 2024-08-12 11:18:15 -07:00
Paul Gauthier (aider)
1c2bd55caf feat: Enhance format_messages to display all content entries 2024-08-09 15:57:33 -03:00
Paul Gauthier (aider)
fd43cd401d feat: Use the Spinner instead of the inlined custom spinner 2024-08-05 19:33:57 -03:00
Paul Gauthier
c67d10749c fix: Remove unused spinner method from InputOutput class 2024-08-05 19:31:54 -03:00
Paul Gauthier
1aaa8365d2 more debug if pip installs fail 2024-07-31 09:52:41 -03:00
Paul Gauthier
dadfb464c4 sssh 2024-07-17 14:38:54 +01:00
Paul Gauthier
4fbe3d295a added [playwright] extra 2024-07-14 19:34:48 +01:00
Paul Gauthier (aider)
bc1369c480 Updated the spinner to update 5 times per second. 2024-07-14 18:48:31 +01:00
Paul Gauthier
6b56a31afc Reduced the maximum line length for the installation progress output to 10 characters. 2024-07-14 18:48:29 +01:00
Paul Gauthier (aider)
2affb111ad Read character by character and update the spinner every newline or every 100 characters received in the run_install function. 2024-07-14 18:46:54 +01:00
Paul Gauthier
9ed0e33b9f refactor help install and add to test setup 2024-07-14 17:49:33 +01:00
Paul Gauthier
76dad84285 added [browser] extra; refac the pip install utils 2024-07-14 17:22:17 +01:00
Paul Gauthier
6c38306eab Automatically install the new aider version 2024-07-13 07:47:07 +01:00
Paul Gauthier
6c2a168327 Added a new function run_install_with_spinner to handle the pip installation process with a spinner. 2024-07-12 17:46:39 +01:00
Paul Gauthier (aider)
af8dff8714 Replaced the simple ASCII spinner characters with a more visually appealing set of Unicode braille characters. 2024-07-12 17:43:58 +01:00
Paul Gauthier (aider)
cbf0fd881c Implemented a simple text spinner to show progress during pip installation. 2024-07-12 17:43:15 +01:00
Paul Gauthier
0d7746c6d7 Improved the pip_install function to handle installation output more gracefully, including printing a simple text spinner during the installation process. 2024-07-12 17:43:14 +01:00
Paul Gauthier (aider)
edf2b7fc13 Captured pip install output line by line, printing each line with a carriage return to overwrite, and displaying full output on failure. 2024-07-12 17:36:36 +01:00
Paul Gauthier
504a72b5cb handle failed install of hf-embed 2024-07-10 17:35:13 +01:00
Paul Gauthier
f688c18b65 offer to install aider[hf] 2024-07-10 16:20:06 +01:00
John-Mason P. Shackelford
dd6a7964b6
tempdirs in test_main now cleanup without windows errors 2024-06-18 11:57:53 -04:00
Daniel Vainsencher
abf8d5e60d aider: Refactored format_messages to use a new function format_content for line-by-line formatting.
# Aider chat conversation:

USER: Now refactor format_messages: extract a function that takes a role and content (where content is a string), and returns the line by line formatted string.

ASSISTANT: To refactor `format_messages`, we will:

1. Create a new function `format_content` that takes a role and content (where content is a string) and returns the line-by-line formatted string.
2. Update `format_messages` to use `format_content`.

Here are the *SEARCH/REPLACE* blocks:

aider/utils.py
```python
<<<<<<< SEARCH
def format_messages(messages, title=None):
=======
def format_content(role, content):
    formatted_lines = []
    for line in content.splitlines():
        formatted_lines.append(f"{role} {line}")
    return "\n".join(formatted_lines)

>>>>>>> REPLACE
```

aider/utils.py
```python
<<<<<<< SEARCH
        elif isinstance(content, str):  # Handle string content
            for line in content.splitlines():
                output.append(f"{role} {line}")
=======
        elif isinstance(content, str):  # Handle string content
            output.append(format_content(role, content))
>>>>>>> REPLACE
```

USER:
# Fix any errors below, if possible.

## Running: flake8 --select=E9,F821,F823,F831,F406,F407,F701,F702,F704,F706 --show-source --isolated aider/utils.py

aider/utils.py:94:8: F821 undefined name 'title'
    if title:
       ^
aider/utils.py:95:26: F821 undefined name 'title'
        output.append(f"{title.upper()} {'*' * 50}")
                         ^
aider/utils.py:97:16: F821 undefined name 'messages'
    for msg in messages:
               ^
aider/utils.py:115:24: F821 undefined name 'format_messages'
    formatted_output = format_messages(messages, title)
                       ^

## See relevant lines below marked with █.

aider/utils.py:
...⋮...
 87│def format_content(role, content):
 88│    formatted_lines = []
...⋮...
 91│    return "\n".join(formatted_lines)
 92│
 93│    output = []
 94█    if title:
 95█        output.append(f"{title.upper()} {'*' * 50}")
 96│
 97█    for msg in messages:
 98│        output.append("")
 99│        role = msg["role"].upper()
100│        content = msg.get("content")
...⋮...
112│
113│
114│def show_messages(messages, title=None, functions=None):
115█    formatted_output = format_messages(messages, title)
116│    print(formatted_output)
117│
118│    if functions:
...⋮...

ASSISTANT: To fix the errors, we need to ensure that the `format_messages` function is properly defined and that the misplaced code is correctly organized. Here are the corrected *SEARCH/REPLACE* blocks:

aider/utils.py
```python
<<<<<<< SEARCH
    return "\n".join(formatted_lines)

    output = []
    if title:
        output.append(f"{title.upper()} {'*' * 50}")

    for msg in messages:
        output.append("")
        role = msg["role"].upper()
        content = msg.get("content")
        if isinstance(content, list):  # Handle list content (e.g., image messages)
            for item in content:
                if isinstance(item, dict) and "image_url" in item:
                    output.append(f"{role} Image URL: {item['image_url']['url']}")
        elif isinstance(content, str):  # Handle string content
            output.append(format_content(role, content))
        content = msg.get("function_call")
        if content:
            output.append(f"{role} {content}")

    return "\n".join(output)
=======
    return "\n".join(formatted_lines)

def format_messages(messages, title=None):
    output = []
    if title:
        output.append(f"{title.upper()} {'*' * 50}")

    for msg in messages:
        output.append("")
        role = msg["role"].upper()
        content = msg.get("content")
        if isinstance(content, list):  # Handle list content (e.g., image messages)
            for item in content:
                if isinstance(item, dict) and "image_url" in item:
                    output.append(f"{role} Image URL: {item['image_url']['url']}")
        elif isinstance(content, str):  # Handle string content
            output.append(format_content(role, content))
        content = msg.get("function_call")
        if content:
            output.append(f"{role} {content}")

    return "\n".join(output)
>>>>>>> REPLACE
```
2024-06-07 09:39:03 -04:00
Daniel Vainsencher
a0b279f105 Refactored format_messages to use format_content for string content handling. 2024-06-07 09:39:03 -04:00
Daniel Vainsencher
69c27d6cd1 aider: Refactored show_messages to call format_messages for formatting title and messages.
# Aider chat conversation:

USER: Refactor show_messages in utils, so that the formatting of title and messages is done in a separate function which returns a string. show_messages should call it and print its output.

ASSISTANT: To refactor the `show_messages` function, we will:

1. Create a new function `format_messages` that formats the title and messages and returns a string.
2. Update `show_messages` to call `format_messages` and print its output.

Here are the *SEARCH/REPLACE* blocks:

aider/utils.py
```python
<<<<<<< SEARCH
def show_messages(messages, title=None, functions=None):
    if title:
        print(title.upper(), "*" * 50)

    for msg in messages:
        print()
        role = msg["role"].upper()
        content = msg.get("content")
        if isinstance(content, list):  # Handle list content (e.g., image messages)
            for item in content:
                if isinstance(item, dict) and "image_url" in item:
                    print(role, "Image URL:", item["image_url"]["url"])
        elif isinstance(content, str):  # Handle string content
            for line in content.splitlines():
                print(role, line)
        content = msg.get("function_call")
        if content:
            print(role, content)

    if functions:
        dump(functions)
=======
def format_messages(messages, title=None):
    output = []
    if title:
        output.append(f"{title.upper()} {'*' * 50}")

    for msg in messages:
        output.append("")
        role = msg["role"].upper()
        content = msg.get("content")
        if isinstance(content, list):  # Handle list content (e.g., image messages)
            for item in content:
                if isinstance(item, dict) and "image_url" in item:
                    output.append(f"{role} Image URL: {item['image_url']['url']}")
        elif isinstance(content, str):  # Handle string content
            for line in content.splitlines():
                output.append(f"{role} {line}")
        content = msg.get("function_call")
        if content:
            output.append(f"{role} {content}")

    return "\n".join(output)

def show_messages(messages, title=None, functions=None):
    formatted_output = format_messages(messages, title)
    print(formatted_output)

    if functions:
        dump(functions)
>>>>>>> REPLACE
```
2024-06-07 09:39:03 -04:00
Paul Gauthier
478b5c8e7c improved utils.split_chat_history_markdown 2024-05-11 08:06:16 -07:00
Paul Gauthier
602a0c7c31 refac utils.split_chat_history_markdown 2024-05-11 07:52:06 -07:00
Paul Gauthier
7fd3b8aeee Tell the AI we are switching code bases 2024-04-30 20:51:24 -07:00
Paul Gauthier
0da1b59901 Fixed up images in chat 2024-04-18 14:39:32 -07:00
Paul Gauthier
c770fc4380 cleaned up client refs 2024-04-17 15:47:07 -07:00
Paul Gauthier
5b78d929a6 Roughly working scraper 2024-02-08 11:44:55 -08:00
Paul Gauthier
1758937042 wip 2024-02-08 07:18:39 -08:00
Joshua Vial
179b648864 merging from upstream main 2023-12-19 22:04:39 +13:00
Paul Gauthier
7113a30271 unified diffs 2023-12-17 12:54:34 -08:00