fix: Face processor now saves status and total_faces to face.json
This commit is contained in:
+20
-15
@@ -2,14 +2,14 @@ use axum::{
|
||||
extract::State,
|
||||
http::StatusCode,
|
||||
response::Json,
|
||||
Router,
|
||||
routing::{get, post, put},
|
||||
Router,
|
||||
};
|
||||
use serde_json::{json, Value};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::core::admin_config::{VlmPrompt, PartialAdminConfig};
|
||||
use crate::api::types::AppState;
|
||||
use crate::core::admin_config::{PartialAdminConfig, VlmPrompt};
|
||||
|
||||
pub fn admin_config_routes() -> Router<AppState> {
|
||||
Router::new()
|
||||
@@ -17,13 +17,14 @@ pub fn admin_config_routes() -> Router<AppState> {
|
||||
.route("/api/v1/admin/config", post(update_config))
|
||||
.route("/api/v1/admin/config/vlm_prompts", get(get_vlm_prompts))
|
||||
.route("/api/v1/admin/config/vlm_prompts/:key", get(get_vlm_prompt))
|
||||
.route("/api/v1/admin/config/vlm_prompts/:key", put(update_vlm_prompt))
|
||||
.route(
|
||||
"/api/v1/admin/config/vlm_prompts/:key",
|
||||
put(update_vlm_prompt),
|
||||
)
|
||||
.route("/api/v1/admin/config/reload", post(reload_config))
|
||||
}
|
||||
|
||||
pub async fn get_config(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
pub async fn get_config(State(state): State<AppState>) -> Result<Json<Value>, StatusCode> {
|
||||
let config = state.admin_config_manager.get_full_config().await;
|
||||
Ok(Json(serde_json::to_value(config).unwrap_or_default()))
|
||||
}
|
||||
@@ -32,7 +33,11 @@ pub async fn update_config(
|
||||
State(state): State<AppState>,
|
||||
Json(partial): Json<PartialAdminConfig>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
match state.admin_config_manager.update_partial_config(partial).await {
|
||||
match state
|
||||
.admin_config_manager
|
||||
.update_partial_config(partial)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Ok(Json(json!({
|
||||
"success": true,
|
||||
"message": "Config updated"
|
||||
@@ -41,9 +46,7 @@ pub async fn update_config(
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_vlm_prompts(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
pub async fn get_vlm_prompts(State(state): State<AppState>) -> Result<Json<Value>, StatusCode> {
|
||||
let prompts = state.admin_config_manager.get_all_vlm_prompts().await;
|
||||
Ok(Json(serde_json::to_value(prompts).unwrap_or_default()))
|
||||
}
|
||||
@@ -63,7 +66,11 @@ pub async fn update_vlm_prompt(
|
||||
axum::extract::Path(key): axum::extract::Path<String>,
|
||||
Json(prompt): Json<VlmPrompt>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
match state.admin_config_manager.update_vlm_prompt(&key, prompt).await {
|
||||
match state
|
||||
.admin_config_manager
|
||||
.update_vlm_prompt(&key, prompt)
|
||||
.await
|
||||
{
|
||||
Ok(_) => Ok(Json(json!({
|
||||
"success": true,
|
||||
"message": format!("Prompt '{}' updated", key)
|
||||
@@ -72,9 +79,7 @@ pub async fn update_vlm_prompt(
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn reload_config(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, StatusCode> {
|
||||
pub async fn reload_config(State(state): State<AppState>) -> Result<Json<Value>, StatusCode> {
|
||||
match state.admin_config_manager.reload().await {
|
||||
Ok(_) => Ok(Json(json!({
|
||||
"success": true,
|
||||
@@ -82,4 +87,4 @@ pub async fn reload_config(
|
||||
}))),
|
||||
Err(_) => Err(StatusCode::INTERNAL_SERVER_ERROR),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user