Refactored and documented the HTTP API

This commit is contained in:
Dave
2026-02-16 16:50:50 +00:00
parent f76376b203
commit feb05dc8d0
9 changed files with 148 additions and 136 deletions

View File

@@ -1,14 +1,22 @@
use crate::http::context::{AppContext, OpenApiResult, bad_request};
use crate::llm::chat;
use poem_openapi::{OpenApi, payload::Json};
use poem_openapi::{OpenApi, Tags, payload::Json};
use std::sync::Arc;
#[derive(Tags)]
enum ChatTags {
Chat,
}
pub struct ChatApi {
pub ctx: Arc<AppContext>,
}
#[OpenApi]
#[OpenApi(tag = "ChatTags::Chat")]
impl ChatApi {
/// Cancel the currently running chat stream, if any.
///
/// Returns `true` once the cancellation signal is issued.
#[oai(path = "/chat/cancel", method = "post")]
async fn cancel_chat(&self) -> OpenApiResult<Json<bool>> {
chat::cancel_chat(&self.ctx.state).map_err(bad_request)?;