-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Add Codestral edit predictions provider #34371
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
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @dvcrn on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
Found a bug: using multiple cursors is messing with things and generates a bunch of duplicates stuff |
|
Thank you for this PR! It works very well Here are some suggestions
|
The issue here is that Mistral API and Codestral use different API keys. It works if the user already has their Codestral API key in Zed, but this usually means that the normal Mistral functionality doesn't work. Maybe we need to add a separate key for Codestral specific? |
|
You are right. I think it's fine to keep the API key in the settings. Maybe someone from Mistral can open a PR to add their own OAuth system like Supermaven some day I am using this branch as my daily driver, this is the best inline completion provider available in Zed right now, really thank you |
Do you have some examples of the end_of_file tokens getting inserted? |
Please give this a go! What changes are missing to get this merged? |
|
@dvcrn Thanks for working on this! Sorry about the huge review delay. I've pushed some improvements. Overall it seems pretty reasonable, and seems to mostly work (I have seen some funky large predictions that seem like bugs, but not worth blocking merge on it). I think it'd be good to remove the context header for now to make this change smaller / more reviewable. The logic differs from zeta and some of the constants seem wild - like 80 lines of diff is a lot (arbitrarily large if there are long lines). Also not sure about wrapping it in The API key really shouldn't be in the settings, it should probably be an additional API key entry in the Mistral section of the agent settings. That would be a fair bit of work to add, though, so not going to block this PR on it. |
…ter zeta2 implements this
|
Going to go ahead and make the changes I described |
|
Please feel free to adjust whatever you see fit, I trust your judgement on that 😄 With
Yes agree. I was considering re-using the mistral API key settings, but since codestral wants a different endpoint, it started getting a little confusing |
Release Notes: - Added Codestral edit predictions provider which can be enabled by adding an API key in the Mistral section of agent settings.  ## Config Get API key from https://console.mistral.ai/codestral and add it in the Mistral section of the agent settings. ``` "features": { "edit_prediction_provider": "codestral" }, "edit_predictions": { "codestral": { "model": "codestral-latest", "max_tokens": 150 } }, ``` --------- Co-authored-by: Michael Sloan <michael@zed.dev>
|
@mgsloan thanks for taking this PR until merge! |
|
|
Is there any reason why the api.mistral.ia endpoint is not used? Currently, the codestral endpoint only has the free option, and due to their privacy policy, they use your data to improve their models. I understand that for most people this may be a benefit, but considering that they may handle sensitive data, it would be advisable to use the paid option. Apart from not having to configure several tokens, as one is sufficient. Thank you very much for your work on this pull request. |
|
@pedrxd Is Codestral now available through normal mistral API? When I started implementation on this, it sounded like the separate Codestral endpoint was the only real way to use Codestral FIM, hence why I couldn't just re-use the existing mistral provider in Zed. Let me look into this /EDIT: Okay we can swap to api.mistral.ai - https://docs.mistral.ai/capabilities/code_generation But the docs still say:
So both endpoints make sense here. Maybe we could check if the user already has the mistral provider setup? But I don't think we should just start using it without any indication what's happening and ramp up cost on that key. How about making the API endpoint configurable? The API key was already configurable in my initial PR, so it would just be another field. Users that want api.mistral.ai can then swap the endpoint + API key out to explicitly use api.mistral.ai over codestral.mistral.ai |
|
@dvcrn Mistral allows on-premise deployments, so allowing you to write the endpoint you want to use could be the best option. The configuration interface could be left as it is now, allowing endpoints to be overwritten via settings.json (like a advance option). This would allow someone with an on-premises deployment to change the endpoints, and someone who wants to use API.mistral.ai instead of codestral to overwrite them. Either option would be fine. If you think it is more appropriate to put it in the interface, that is also fine. |
Yes I think if anything, this option would be the best. We default to codestral and if someone really wants to, they can override the base_url through the settings.json file, in a similar way to how we can already do it for other providers. (Wonder if that would even enable local ollama codestral, if the API interface is identical) |
|
@dvcrn: maybe remove the
It's still surprisingly unintelligent. In a JS file, it completes "// Generate a random string of 100 characters" with "Math.random().toString(36).substring(2, 100)". |
```json
"edit_predictions": {
"codestral": {
"api_url": "https://codestral.mistral.ai",
"model": "codestral-latest",
"max_tokens": 150
}
},
```
Release Notes:
- Added support for changing the Codestral endpoint. This was discussed
at #34371.
---------
Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
```json
"edit_predictions": {
"codestral": {
"api_url": "https://codestral.mistral.ai",
"model": "codestral-latest",
"max_tokens": 150
}
},
```
Release Notes:
- Added support for changing the Codestral endpoint. This was discussed
at zed-industries#34371.
---------
Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>

Attempt of adding Codestral through Mistral API as edit predictions provider. Heavily inspired (or more like copy pasted) by the Supermaven provider
Config
Get API key from https://console.mistral.ai/codestral
Disclaimer: I'm not a rust engineer and this is my first time dealing with the Zed repo. AI helped me a lot with figuring things out.