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

Get retries working again despite prefix #10

Closed
simonw opened this issue Apr 16, 2024 · 2 comments
Closed

Get retries working again despite prefix #10

simonw opened this issue Apr 16, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@simonw
Copy link
Contributor

simonw commented Apr 16, 2024

I found a query that gave a SQL parse error first time and needed a retry and got this error:

anthropic.BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages: roles must alternate between "user" and "assistant", but found multiple "assistant" roles in a row'}}

@simonw simonw added the bug Something isn't working label Apr 16, 2024
@simonw
Copy link
Contributor Author

simonw commented Apr 16, 2024

I upgraded to Sonnet for this experiment. The question I tried was:

4 most popular licenses and the top repos for each one, use json_object

Against the https://datasette.io/content/licenses table

@simonw
Copy link
Contributor Author

simonw commented Apr 16, 2024

Eventually got it working. The debug output looked like this:


--
explain select l.name, l.key, json_group_object (
    'repos', json_group_array(
        json_object(
            'id', r.id,
            'full_name', r.full_name,
            'stargazers', r.stargazers_count
        )
    )
)
from licenses l
join repos r on r.license = l.key
group by l.name, l.key
order by sum(r.stargazers_count) desc
limit 4;

--
ERROR: conn=<sqlite3.Connection object at 0x10720c840>, sql = "explain select l.name, l.key, json_group_object (\n    'repos', json_group_array(\n        json_object(\n            'id', r.id,\n            'full_name', r.full_name,\n            'stargazers', r.stargazers_count\n        )\n    )\n)\nfrom licenses l\njoin repos r on r.license = l.key\ngroup by l.name, l.key\norder by sum(r.stargazers_count) desc\nlimit 4;\n", params = None: misuse of aggregate function json_group_array()
--
explain select l.name, l.key,
json_group_array(
    json_object(
        'id', r.id,
        'full_name', r.full_name, 
        'stargazers', r.stargazers_count
    )
)
from licenses l
join repos r on r.license = l.key
group by l.name, l.key
order by sum(r.stargazers_count) desc
limit 4;

Note the error there: misuse of aggregate function json_group_array()

@simonw simonw closed this as completed in 537b3c8 Apr 16, 2024
simonw added a commit that referenced this issue Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant