use serde::{Deserialize, Serialize};
use crate::constants::{CHANGES_DEFAULT_LIMIT, DEFAULT_LIMIT};
use crate::contracts::PositiveCount;
use crate::search::input::WhereClause;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum RecallFormat {
#[default]
Json,
PromptXml,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ReadInput {
pub path: Option<String>,
#[serde(default)]
pub raw: bool,
#[serde(default)]
pub from_line: Option<PositiveCount>,
#[serde(default)]
pub max_lines: Option<PositiveCount>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RecallInput {
pub message: String,
#[serde(default)]
pub prior_messages: Vec<String>,
#[serde(default = "default_recall_budget")]
pub budget_tokens: u32,
#[serde(default)]
pub exclude: Vec<String>,
#[serde(default)]
pub scope: Vec<String>,
#[serde(default)]
pub scope_only: Vec<String>,
#[serde(default)]
pub scope_all: bool,
#[serde(default)]
pub format: RecallFormat,
#[serde(default = "default_recall_depth")]
pub depth: u8,
#[serde(default)]
pub min_confidence: f64,
#[serde(default)]
pub fast: bool,
#[serde(default)]
pub diagnostics: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub deadline_ms: Option<u64>,
}
const fn default_recall_budget() -> u32 {
2000
}
const fn default_recall_depth() -> u8 {
1
}
impl Default for RecallInput {
fn default() -> Self {
Self {
message: String::new(),
prior_messages: Vec::new(),
budget_tokens: default_recall_budget(),
exclude: Vec::new(),
scope: Vec::new(),
scope_only: Vec::new(),
scope_all: false,
format: RecallFormat::Json,
depth: default_recall_depth(),
min_confidence: 0.0,
fast: false,
diagnostics: false,
deadline_ms: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MetaInput {
#[serde(default)]
pub where_: Vec<WhereClause>,
#[serde(default)]
pub since: Option<String>,
#[serde(default)]
pub scope: Vec<String>,
#[serde(default)]
pub scope_only: Vec<String>,
#[serde(default)]
pub scope_all: bool,
#[serde(default)]
pub select: Vec<String>,
#[serde(default)]
pub tag_counts: bool,
#[serde(default)]
pub sources: Option<String>,
#[serde(default)]
pub limit: PositiveCount,
}
impl Default for MetaInput {
fn default() -> Self {
Self {
where_: Vec::new(),
since: None,
scope: Vec::new(),
scope_only: Vec::new(),
scope_all: false,
select: Vec::new(),
tag_counts: false,
sources: None,
limit: PositiveCount::from_const(DEFAULT_LIMIT),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ChangesInput {
pub since: String,
#[serde(default)]
pub scope: Vec<String>,
#[serde(default)]
pub scope_only: Vec<String>,
#[serde(default)]
pub scope_all: bool,
#[serde(default = "default_changes_limit")]
pub limit: PositiveCount,
}
const fn default_changes_limit() -> PositiveCount {
PositiveCount::from_const(CHANGES_DEFAULT_LIMIT)
}