Files
kebab/crates/kebab-rag/src/lib.rs
th-kim0823 307fd8d527 feat(rag): pipeline emits StreamEvent + cancel on SendError (fb-33)
RetrievalDone after retrieve+stale-stamp, Token per LM chunk
(SendError → break, FinishReason::Cancelled, RefusalReason::
LlmStreamAborted), Final on success. answers row still persists
on cancel for audit. Adds FinishReason::Cancelled, re-exports
StreamEvent from kebab_rag, migrates two pre-fb-33 sink tests
in tests/pipeline.rs to the new StreamEvent type (the
"dropped receiver does not abort" test inverts to record cancel).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 14:49:55 +09:00

26 lines
1.1 KiB
Rust

//! `kb-rag` — RAG pipeline (P4-3).
//!
//! End-to-end orchestration of `retrieve → gate → pack → generate →
//! cite-validate → persist` per design §0 Q4 / §1 / §2.3 / §3.8 / §6.4.
//!
//! Allowed deps per the P4-3 task spec:
//! - `kb-core` (Answer / Retriever / LanguageModel / DocumentStore types)
//! - `kb-config` (RagCfg + LlmCfg + EmbeddingModelCfg)
//! - `kb-search` (Retriever trait object — concrete adapters injected)
//! - `kb-llm` (LanguageModel trait re-export)
//! - `kb-store-sqlite` (read chunk text via DocumentStore + write
//! `answers` row via the new `put_answer` helper)
//! - `serde`, `serde_json`, `regex`, `time`, `tracing`, `thiserror`,
//! `anyhow`, `blake3` (TraceId minting).
//!
//! Forbidden (per spec §Forbidden dependencies): `kb-source-fs`,
//! `kb-parse-md`, `kb-normalize`, `kb-chunk`, `kb-store-vector` (only
//! reachable via `Retriever`), `kb-embed*` (only via `Retriever`),
//! `kb-llm-local` (only via `LanguageModel`), `kb-tui`, `kb-desktop`.
pub use kebab_core::{Answer, AnswerCitation, AnswerRetrievalSummary, RefusalReason};
mod pipeline;
pub use pipeline::{AskOpts, RagPipeline, StreamEvent};