use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SufficiencyLevel {
Sufficient,
PartialSufficient,
Insufficient,
}
impl Default for SufficiencyLevel {
fn default() -> Self {
Self::Insufficient
}
}
#[derive(Debug, Clone)]
pub struct RetrieveResponse {
pub results: Vec<RetrievalResult>,
pub content: String,
pub confidence: f32,
pub is_sufficient: bool,
pub strategy_used: String,
pub reasoning_chain: ReasoningChain,
pub tokens_used: usize,
}
impl Default for RetrieveResponse {
fn default() -> Self {
Self {
results: Vec::new(),
content: String::new(),
confidence: 0.0,
is_sufficient: false,
strategy_used: String::new(),
reasoning_chain: ReasoningChain::default(),
tokens_used: 0,
}
}
}
impl RetrieveResponse {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn is_empty(&self) -> bool {
self.results.is_empty()
}
#[must_use]
pub fn len(&self) -> usize {
self.results.len()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RetrievalResult {
pub node_id: Option<String>,
pub title: String,
pub content: Option<String>,
pub summary: Option<String>,
pub score: f32,
pub depth: usize,
pub page_range: Option<(usize, usize)>,
}
impl RetrievalResult {
#[must_use]
pub fn new(title: impl Into<String>) -> Self {
Self {
node_id: None,
title: title.into(),
content: None,
summary: None,
score: 1.0,
depth: 0,
page_range: None,
}
}
#[must_use]
pub fn with_node_id(mut self, id: impl Into<String>) -> Self {
self.node_id = Some(id.into());
self
}
#[must_use]
pub fn with_content(mut self, content: impl Into<String>) -> Self {
self.content = Some(content.into());
self
}
#[must_use]
pub fn with_summary(mut self, summary: impl Into<String>) -> Self {
self.summary = Some(summary.into());
self
}
#[must_use]
pub fn with_score(mut self, score: f32) -> Self {
self.score = score;
self
}
#[must_use]
pub fn with_depth(mut self, depth: usize) -> Self {
self.depth = depth;
self
}
#[must_use]
pub fn with_page_range(mut self, start: usize, end: usize) -> Self {
self.page_range = Some((start, end));
self
}
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ReasoningChain {
pub steps: Vec<ReasoningStep>,
}
impl ReasoningChain {
#[must_use]
pub fn new() -> Self {
Self::default()
}
pub fn push(&mut self, step: ReasoningStep) {
self.steps.push(step);
}
#[must_use]
pub fn len(&self) -> usize {
self.steps.len()
}
#[must_use]
pub fn is_empty(&self) -> bool {
self.steps.is_empty()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReasoningStep {
pub reasoning: String,
}