use crate::{ModelStats, TrainingStats, Vector};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EmbeddingRequest {
pub entity_id: String,
pub entity: String,
pub model_id: Option<Uuid>,
pub model_version: Option<String>,
pub use_cache: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EmbeddingResponse {
pub entity_id: String,
pub entity: String,
pub embedding: Vector,
pub dimensions: usize,
pub model_id: Uuid,
pub model_version: String,
pub from_cache: bool,
pub generation_time_ms: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BatchEmbeddingRequest {
pub entity_ids: Vec<String>,
pub entities: Vec<String>,
pub model_id: Option<Uuid>,
pub model_version: Option<String>,
pub use_cache: Option<bool>,
pub options: Option<BatchOptions>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BatchOptions {
pub use_cache: Option<bool>,
pub batch_size: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BatchEmbeddingResponse {
pub embeddings: Vec<EmbeddingResponse>,
pub total_time_ms: f64,
pub cache_hits: usize,
pub cache_misses: usize,
pub model_id: Uuid,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TextEmbeddingRequest {
pub text: String,
pub text_type: Option<String>,
pub model_id: Option<Uuid>,
pub language: Option<String>,
pub use_cache: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TextEmbeddingResponse {
pub text: String,
pub embedding: Vector,
pub detected_language: Option<String>,
pub model_id: Uuid,
pub from_cache: bool,
pub generation_time_ms: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MultiModalRequest {
pub text: Option<String>,
pub entities: Option<Vec<String>>,
pub model_id: Option<Uuid>,
pub fusion_strategy: Option<String>,
pub use_cache: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MultiModalResponse {
pub embedding: Vector,
pub component_embeddings: HashMap<String, Vector>,
pub fusion_strategy: String,
pub model_id: Uuid,
pub from_cache: bool,
pub generation_time_ms: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StreamEmbeddingRequest {
pub items: Vec<StreamEmbeddingItem>,
pub model_id: Option<Uuid>,
pub options: Option<BatchOptions>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StreamEmbeddingItem {
pub id: String,
pub content: String,
pub content_type: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TripleScoreRequest {
pub subject: String,
pub predicate: String,
pub object: String,
pub model_id: Option<Uuid>,
pub model_version: Option<String>,
pub use_cache: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TripleScoreResponse {
pub subject: String,
pub predicate: String,
pub object: String,
pub triple: (String, String, String),
pub score: f64,
pub model_id: Uuid,
pub model_version: String,
pub from_cache: bool,
pub computation_time_ms: f64,
pub scoring_time_ms: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PredictionRequest {
pub entities: Vec<String>,
pub prediction_type: PredictionType,
pub top_k: Option<usize>,
pub model_id: Option<Uuid>,
pub use_cache: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PredictionType {
Objects { subject: String, predicate: String },
Subjects { predicate: String, object: String },
Relations { subject: String, object: String },
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PredictionResponse {
pub input: Vec<String>,
pub prediction_type: String,
pub predictions: Vec<(String, f64)>,
pub model_version: String,
pub from_cache: bool,
pub prediction_time_ms: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ModelInfoRequest {
pub model_id: Option<Uuid>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ModelInfoResponse {
pub stats: ModelStats,
pub health: ModelHealth,
pub capabilities: Vec<String>,
pub last_training: Option<TrainingStats>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ModelHealth {
pub status: HealthStatus,
pub last_check: DateTime<Utc>,
pub metrics: HealthMetrics,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum HealthStatus {
Healthy,
Degraded,
Unhealthy,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HealthMetrics {
pub avg_response_time_ms: f64,
pub requests_last_hour: u64,
pub error_rate_percent: f64,
pub memory_usage_mb: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueryParams {
pub limit: Option<usize>,
pub offset: Option<usize>,
pub model_id: Option<Uuid>,
pub format: Option<String>,
pub detailed: Option<bool>,
}