gglib_core/domain/thinking/
mod.rs

1//! Thinking/reasoning content parsing and streaming accumulation.
2//!
3//! Reasoning models (`DeepSeek R1`, `Qwen3`, etc.) output a "thinking" phase that
4//! can appear either as a structured `reasoning_content` SSE field or as inline
5//! `<think>…</think>` tags in the message content.
6//!
7//! This module is the **single source of truth** for parsing those tags across
8//! all surfaces (CLI, Axum, Tauri).  It supports four tag families:
9//!
10//! | Format | Models |
11//! |---|---|
12//! | `<think>…</think>` | `DeepSeek R1`, `Qwen3`, most reasoning models |
13//! | `<reasoning>…</reasoning>` | Alternative / custom models |
14//! | `<seed:think>…</seed:think>` | `Seed-OSS` models |
15//! | `<\|START_THINKING\|>…<\|END_THINKING\|>` | `Command-R7B` style |
16//!
17//! # Modules
18//!
19//! | Module | Contents |
20//! |--------|----------|
21//! | [`types`] | [`ParsedThinkingContent`], [`ThinkingEvent`] |
22//! | [`normalize`] | [`normalize_thinking_tags`] — variant-tag normalisation |
23//! | [`parse`] | [`parse_thinking_content`], [`embed_thinking_content`], [`has_thinking_content`], [`format_thinking_duration`] |
24//! | [`accumulator`] | [`ThinkingAccumulator`] — streaming FSM for split-tag detection |
25
26pub mod accumulator;
27pub mod normalize;
28pub mod parse;
29pub mod types;
30
31#[cfg(test)]
32mod accumulator_tests;
33#[cfg(test)]
34mod parse_tests;
35
36// Re-export public API at module level for ergonomic imports.
37pub use accumulator::ThinkingAccumulator;
38pub use normalize::normalize_thinking_tags;
39pub use parse::{
40    embed_thinking_content, format_thinking_duration, has_thinking_content, parse_thinking_content,
41};
42pub use types::{ParsedThinkingContent, ThinkingEvent};