1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use utoipa::ToSchema;
4
5use crate::search::SearchMode;
6
7#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
8pub struct SearchSettingsResponse {
9 pub mode: SearchMode,
10 pub rerank_enabled: bool,
11 pub rerank_base_url: String,
12 pub rerank_model: String,
13 pub candidate_limit: usize,
14 pub timeout_secs: u64,
15 pub has_api_key: bool,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
19pub struct UpdateSearchSettingsRequest {
20 pub mode: SearchMode,
21 pub rerank_enabled: bool,
22 pub rerank_base_url: String,
23 pub rerank_model: String,
24 pub candidate_limit: usize,
25 pub timeout_secs: u64,
26 #[serde(default)]
27 pub api_key: Option<String>,
28 #[serde(default)]
29 pub clear_api_key: bool,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
33pub struct RuntimeSettingsResponse {
34 pub qdrant: RuntimeQdrantSettings,
35 pub embedding: RuntimeEmbeddingSettings,
36 pub scheduler: RuntimeSchedulerSettings,
37 pub chunking: RuntimeChunkingSettings,
38 pub file_library: RuntimeFileLibrarySettings,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
42pub struct UpdateRuntimeSettingsRequest {
43 pub qdrant: RuntimeQdrantSettings,
44 pub embedding: UpdateRuntimeEmbeddingSettings,
45 pub scheduler: RuntimeSchedulerSettings,
46 pub chunking: RuntimeChunkingSettings,
47 pub file_library: UpdateRuntimeFileLibrarySettings,
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
51pub struct RuntimeQdrantSettings {
52 pub url: String,
53 pub collection_name: String,
54 pub recreate_on_dimension_mismatch: bool,
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
58pub struct RuntimeEmbeddingSettings {
59 pub base_url: String,
60 pub model: String,
61 pub dimensions: usize,
62 pub timeout_secs: u64,
63 pub has_api_key: bool,
64}
65
66#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
67pub struct UpdateRuntimeEmbeddingSettings {
68 pub base_url: String,
69 pub model: String,
70 pub dimensions: usize,
71 pub timeout_secs: u64,
72 #[serde(default, skip_serializing_if = "Option::is_none")]
73 pub api_key: Option<String>,
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
77pub struct RuntimeSchedulerSettings {
78 pub interval_secs: u64,
79 pub run_on_start: bool,
80 pub max_concurrency: usize,
81 pub job_id: String,
82 #[serde(default, skip_serializing_if = "Option::is_none")]
83 pub valkey_url: Option<String>,
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
87pub struct TestRuntimeValkeyRequest {
88 pub valkey_url: String,
89}
90
91#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
92#[serde(rename_all = "snake_case")]
93pub enum VectorIndexRebuildState {
94 Idle,
95 Running,
96 Succeeded,
97 Failed,
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
101pub struct VectorIndexRebuildStatus {
102 pub state: VectorIndexRebuildState,
103 pub processed_chunks: usize,
104 pub total_chunks: usize,
105 #[serde(default, skip_serializing_if = "Option::is_none")]
106 pub error_message: Option<String>,
107 #[serde(default, skip_serializing_if = "Option::is_none")]
108 pub started_at: Option<DateTime<Utc>>,
109 #[serde(default, skip_serializing_if = "Option::is_none")]
110 pub finished_at: Option<DateTime<Utc>>,
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
114pub struct RuntimeChunkingSettings {
115 pub max_chars: usize,
116 pub overlap_chars: usize,
117}
118
119#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
120pub struct RuntimeFileLibrarySettings {
121 pub storage_root: String,
122 pub max_upload_size_mb: usize,
123 pub max_upload_request_size_mb: usize,
124 pub ingest_concurrency: usize,
125 pub pdf_pages_per_task: u32,
126 #[serde(default, skip_serializing_if = "Option::is_none")]
127 pub s3: Option<RuntimeS3SettingsResponse>,
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
131pub struct UpdateRuntimeFileLibrarySettings {
132 pub storage_root: String,
133 pub max_upload_size_mb: usize,
134 pub max_upload_request_size_mb: usize,
135 pub ingest_concurrency: usize,
136 pub pdf_pages_per_task: u32,
137 #[serde(default, skip_serializing_if = "Option::is_none")]
138 pub s3: Option<UpdateRuntimeS3Settings>,
139}
140
141#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
142pub struct RuntimeS3SettingsResponse {
143 pub endpoint: String,
144 pub region: String,
145 pub bucket: String,
146 pub prefix: String,
147 pub path_style: bool,
148 pub access_key: String,
149 pub has_secret_key: bool,
150}
151
152#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
153pub struct UpdateRuntimeS3Settings {
154 pub endpoint: String,
155 pub region: String,
156 pub bucket: String,
157 #[serde(default)]
158 pub prefix: String,
159 #[serde(default)]
160 pub path_style: bool,
161 pub access_key: String,
162 #[serde(default, skip_serializing_if = "Option::is_none")]
163 pub secret_key: Option<String>,
164}
165
166#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
167#[serde(rename_all = "snake_case")]
168pub enum DoclingSettingsSource {
169 Config,
170 Database,
171 Unconfigured,
172}
173
174#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
175pub struct DoclingSettingsResponse {
176 pub configured: bool,
177 pub source: DoclingSettingsSource,
178 pub connection: DoclingConnectionSettingsResponse,
179 pub vlm: DoclingVlmSettingsResponse,
180}
181
182#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
183pub struct UpdateDoclingSettingsRequest {
184 pub connection: UpdateDoclingConnectionSettings,
185 #[serde(default)]
186 pub vlm: UpdateDoclingVlmSettings,
187}
188
189#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
190pub struct DoclingConnectionSettingsResponse {
191 #[serde(default, skip_serializing_if = "Option::is_none")]
192 pub base_url: Option<String>,
193 pub timeout_secs: u64,
194 pub poll_interval_secs: u64,
195}
196
197#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
198pub struct UpdateDoclingConnectionSettings {
199 pub base_url: String,
200 pub timeout_secs: u64,
201 pub poll_interval_secs: u64,
202}
203
204#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
205pub struct DoclingVlmSettingsResponse {
206 #[serde(default, skip_serializing_if = "Option::is_none")]
207 pub openai_base_url: Option<String>,
208 pub has_api_key: bool,
209 #[serde(default, skip_serializing_if = "Option::is_none")]
210 pub vlm_pipeline_model: Option<String>,
211 #[serde(default, skip_serializing_if = "Option::is_none")]
212 pub picture_description_model: Option<String>,
213 #[serde(default, skip_serializing_if = "Option::is_none")]
214 pub code_formula_model: Option<String>,
215}
216
217#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, Default)]
218pub struct UpdateDoclingVlmSettings {
219 #[serde(default, skip_serializing_if = "Option::is_none")]
220 pub openai_base_url: Option<String>,
221 #[serde(default, skip_serializing_if = "Option::is_none")]
222 pub api_key: Option<String>,
223 #[serde(default, skip_serializing_if = "Option::is_none")]
224 pub vlm_pipeline_model: Option<String>,
225 #[serde(default, skip_serializing_if = "Option::is_none")]
226 pub picture_description_model: Option<String>,
227 #[serde(default, skip_serializing_if = "Option::is_none")]
228 pub code_formula_model: Option<String>,
229}