language_models: Add support for tool use to LM Studio provider (#30589)

Closes #30004

**Quick demo:**


https://github.com/user-attachments/assets/0ac93851-81d7-4128-a34b-1f3ae4bcff6d

**Additional notes:**

I've tried to stick to existing code in OpenAI provider as much as
possible without changing much to keep the diff small.

This PR is done in collaboration with @yagil from LM Studio. We agreed
upon the format in which LM Studio will return information about tool
use support for the model in the upcoming version. As of current stable
version nothing is going to change for the users, but once they update
to a newer LM Studio tool use gets automatically enabled for them. I
think this is much better UX then defaulting to true right now.


Release Notes:

- Added support for tool calls to LM Studio provider

---------

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
This commit is contained in:
Fedor Nezhivoi 2025-05-26 18:54:17 +07:00 committed by GitHub
parent 6363fdab88
commit 998542b048
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 320 additions and 120 deletions

View file

@ -383,7 +383,9 @@ impl AssistantSettingsContent {
_ => None,
};
settings.provider = Some(AssistantProviderContentV1::LmStudio {
default_model: Some(lmstudio::Model::new(&model, None, None)),
default_model: Some(lmstudio::Model::new(
&model, None, None, false,
)),
api_url,
});
}