Added lmstudio declarative provider (#7455)
This commit is contained in:
@@ -266,7 +266,10 @@ pub fn load_provider(id: &str) -> Result<LoadedProvider> {
|
|||||||
.contents_utf8()
|
.contents_utf8()
|
||||||
.ok_or_else(|| anyhow::anyhow!("Failed to read file as UTF-8: {:?}", file.path()))?;
|
.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 {
|
if config.name == id {
|
||||||
return Ok(LoadedProvider {
|
return Ok(LoadedProvider {
|
||||||
config,
|
config,
|
||||||
@@ -306,8 +309,16 @@ fn load_fixed_providers() -> Result<Vec<DeclarativeProviderConfig>> {
|
|||||||
.contents_utf8()
|
.contents_utf8()
|
||||||
.ok_or_else(|| anyhow::anyhow!("Failed to read file as UTF-8: {:?}", file.path()))?;
|
.ok_or_else(|| anyhow::anyhow!("Failed to read file as UTF-8: {:?}", file.path()))?;
|
||||||
|
|
||||||
let config: DeclarativeProviderConfig = serde_json::from_str(content)?;
|
match serde_json::from_str(content) {
|
||||||
res.push(config)
|
Ok(config) => res.push(config),
|
||||||
|
Err(e) => {
|
||||||
|
tracing::warn!(
|
||||||
|
"Skipping invalid declarative provider {:?}: {}",
|
||||||
|
file.path(),
|
||||||
|
e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
|
|||||||
@@ -1,19 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "Kimi",
|
"name": "kimi",
|
||||||
"metadata": {
|
"engine": "openai",
|
||||||
"homepage": "https://kimi.ai",
|
"display_name": "Kimi",
|
||||||
"docs": "https://platform.moonshot.cn/docs/intro",
|
"description": "Kimi Code AI models optimized for coding tasks",
|
||||||
"description": "Kimi Code AI models optimized for coding tasks"
|
"api_key_env": "MOONSHOT_API_KEY",
|
||||||
},
|
"base_url": "https://api.moonshot.cn/v1/chat/completions",
|
||||||
"engine": {
|
"models": [
|
||||||
"type": "openai",
|
{"name": "kimi-for-coding", "context_limit": 262144},
|
||||||
"base_url": "https://api.moonshot.cn/v1",
|
{"name": "kimi-code", "context_limit": 262144}
|
||||||
"api_key_env_var": "MOONSHOT_API_KEY"
|
],
|
||||||
},
|
"supports_streaming": true
|
||||||
"models": [
|
|
||||||
{"name": "kimi-for-coding", "context_limit": 262144},
|
|
||||||
{"name": "kimi-code", "context_limit": 262144}
|
|
||||||
],
|
|
||||||
"streaming_default": true,
|
|
||||||
"pricing_info_url": "https://platform.moonshot.cn/pricing"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "lmstudio",
|
||||||
|
"engine": "openai",
|
||||||
|
"display_name": "LM Studio",
|
||||||
|
"description": "Run local models with LM Studio",
|
||||||
|
"api_key_env": "",
|
||||||
|
"base_url": "http://localhost:1234/v1/chat/completions",
|
||||||
|
"models": [],
|
||||||
|
"supports_streaming": true,
|
||||||
|
"requires_auth": false
|
||||||
|
}
|
||||||
@@ -1,23 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "Moonshot",
|
"name": "moonshot",
|
||||||
"metadata": {
|
"engine": "openai",
|
||||||
"homepage": "https://kimi.moonshot.cn/",
|
"display_name": "Moonshot",
|
||||||
"docs": "https://platform.moonshot.cn/docs/intro",
|
"description": "Moonshot AI (Kimi) models",
|
||||||
"description": "Moonshot AI (Kimi) models"
|
"api_key_env": "MOONSHOT_API_KEY",
|
||||||
},
|
"base_url": "https://api.moonshot.cn/v1/chat/completions",
|
||||||
"engine": {
|
"models": [
|
||||||
"type": "openai",
|
{"name": "kimi-latest", "context_limit": 131072},
|
||||||
"base_url": "https://api.moonshot.cn/v1",
|
{"name": "kimi-thinking-preview", "context_limit": 131072},
|
||||||
"api_key_env_var": "MOONSHOT_API_KEY"
|
{"name": "kimi-k2-0711", "context_limit": 131072},
|
||||||
},
|
{"name": "kimi-k2", "context_limit": 262144},
|
||||||
"models": [
|
{"name": "moonshot-v1-8k", "context_limit": 8192},
|
||||||
{"name": "kimi-latest", "context_limit": 131072},
|
{"name": "moonshot-v1-32k", "context_limit": 32768}
|
||||||
{"name": "kimi-thinking-preview", "context_limit": 131072},
|
],
|
||||||
{"name": "kimi-k2-0711", "context_limit": 131072},
|
"supports_streaming": true
|
||||||
{"name": "kimi-k2", "context_limit": 262144},
|
|
||||||
{"name": "moonshot-v1-8k", "context_limit": 8192},
|
|
||||||
{"name": "moonshot-v1-32k", "context_limit": 32768}
|
|
||||||
],
|
|
||||||
"streaming_default": true,
|
|
||||||
"pricing_info_url": "https://platform.moonshot.cn/pricing"
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user