Commit graph

2629 commits

Author SHA1 Message Date
Paul Gauthier
68f043bd96 copy 2023-08-07 11:30:22 -03:00
Paul Gauthier
0f682570a4 aider: Fix the issue with forming the raw URL for a non-raw GitHub gist by including the username in the URL.
# Aider chat conversation:

USER: if the mdurl is a non-raw github gist like this `https://gist.github.com/paul-gauthier/2a4ac695b77f6374c923b0b165a6872b` pull out the h
ash and turn into a raw url like this: `4fd2ac290d
64100e51206fb6874e9ac20644fcd`. Right now it's not including the username (paul-gauthier) portion in the raw url

ASSISTANT: To fix this issue, we need to modify the JavaScript code in the `share/index.md` file. The current code is not correctly forming the raw URL for a non-raw GitHub gist. It's missing the username in the raw URL.

Here is the step-by-step plan:

1. Modify the regular expression to capture the username and the gist hash.
2. Update the raw URL formation to include the captured username.

Here is the *edit block* for the change:

```markdown
share/index.md
<<<<<<< ORIGINAL
    var gistRegex = /^https:\/\/gist\.github\.com\/[^\/]+\/([a-f0-9]+)$/;
    var match = gistRegex.exec(conv);
    if (match) {
        // If it is, convert it into a raw URL
        conv = 'https://gist.githubusercontent.com/' + match[1] + '/raw';
    }
=======
    var gistRegex = /^https:\/\/gist\.github\.com\/([^\/]+)\/([a-f0-9]+)$/;
    var match = gistRegex.exec(conv);
    if (match) {
        // If it is, convert it into a raw URL
        conv = 'https://gist.githubusercontent.com/' + match[1] + '/' + match[2] + '/raw';
    }
>>>>>>> UPDATED
```

This change will correctly form the raw URL for a non-raw GitHub gist by including the username in the URL.
2023-08-07 11:16:56 -03:00
Paul Gauthier
8e1a1f5886 aider: Add condition to convert non-raw GitHub gist URLs into raw URLs.
# Aider chat conversation:

USER: if the mdurl is a non-raw github gist like this `https://gist.github.com/paul-gauthier/2a4ac695b77f6374c923b0b165a6872b` pull out the hash and turn into a raw url like this: `4fd2ac290d`

ASSISTANT: To implement this change, we need to modify the `share/index.md` file. We will add a condition to check if the `mdurl` parameter is a non-raw GitHub gist URL. If it is, we will extract the gist ID and convert it into a raw URL.

Here is the proposed change:

```markdown
share/index.md
<<<<<<< ORIGINAL
var conv = urlParams.get('mdurl');
if (!conv) {
    return;
}
fetch(conv)
=======
var conv = urlParams.get('mdurl');
if (!conv) {
    return;
}
// Check if the URL is a non-raw GitHub gist
var gistRegex = /^https:\/\/gist\.github\.com\/[^\/]+\/([a-f0-9]+)$/;
var match = gistRegex.exec(conv);
if (match) {
    // If it is, convert it into a raw URL
    conv = 'https://gist.githubusercontent.com/' + match[1] + '/raw';
}
fetch(conv)
>>>>>>> UPDATED
```

This change adds a regular expression to match non-raw GitHub gist URLs. If the `mdurl` parameter matches this pattern, the gist ID is extracted and used to construct a raw URL. The fetch operation then uses this raw URL instead of the original URL.
2023-08-07 11:12:45 -03:00
Paul Gauthier
7aed0438fe aider: If the fetch fails, skip the rest.
# Aider chat conversation:

USER: if the fetch fails, skip the rest

ASSISTANT: To handle fetch failures, we need to modify the `share/index.md` file. We will add a `.catch` block to the fetch promise chain to handle any errors that occur during the fetch operation.

Here is the proposed change:

```markdown
share/index.md
<<<<<<< ORIGINAL
fetch(conv)
.then(response => response.text())
.then(markdown => {
    // Ensure every line that starts with '>' ends with exactly 2 spaces
    markdown = markdown.split('\n').map(function(line) {
        if (line.startsWith('>')) {
            return line.trimEnd() + '  ';
        }
        return line;
    }).join('\n');
    var html = marked.parse(markdown);
    var divElement = document.querySelector('.chat-transcript');
    divElement.innerHTML = html;
});
=======
fetch(conv)
.then(response => response.text())
.then(markdown => {
    // Ensure every line that starts with '>' ends with exactly 2 spaces
    markdown = markdown.split('\n').map(function(line) {
        if (line.startsWith('>')) {
            return line.trimEnd() + '  ';
        }
        return line;
    }).join('\n');
    var html = marked.parse(markdown);
    var divElement = document.querySelector('.chat-transcript');
    divElement.innerHTML = html;
})
.catch(error => {
    console.error('Error fetching markdown:', error);
});
>>>>>>> UPDATED
```

This change adds a `.catch` block to the fetch promise chain. If an error occurs during the fetch operation, the error will be logged to the console and the rest of the script will be skipped.
2023-08-07 11:11:02 -03:00
Paul Gauthier
c5d80e9f7a aider: Check if there is a mdurl param and skip the rest if not.
# Aider chat conversation:

USER: check to make sure there is a mdurl param, skip the rest if not

ASSISTANT: To implement this change, we need to modify the `share/index.md` file. We will add a condition to check if the `mdurl` parameter exists before proceeding with the rest of the script.

Here is the proposed change:

```markdown
share/index.md
<<<<<<< ORIGINAL
window.onload = function() {
    var urlParams = new URLSearchParams(window.location.search);
    var conv = urlParams.get('mdurl');
    fetch(conv)
=======
window.onload = function() {
    var urlParams = new URLSearchParams(window.location.search);
    var conv = urlParams.get('mdurl');
    if (!conv) {
        return;
    }
    fetch(conv)
>>>>>>> UPDATED
```

This change checks if `conv` (which holds the value of the `mdurl` parameter) is not present. If it's not, the function returns immediately, skipping the rest of the script.
2023-08-07 11:10:28 -03:00
Paul Gauthier
49b1b228bd aider: Add script tag to load marked.min.js from CDN.
# Aider chat conversation:

USER: also load https://cdn.jsdelivr.net/npm/marked/marked.min.js

ASSISTANT: To load the `marked.min.js` library from the CDN, we need to add a script tag in the `index.md` file. Here is the change:

```markdown
share/index.md
<<<<<<< ORIGINAL
<script>
window.onload = function() {
=======
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script>
window.onload = function() {
>>>>>>> UPDATED
```

This change adds a new script tag before the existing script tag. The new script tag loads the `marked.min.js` library from the CDN. The existing script tag remains unchanged.
2023-08-07 11:06:35 -03:00
Paul Gauthier
4f8627e81f Add script to fetch and display a shared aider chat transcript. 2023-08-07 11:06:14 -03:00
Paul Gauthier
03ac5202dd Handle a pending summarization 2023-08-07 08:33:06 -03:00
Paul Gauthier
fcce0c2c39 copy 2023-08-04 07:40:29 -03:00
Paul Gauthier
0328e0b4c1 copy 2023-08-04 07:27:43 -03:00
Paul Gauthier
973884d8a1 Updated HISTORY 2023-08-04 06:40:00 -03:00
Paul Gauthier
c271bfd932 Fixed /commit after repo refactor, added test coverage 2023-08-04 06:39:04 -03:00
Paul Gauthier
5fe0652099 copy 2023-08-03 14:27:15 -03:00
Paul Gauthier
9dfc23c660 copy 2023-08-03 12:43:08 -03:00
Paul Gauthier
3ef16827fc show a progress bar if there are on tags/idents caches 2023-08-03 12:07:53 -03:00
Paul Gauthier
9ef730fd97 copy 2023-08-03 11:48:24 -03:00
Paul Gauthier
1af38e943d copy 2023-08-03 11:45:51 -03:00
Paul Gauthier
c24c9d33a5 Fixed comment in -dev bump 2023-08-02 16:23:34 -03:00
Paul Gauthier
f15b8c610b set version to 0.11.0-dev 2023-08-02 16:22:00 -03:00
Paul Gauthier
ce27820e9a version bump to 0.11.0 2023-08-02 16:21:39 -03:00
Paul Gauthier
63acc7e999 Updated HISTORY 2023-08-02 16:21:07 -03:00
Paul Gauthier
4829d7ed0c Updated HISTORY 2023-08-02 13:17:26 -03:00
Paul Gauthier
1858f0504b Strip asterisks from filenames suggested by GPT-3.5 #157 #168 2023-08-02 06:58:59 -03:00
Paul Gauthier
f24c04320e copy 2023-08-01 09:35:28 -03:00
Paul Gauthier
d5a7aac560 include token/cost in log 2023-07-28 11:33:37 -03:00
Paul Gauthier
f5dd19a04f Updated HISTORY 2023-07-28 09:25:20 -03:00
paul-gauthier
4207be9aa1
Merge pull request #144 from paul-gauthier/chat-history
Automatically summarize earlier parts of the chat history
2023-07-28 09:23:57 -03:00
Paul Gauthier
80d5c0b75c use 3.5 for summaries 2023-07-27 22:54:26 -03:00
Paul Gauthier
d1d498bb24 cleanup 2023-07-27 22:34:41 -03:00
Paul Gauthier
16dea76691 Merge branch 'main' into chat-history 2023-07-27 22:32:33 -03:00
Paul Gauthier
832259b55b Bugfix reference to self.get_tracked_files, plus test coverage 2023-07-27 06:55:06 -03:00
Paul Gauthier
c6f99c9b66 Updated discord link 2023-07-27 06:47:47 -03:00
Paul Gauthier
ecd37b1ad5 prettier cost output in /tokens 2023-07-26 17:43:16 -03:00
Paul Gauthier
2094b3176b aider: Adjusted the calculation of the cost in the cmd_tokens method to account for the prices in Model being per 1k tokens.
# Aider chat conversation:

USER: the prices in `Model` are per 1k tokens

ASSISTANT: I see, the prices in the `Model` class are per 1k tokens. Therefore, we need to adjust the calculation of the cost in the `cmd_tokens` method in the `Commands` class in the `aider/commands.py` file.

We will divide the `completion_price` by 1000 before multiplying it with the token count to get the cost.

Here are the changes:

<source>python
aider/commands.py
<<<<<<< ORIGINAL
        total = 0
        total_cost = 0.0
        for tk, msg, tip in res:
            total += tk
            cost = tk * self.coder.main_model.completion_price
            total_cost += cost
            msg = msg.ljust(col_width)
            self.io.tool_output(f"{fmt(tk)} {msg} {tip} (cost: ${cost:.2f})")

        self.io.tool_output("=" * width)
        self.io.tool_output(f"{fmt(total)} tokens total (cost: ${total_cost:.2f})")
=======
        total = 0
        total_cost = 0.0
        for tk, msg, tip in res:
            total += tk
            cost = tk * (self.coder.main_model.completion_price / 1000)
            total_cost += cost
            msg = msg.ljust(col_width)
            self.io.tool_output(f"{fmt(tk)} {msg} {tip} (cost: ${cost:.2f})")

        self.io.tool_output("=" * width)
        self.io.tool_output(f"{fmt(total)} tokens total (cost: ${total_cost:.2f})")
>>>>>>> UPDATED
</source>
2023-07-26 17:35:42 -03:00
Paul Gauthier
35ccfac3fd aider: Updated the output of /tokens to include the total cost.
# Aider chat conversation:

USER: udpate the output of /tokens to include the total $ cost

ASSISTANT: To include the total cost in the output of the `/tokens` command, we need to modify the `cmd_tokens` method in the `Commands` class in the `aider/commands.py` file.

We will add a new variable `total_cost` to keep track of the total cost. For each token count, we will calculate the cost by multiplying the token count by the model's `completion_price` (since we're considering the cost of generating these tokens). We will then add this cost to `total_cost`.

Finally, we will add a line to the output to display the total cost.

Here are the changes:

<source>python
aider/commands.py
<<<<<<< ORIGINAL
        total = 0
        for tk, msg, tip in res:
            total += tk
            msg = msg.ljust(col_width)
            self.io.tool_output(f"{fmt(tk)} {msg} {tip}")

        self.io.tool_output("=" * width)
        self.io.tool_output(f"{fmt(total)} tokens total")
=======
        total = 0
        total_cost = 0.0
        for tk, msg, tip in res:
            total += tk
            cost = tk * self.coder.main_model.completion_price
            total_cost += cost
            msg = msg.ljust(col_width)
            self.io.tool_output(f"{fmt(tk)} {msg} {tip} (cost: ${cost:.2f})")

        self.io.tool_output("=" * width)
        self.io.tool_output(f"{fmt(total)} tokens total (cost: ${total_cost:.2f})")
>>>>>>> UPDATED
</source>
2023-07-26 17:34:50 -03:00
Paul Gauthier
08ee61617f Updated discord link 2023-07-26 15:52:13 -03:00
Paul Gauthier
3e4b4d1b0d retry on APIConnectionError 2023-07-26 07:40:36 -03:00
Paul Gauthier
8ea4629e73 Merge branch 'main' into chat-history 2023-07-26 07:29:54 -03:00
paul-gauthier
86309f336c
Merge pull request #137 from paul-gauthier/refactor-repo
Refactor git repo code into a new file
2023-07-26 07:24:10 -03:00
Paul Gauthier
3e77df7587 /tokens should warn when <1k tokens left 2023-07-25 09:25:01 -03:00
Paul Gauthier
133eff8bdf Merge branch 'refactor-repo' into chat-history 2023-07-25 09:20:22 -03:00
Paul Gauthier
5bb3935f7e ssh 2023-07-25 09:19:01 -03:00
Paul Gauthier
b3746db08b Merge branch 'main' into chat-history 2023-07-25 09:13:28 -03:00
Paul Gauthier
53e332526b Merge branch 'main' into refactor-repo 2023-07-25 09:13:20 -03:00
Paul Gauthier
05c1b3bc99 cleanup 2023-07-25 09:13:07 -03:00
Paul Gauthier
9050b9bd93 threading 2023-07-25 07:57:05 -03:00
Paul Gauthier
4e348102bf wip 2023-07-25 07:46:05 -03:00
Paul Gauthier
b849d16ec7 Updated HISTORY 2023-07-25 07:22:22 -03:00
Paul Gauthier
fcdd640a09 Strong prompt to never elide code 2023-07-25 07:04:14 -03:00
Paul Gauthier
f0ec6cb36a Expand the tail to ensure head ends with assistant msg 2023-07-25 06:58:41 -03:00