mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-11-30 15:55:49 +08:00
feat(desktop): add tooltip provider and model management
This commit is contained in:
1 parent
37f9c4c4c8
commit
4700d3abc0
25 files changed
+717
-262
No files matched your search
@@ -177,6 +177,10 @@ pub fn api_router(service: ControlService) -> Router {
|
||||
"/__byok-api__/api/plugins/{plugin_id}/providers/{provider_id}/models/sync",
|
||||
post(plugins::sync_models),
|
||||
)
|
||||
.route(
|
||||
"/__byok-api__/api/plugins/{plugin_id}/providers/{provider_id}/models/enabled",
|
||||
put(plugins::set_model_enabled),
|
||||
)
|
||||
.route(
|
||||
"/__byok-api__/api/settings/observability",
|
||||
get(settings::get).put(settings::update),
|
||||
|
||||
@@ -105,6 +105,25 @@ pub async fn sync_models(
|
||||
Ok(Json(serde_json::json!({ "models": count })))
|
||||
}
|
||||
|
||||
pub async fn set_model_enabled(
|
||||
State(service): State<ControlService>,
|
||||
Path((plugin_id, provider_id)): Path<(String, String)>,
|
||||
Json(input): Json<serde_json::Value>,
|
||||
) -> Result<StatusCode> {
|
||||
let model_id = input
|
||||
.get("modelId")
|
||||
.and_then(serde_json::Value::as_str)
|
||||
.ok_or_else(|| crate::Error::Config("modelId must be a string".into()))?;
|
||||
let enabled = input
|
||||
.get("enabled")
|
||||
.and_then(serde_json::Value::as_bool)
|
||||
.ok_or_else(|| crate::Error::Config("enabled must be a boolean".into()))?;
|
||||
service
|
||||
.plugin_set_model_enabled(&plugin_id, &provider_id, model_id, enabled)
|
||||
.await?;
|
||||
Ok(StatusCode::NO_CONTENT)
|
||||
}
|
||||
|
||||
pub async fn runtime_status(
|
||||
State(service): State<ControlService>,
|
||||
) -> Result<Json<PluginRuntimeStatus>> {
|
||||
|
||||
@@ -241,6 +241,18 @@ impl ControlService {
|
||||
self.plugins.sync_models(plugin_id, provider_id).await
|
||||
}
|
||||
|
||||
pub async fn plugin_set_model_enabled(
|
||||
&self,
|
||||
plugin_id: &str,
|
||||
provider_id: &str,
|
||||
model_id: &str,
|
||||
enabled: bool,
|
||||
) -> Result<()> {
|
||||
self.plugins
|
||||
.set_model_enabled(plugin_id, provider_id, model_id, enabled)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn remove_plugin_configuration(&self, plugin_id: &str) -> Result<()> {
|
||||
self.plugins.remove(plugin_id).await
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user