1use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5use std::collections::HashMap;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
9#[serde(rename_all = "snake_case")]
10pub enum SimilarityMetric {
11 Cosine,
13 Euclidean,
15 DotProduct,
17}
18
19impl Default for SimilarityMetric {
20 fn default() -> Self {
21 Self::Cosine
22 }
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct Vector {
28 pub id: String,
30 pub data: Vec<f32>,
32 pub metadata: Option<HashMap<String, serde_json::Value>>,
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
38pub struct Collection {
39 pub name: String,
41 pub dimension: usize,
43 pub similarity_metric: SimilarityMetric,
45 pub description: Option<String>,
47 pub created_at: Option<DateTime<Utc>>,
49 pub updated_at: Option<DateTime<Utc>>,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct CollectionInfo {
56 pub name: String,
58 pub dimension: usize,
60 pub metric: String,
62 pub vector_count: usize,
64 pub document_count: usize,
66 pub created_at: String,
68 pub updated_at: String,
70 pub indexing_status: IndexingStatus,
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct IndexingStatus {
77 pub status: String,
79 pub progress: f32,
81 pub total_documents: usize,
83 pub processed_documents: usize,
85 pub vector_count: usize,
87 pub estimated_time_remaining: Option<String>,
89 pub last_updated: String,
91}
92
93#[derive(Debug, Clone, Serialize, Deserialize)]
95pub struct SearchResult {
96 pub id: String,
98 pub score: f32,
100 pub content: Option<String>,
102 pub metadata: Option<HashMap<String, serde_json::Value>>,
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108pub struct SearchResponse {
109 pub results: Vec<SearchResult>,
111 pub query_time_ms: f64,
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117pub struct EmbeddingRequest {
118 pub text: String,
120 pub model: Option<String>,
122 pub parameters: Option<EmbeddingParameters>,
124}
125
126#[derive(Debug, Clone, Serialize, Deserialize)]
128pub struct EmbeddingParameters {
129 pub max_length: Option<usize>,
131 pub normalize: Option<bool>,
133 pub prefix: Option<String>,
135}
136
137#[derive(Debug, Clone, Serialize, Deserialize)]
139pub struct EmbeddingResponse {
140 pub embedding: Vec<f32>,
142 pub model: String,
144 pub text: String,
146 pub dimension: usize,
148 pub provider: String,
150}
151
152#[derive(Debug, Clone, Serialize, Deserialize)]
154pub struct HealthStatus {
155 pub status: String,
157 pub version: String,
159 pub timestamp: String,
161 pub uptime: Option<u64>,
163 pub collections: Option<usize>,
165 pub total_vectors: Option<usize>,
167}
168
169#[derive(Debug, Clone, Serialize, Deserialize)]
171pub struct CollectionsResponse {
172 pub collections: Vec<CollectionInfo>,
174}
175
176#[derive(Debug, Clone, Serialize, Deserialize)]
178pub struct CreateCollectionResponse {
179 pub message: String,
181 pub collection: String,
183}
184
185#[derive(Debug, Clone, Serialize, Deserialize)]
187pub struct DatabaseStats {
188 pub total_collections: usize,
190 pub total_vectors: usize,
192 pub total_memory_estimate_bytes: usize,
194 pub collections: Vec<CollectionStats>,
196}
197
198#[derive(Debug, Clone, Serialize, Deserialize)]
200pub struct CollectionStats {
201 pub name: String,
203 pub vector_count: usize,
205 pub dimension: usize,
207 pub memory_estimate_bytes: usize,
209}
210
211#[derive(Debug, Clone, Serialize, Deserialize)]
213pub struct BatchTextRequest {
214 pub id: String,
216 pub text: String,
218 pub metadata: Option<HashMap<String, String>>,
220}
221
222#[derive(Debug, Clone, Serialize, Deserialize)]
224pub struct BatchConfig {
225 pub max_batch_size: Option<usize>,
227 pub parallel_workers: Option<usize>,
229 pub atomic: Option<bool>,
231}
232
233#[derive(Debug, Clone, Serialize, Deserialize)]
235pub struct BatchInsertRequest {
236 pub texts: Vec<BatchTextRequest>,
238 pub config: Option<BatchConfig>,
240}
241
242#[derive(Debug, Clone, Serialize, Deserialize)]
244pub struct BatchResponse {
245 pub success: bool,
247 pub collection: String,
249 pub operation: String,
251 pub total_operations: usize,
253 pub successful_operations: usize,
255 pub failed_operations: usize,
257 pub duration_ms: u64,
259 pub errors: Vec<String>,
261}
262
263#[derive(Debug, Clone, Serialize, Deserialize)]
265pub struct BatchSearchQuery {
266 pub query: String,
268 pub limit: Option<usize>,
270 pub score_threshold: Option<f32>,
272}
273
274#[derive(Debug, Clone, Serialize, Deserialize)]
276pub struct BatchSearchRequest {
277 pub queries: Vec<BatchSearchQuery>,
279 pub config: Option<BatchConfig>,
281}
282
283#[derive(Debug, Clone, Serialize, Deserialize)]
285pub struct BatchSearchResponse {
286 pub success: bool,
288 pub collection: String,
290 pub total_queries: usize,
292 pub successful_queries: usize,
294 pub failed_queries: usize,
296 pub duration_ms: u64,
298 pub results: Vec<Vec<SearchResult>>,
300 pub errors: Vec<String>,
302}
303
304#[derive(Debug, Clone, Serialize, Deserialize)]
306pub struct BatchVectorUpdate {
307 pub id: String,
309 pub data: Option<Vec<f32>>,
311 pub metadata: Option<HashMap<String, serde_json::Value>>,
313}
314
315#[derive(Debug, Clone, Serialize, Deserialize)]
317pub struct BatchUpdateRequest {
318 pub updates: Vec<BatchVectorUpdate>,
320 pub config: Option<BatchConfig>,
322}
323
324#[derive(Debug, Clone, Serialize, Deserialize)]
326pub struct BatchDeleteRequest {
327 pub vector_ids: Vec<String>,
329 pub config: Option<BatchConfig>,
331}
332
333#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
335#[serde(rename_all = "snake_case")]
336pub enum SummarizationMethod {
337 Extractive,
339 Keyword,
341 Sentence,
343 Abstractive,
345}
346
347impl Default for SummarizationMethod {
348 fn default() -> Self {
349 Self::Extractive
350 }
351}
352
353#[derive(Debug, Clone, Serialize, Deserialize)]
355pub struct SummarizeTextRequest {
356 pub text: String,
358 pub method: Option<SummarizationMethod>,
360 pub max_length: Option<usize>,
362 pub compression_ratio: Option<f32>,
364 pub language: Option<String>,
366}
367
368#[derive(Debug, Clone, Serialize, Deserialize)]
370pub struct SummarizeTextResponse {
371 pub summary_id: String,
373 pub original_text: String,
375 pub summary: String,
377 pub method: String,
379 pub original_length: usize,
381 pub summary_length: usize,
383 pub compression_ratio: f32,
385 pub language: String,
387 pub status: String,
389 pub message: String,
391 pub metadata: HashMap<String, String>,
393}
394
395#[derive(Debug, Clone, Serialize, Deserialize)]
397pub struct SummarizeContextRequest {
398 pub context: String,
400 pub method: Option<SummarizationMethod>,
402 pub max_length: Option<usize>,
404 pub compression_ratio: Option<f32>,
406 pub language: Option<String>,
408}
409
410#[derive(Debug, Clone, Serialize, Deserialize)]
412pub struct SummarizeContextResponse {
413 pub summary_id: String,
415 pub original_context: String,
417 pub summary: String,
419 pub method: String,
421 pub original_length: usize,
423 pub summary_length: usize,
425 pub compression_ratio: f32,
427 pub language: String,
429 pub status: String,
431 pub message: String,
433 pub metadata: HashMap<String, String>,
435}
436
437#[derive(Debug, Clone, Serialize, Deserialize)]
439pub struct GetSummaryResponse {
440 pub summary_id: String,
442 pub original_text: String,
444 pub summary: String,
446 pub method: String,
448 pub original_length: usize,
450 pub summary_length: usize,
452 pub compression_ratio: f32,
454 pub language: String,
456 pub created_at: String,
458 pub metadata: HashMap<String, String>,
460 pub status: String,
462}
463
464#[derive(Debug, Clone, Serialize, Deserialize)]
466pub struct SummaryInfo {
467 pub summary_id: String,
469 pub method: String,
471 pub language: String,
473 pub original_length: usize,
475 pub summary_length: usize,
477 pub compression_ratio: f32,
479 pub created_at: String,
481 pub metadata: HashMap<String, String>,
483}
484
485#[derive(Debug, Clone, Serialize, Deserialize)]
487pub struct ListSummariesResponse {
488 pub summaries: Vec<SummaryInfo>,
490 pub total_count: usize,
492 pub status: String,
494}
495
496#[derive(Debug, Clone, Serialize, Deserialize)]
498pub struct IndexingProgress {
499 pub is_indexing: bool,
501 pub overall_status: String,
503 pub collections: Vec<CollectionProgress>,
505}
506
507#[derive(Debug, Clone, Serialize, Deserialize)]
509pub struct CollectionProgress {
510 pub collection_name: String,
512 pub status: String,
514 pub progress: f32,
516 pub vector_count: usize,
518 pub error_message: Option<String>,
520 pub last_updated: String,
522}