- Unified synchronous generate() core with callback; both streaming and non-streaming paths run it via spawn_blocking (context: std Mutex). - build_prompt now passes tool definitions to the template (was dead) and embeds assistant tool-call history as XML matching the parser format; fixes double <tool_response> wrap and template set-scoping bug. - Tokenize with AddBos::Never (template owns <s>) to remove double BOS. - Streaming: preserve inter-word spaces (per-chunk trim removed), add [DONE] + usage chunk, emit error events, single-shot tool_calls delta. - Strict model validation (400 on unknown model); health/UI/README aligned to minicpm5-1b-fable5-v2-thinking; auth returns JSON errors; n_ctx/ n_batch/n_threads env-configurable. - Added 18 unit tests; cargo check/clippy/fmt clean. - scripts/smoke-test.sh for post-deploy verification on the VPS. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
20 lines
497 B
Rust
20 lines
497 B
Rust
//! Chat UI — simple web interface for interacting with the LLM.
|
|
|
|
use axum::http::{header, HeaderValue, StatusCode};
|
|
use axum::response::{IntoResponse, Response};
|
|
|
|
const HTML: &str = include_str!("chat-ui/index.html");
|
|
|
|
/// GET / — serve the chat UI page.
|
|
pub async fn chat_ui() -> Response {
|
|
(
|
|
StatusCode::OK,
|
|
[(
|
|
header::CONTENT_TYPE,
|
|
HeaderValue::from_static("text/html; charset=utf-8"),
|
|
)],
|
|
HTML,
|
|
)
|
|
.into_response()
|
|
}
|