Added lmstudio declarative provider (#7455)

This commit is contained in:
Zane
2026-02-24 08:48:43 -08:00
committed by GitHub
parent 959ff9a6bd
commit 6305b9d62a
4 changed files with 51 additions and 41 deletions
@@ -266,7 +266,10 @@ pub fn load_provider(id: &str) -> Result<LoadedProvider> {
.contents_utf8()
.ok_or_else(|| anyhow::anyhow!("Failed to read file as UTF-8: {:?}", file.path()))?;
let config: DeclarativeProviderConfig = serde_json::from_str(content)?;
let config: DeclarativeProviderConfig = match serde_json::from_str(content) {
Ok(config) => config,
Err(_) => continue,
};
if config.name == id {
return Ok(LoadedProvider {
config,
@@ -306,8 +309,16 @@ fn load_fixed_providers() -> Result<Vec<DeclarativeProviderConfig>> {
.contents_utf8()
.ok_or_else(|| anyhow::anyhow!("Failed to read file as UTF-8: {:?}", file.path()))?;
let config: DeclarativeProviderConfig = serde_json::from_str(content)?;
res.push(config)
match serde_json::from_str(content) {
Ok(config) => res.push(config),
Err(e) => {
tracing::warn!(
"Skipping invalid declarative provider {:?}: {}",
file.path(),
e
);
}
}
}
Ok(res)