diff --git a/docker-compose.yml b/docker-compose.yml index d4fe86d..11d1c18 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - NOXIS_LOG_LEVEL=TRACE - ML_TARGET_URL=http://192.168.249.5:11434/api/generate - ML_MODEL_NAME=kis-test - - ML_REQUEST_TIMEOUT=20 + - ML_REQUEST_TIMEOUT=30 - ML_LOG_LEVEL=TRACE - ML_API_PORT=5134 ports: diff --git a/src/api_docs.rs b/src/api_docs.rs index b59c95b..d030a6a 100644 --- a/src/api_docs.rs +++ b/src/api_docs.rs @@ -1,5 +1,5 @@ use crate::schemas::InputMetric; -use crate::endpoints::rest::__path_model_rest_handler; +use crate::endpoints::rest::{__path_model_rest_handler, __path_settings_handler}; use utoipa::OpenApi; #[derive(OpenApi)] @@ -14,7 +14,7 @@ use utoipa::OpenApi; url = "https://___" ) ), - paths(model_rest_handler), + paths(model_rest_handler, settings_handler), components( schemas(InputMetric) ), diff --git a/src/endpoints.rs b/src/endpoints.rs index 5d60805..496b5dd 100644 --- a/src/endpoints.rs +++ b/src/endpoints.rs @@ -14,7 +14,7 @@ pub mod rest { use super::{IntoResponse, StatusCode, InputMetric, Json, Config, State}; #[utoipa::path( - get, + post, summary = "An endpoint using to REST communication with the Model", path = "/api/metrics/rest", request_body = Vec, @@ -34,6 +34,22 @@ pub mod rest { Err(er) => (StatusCode::INTERNAL_SERVER_ERROR, format!("cannot get model response: {er}")), } } + + #[utoipa::path( + get, + summary = "An endpoint using to get APi's config", + path = "/api/settings", + responses( + (status = 200, description = "API shared its config"), + ), + tag = "query" + )] + pub async fn settings_handler( + State(config) : State, + ) -> impl IntoResponse { + trace!("GET on /api/settings"); + (StatusCode::OK, config.to_string()) + } } pub mod ws { diff --git a/src/main.rs b/src/main.rs index 806dfee..c59351a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,13 +8,13 @@ use std::sync::Arc; use tracing::{debug, info, trace}; use dotenv::dotenv; use endpoints::{ - rest::model_rest_handler, + rest::{model_rest_handler, settings_handler}, ws::model_ws_handler, }; use setup::setup_self_config; use models::ApiSessionConfig; use axum::{ - routing::get, + routing::{get, post}, Router}; use lazy_static::lazy_static; use utoipa_swagger_ui::SwaggerUi; @@ -35,12 +35,13 @@ async fn main() -> anyhow::Result<()> { // routing trace!("configurating routing ..."); let api = Router::new() - .route("/rest", get(model_rest_handler)) - .route("/ws", get(model_ws_handler)) + .route("/metrics/rest", post(model_rest_handler)) + .route("/metrics/ws", get(model_ws_handler)) + .route("/settings", get(settings_handler)) .with_state(app_state.clone()); let router = Router::new() - .nest("/api/metrics", api) + .nest("/api", api) .merge(SwaggerUi::new("/swagger").url("/api-docs/openapi.json", ApiDoc::openapi())); // .route("/swagger", get(swagger));