Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/backend/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,10 @@ pub fn create_router(state: AppState) -> Router {
.route("/static_flow/admin/llm-gateway/monitor", get(seo::seo_spa_shell))
.route("/admin/kiro-gateway", get(seo::seo_spa_shell))
.route("/admin/kiro-gateway/accounts", any(admin_kiro_accounts_entry))
.route("/admin/kiro-gateway/upstream-channels", get(seo::seo_spa_shell))
.route("/static_flow/admin/kiro-gateway", get(seo::seo_spa_shell))
.route("/static_flow/admin/kiro-gateway/accounts", any(admin_kiro_accounts_entry))
.route("/static_flow/admin/kiro-gateway/upstream-channels", get(seo::seo_spa_shell))
.route("/admin/llm-gateway/*path", any(crate::llm_access_admin_proxy::proxy_admin_request))
.route(
"/static_flow/admin/llm-gateway/*path",
Expand Down
92 changes: 92 additions & 0 deletions crates/frontend/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10887,11 +10887,33 @@ pub struct AdminAnthropicUpstreamChannelView {
pub proxy_mode: String,
pub proxy_config_id: Option<String>,
pub last_error: Option<String>,
pub models: Vec<String>,
pub last_models_status: Option<String>,
pub last_models_latency_ms: Option<u64>,
pub last_models_checked_at: Option<i64>,
pub last_models_error: Option<String>,
pub last_test_model: Option<String>,
pub last_test_status: Option<String>,
pub last_test_latency_ms: Option<u64>,
pub last_test_at: Option<i64>,
pub last_test_error: Option<String>,
pub usage: AdminAnthropicUpstreamUsageRollupView,
pub created_at: i64,
pub updated_at: i64,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
#[serde(default)]
pub struct AdminAnthropicUpstreamProbeResponseView {
pub ok: bool,
pub status: String,
pub status_code: Option<u16>,
pub latency_ms: u64,
pub error: Option<String>,
pub channel: AdminAnthropicUpstreamChannelView,
pub generated_at: i64,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
#[serde(default)]
pub struct AdminAnthropicUpstreamChannelsResponse {
Expand Down Expand Up @@ -10929,6 +10951,11 @@ pub struct PatchAdminAnthropicUpstreamChannelInput {
pub clear_last_error: bool,
}

#[derive(Debug, Serialize, Clone, PartialEq, Default)]
pub struct TestAdminAnthropicUpstreamModelInput {
pub model: String,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
#[serde(default)]
pub struct KiroAccountView {
Expand Down Expand Up @@ -11904,6 +11931,71 @@ pub async fn patch_admin_anthropic_upstream_channel(
}
}

pub async fn refresh_admin_anthropic_upstream_models(
name: &str,
) -> Result<AdminAnthropicUpstreamProbeResponseView, String> {
#[cfg(feature = "mock")]
{
let _ = name;
Ok(AdminAnthropicUpstreamProbeResponseView::default())
}

#[cfg(not(feature = "mock"))]
{
let url = format!(
"{}/admin/kiro-gateway/anthropic-upstreams/{}/refresh-models",
llm_access_admin_base(),
urlencoding::encode(name)
);
let response = api_post(&url)
.send()
.await
.map_err(|e| format!("Network error: {:?}", e))?;
if !response.ok() {
let text = response.text().await.unwrap_or_default();
return Err(format!("Failed: {text}"));
}
response
.json()
.await
.map_err(|e| format!("Parse error: {:?}", e))
}
}

pub async fn test_admin_anthropic_upstream_model(
name: &str,
input: &TestAdminAnthropicUpstreamModelInput,
) -> Result<AdminAnthropicUpstreamProbeResponseView, String> {
#[cfg(feature = "mock")]
{
let _ = (name, input);
Ok(AdminAnthropicUpstreamProbeResponseView::default())
}

#[cfg(not(feature = "mock"))]
{
let url = format!(
"{}/admin/kiro-gateway/anthropic-upstreams/{}/test",
llm_access_admin_base(),
urlencoding::encode(name)
);
let response = api_post(&url)
.json(input)
.map_err(|e| format!("Serialize error: {:?}", e))?
.send()
.await
.map_err(|e| format!("Network error: {:?}", e))?;
if !response.ok() {
let text = response.text().await.unwrap_or_default();
return Err(format!("Failed: {text}"));
}
response
.json()
.await
.map_err(|e| format!("Parse error: {:?}", e))
}
}

pub async fn delete_admin_anthropic_upstream_channel(name: &str) -> Result<(), String> {
#[cfg(feature = "mock")]
{
Expand Down
Loading
Loading