use crate::common::ApiState;
use crate::common::{ApiError, ApiResult, Json, State};
use serde_json::{json, Value};
use std::collections::HashMap;
#[utoipa::path(
get,
path = "/v1/evolution/status",
tag = "evolution",
responses(
(status = 200, description = "Evolution status", body = HashMap<String, serde_json::Value>),
(status = 500, description = "Internal server error")
)
)]
pub async fn get_status(State(_state): State<ApiState>) -> ApiResult<Json<HashMap<String, Value>>> {
let mut response = HashMap::new();
response.insert("active".to_string(), json!(false));
response.insert("generation".to_string(), json!(0));
response.insert("population_size".to_string(), json!(0));
Ok(Json(response))
}
#[utoipa::path(
post,
path = "/v1/evolution/config",
tag = "evolution",
responses(
(status = 200, description = "Evolution configured", body = HashMap<String, String>),
(status = 500, description = "Internal server error")
)
)]
pub async fn post_config(
State(_state): State<ApiState>,
Json(request): Json<HashMap<String, Value>>,
) -> ApiResult<Json<HashMap<String, String>>> {
let _config = request
.get("config")
.ok_or_else(|| ApiError::invalid_input("Missing 'config' field"))?;
tracing::info!(target: "feagi-api", "Evolution configuration updated");
Ok(Json(HashMap::from([(
"message".to_string(),
"Evolution configured successfully".to_string(),
)])))
}