feagi_api/endpoints/
evolution.rs1use crate::common::ApiState;
12use crate::common::{ApiError, ApiResult, Json, State};
13use serde_json::{json, Value};
15use std::collections::HashMap;
16
17#[utoipa::path(
23 get,
24 path = "/v1/evolution/status",
25 tag = "evolution",
26 responses(
27 (status = 200, description = "Evolution status", body = HashMap<String, serde_json::Value>),
28 (status = 500, description = "Internal server error")
29 )
30)]
31pub async fn get_status(State(_state): State<ApiState>) -> ApiResult<Json<HashMap<String, Value>>> {
32 let mut response = HashMap::new();
34 response.insert("active".to_string(), json!(false));
35 response.insert("generation".to_string(), json!(0));
36 response.insert("population_size".to_string(), json!(0));
37
38 Ok(Json(response))
39}
40
41#[utoipa::path(
43 post,
44 path = "/v1/evolution/config",
45 tag = "evolution",
46 responses(
47 (status = 200, description = "Evolution configured", body = HashMap<String, String>),
48 (status = 500, description = "Internal server error")
49 )
50)]
51pub async fn post_config(
52 State(_state): State<ApiState>,
53 Json(request): Json<HashMap<String, Value>>,
54) -> ApiResult<Json<HashMap<String, String>>> {
55 let _config = request
57 .get("config")
58 .ok_or_else(|| ApiError::invalid_input("Missing 'config' field"))?;
59
60 tracing::info!(target: "feagi-api", "Evolution configuration updated");
62
63 Ok(Json(HashMap::from([(
64 "message".to_string(),
65 "Evolution configured successfully".to_string(),
66 )])))
67}