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 url_import_concurrency: usize,
126 pub url_import_min_interval_ms: u64,
127 pub trusted_proxy_enabled: bool,
128 #[serde(default, skip_serializing_if = "Option::is_none")]
129 pub s3: Option<RuntimeS3SettingsResponse>,
130}
131
132#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
133pub struct UpdateRuntimeFileLibrarySettings {
134 pub storage_root: String,
135 pub max_upload_size_mb: usize,
136 pub max_upload_request_size_mb: usize,
137 pub ingest_concurrency: usize,
138 pub url_import_concurrency: usize,
139 pub url_import_min_interval_ms: u64,
140 #[serde(default)]
141 pub trusted_proxy_enabled: bool,
142 #[serde(default, skip_serializing_if = "Option::is_none")]
143 pub s3: Option<UpdateRuntimeS3Settings>,
144}
145
146#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
147pub struct RuntimeS3SettingsResponse {
148 pub endpoint: String,
149 pub region: String,
150 pub bucket: String,
151 pub prefix: String,
152 pub path_style: bool,
153 pub access_key: String,
154 pub has_secret_key: bool,
155}
156
157#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
158pub struct UpdateRuntimeS3Settings {
159 pub endpoint: String,
160 pub region: String,
161 pub bucket: String,
162 #[serde(default)]
163 pub prefix: String,
164 #[serde(default)]
165 pub path_style: bool,
166 pub access_key: String,
167 #[serde(default, skip_serializing_if = "Option::is_none")]
168 pub secret_key: Option<String>,
169}
170
171#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
172#[serde(rename_all = "snake_case")]
173pub enum DoclingSettingsSource {
174 Config,
175 Database,
176 Unconfigured,
177}
178
179#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
180pub struct DoclingSettingsResponse {
181 pub configured: bool,
182 pub source: DoclingSettingsSource,
183 pub connection: DoclingConnectionSettingsResponse,
184 pub vlm: DoclingVlmSettingsResponse,
185}
186
187#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
188pub struct UpdateDoclingSettingsRequest {
189 pub connection: UpdateDoclingConnectionSettings,
190 #[serde(default)]
191 pub vlm: UpdateDoclingVlmSettings,
192}
193
194#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
195pub struct DoclingConnectionSettingsResponse {
196 #[serde(default, skip_serializing_if = "Option::is_none")]
197 pub base_url: Option<String>,
198 pub timeout_secs: u64,
199 pub poll_interval_secs: u64,
200 pub task_timeout_secs: u64,
201}
202
203#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
204pub struct UpdateDoclingConnectionSettings {
205 pub base_url: String,
206 pub timeout_secs: u64,
207 pub poll_interval_secs: u64,
208 pub task_timeout_secs: u64,
209}
210
211#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
212pub struct DoclingVlmSettingsResponse {
213 #[serde(default, skip_serializing_if = "Option::is_none")]
214 pub openai_base_url: Option<String>,
215 pub has_api_key: bool,
216 #[serde(default, skip_serializing_if = "Option::is_none")]
217 pub vlm_pipeline_model: Option<String>,
218 #[serde(default, skip_serializing_if = "Option::is_none")]
219 pub picture_description_model: Option<String>,
220 #[serde(default, skip_serializing_if = "Option::is_none")]
221 pub code_formula_model: Option<String>,
222}
223
224#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, Default)]
225pub struct UpdateDoclingVlmSettings {
226 #[serde(default, skip_serializing_if = "Option::is_none")]
227 pub openai_base_url: Option<String>,
228 #[serde(default, skip_serializing_if = "Option::is_none")]
229 pub api_key: Option<String>,
230 #[serde(default, skip_serializing_if = "Option::is_none")]
231 pub vlm_pipeline_model: Option<String>,
232 #[serde(default, skip_serializing_if = "Option::is_none")]
233 pub picture_description_model: Option<String>,
234 #[serde(default, skip_serializing_if = "Option::is_none")]
235 pub code_formula_model: Option<String>,
236}