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

Support for new key= mechanism #22

Closed
simonw opened this issue Mar 4, 2025 · 3 comments
Closed

Support for new key= mechanism #22

simonw opened this issue Mar 4, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Mar 4, 2025

https://llm.datasette.io/en/stable/plugins/advanced-model-plugins.html#advanced-model-plugins-api-keys

@simonw simonw added the enhancement New feature or request label Mar 4, 2025
@simonw
Copy link
Owner Author

simonw commented Mar 4, 2025

Without this passing an invalid key would still use the valid key stored in llm keys set mistral:

llm -m mistral-small 'goat joke' --key invalid

I got a goat joke:

Sure, her

e's a light-hearted goat joke for you:

Why don't goats make good secret keepers?

Because they always bleat everything out!

But with the fix applied I get:

{
 "message":"Unauthorized",
 "request_id":"6941f674e9372b3df07b6e320d7f201d"
}
Error: Client error '401 Unauthorized' for url 'https://api.mistral.ai/v1/chat/completions'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401

simonw added a commit that referenced this issue Mar 4, 2025
@simonw
Copy link
Owner Author

simonw commented Mar 4, 2025

Spotted this bug:

llm -m mistral-small 'goat joke' --key invalid --async

Error: Attempted to call a sync iterator on an async stream.

It works without --async and it worked fine before this fix.

@simonw
Copy link
Owner Author

simonw commented Mar 4, 2025

Fired up a debugger:

RuntimeError: Attempted to call a sync iterator on an async stream.
>>> import pdb
>>> pdb.pm()
> /Users/simon/.local/share/virtualenvs/llm-mistral-LjsSd8B3/lib/python3.10/site-packages/httpx/_models.py(944)iter_raw()
-> raise RuntimeError("Attempted to call a sync iterator on an async stream.")
(Pdb) u
> /Users/simon/.local/share/virtualenvs/llm-mistral-LjsSd8B3/lib/python3.10/site-packages/httpx/_models.py(897)iter_bytes()
-> for raw_bytes in self.iter_raw():
(Pdb) u
> /Users/simon/.local/share/virtualenvs/llm-mistral-LjsSd8B3/lib/python3.10/site-packages/httpx/_models.py(881)read()
-> self._content = b"".join(self.iter_bytes())
(Pdb) u
> /Users/simon/Dropbox/Development/llm-mistral/llm_mistral.py(380)execute()
-> decoded = json.loads(event_source.response.read())

simonw added a commit that referenced this issue Mar 4, 2025
@simonw simonw closed this as completed Mar 4, 2025
simonw added a commit that referenced this issue Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant