use serde::{Deserialize, Serialize}; /// Basic user display data used by frontend components. #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct UserData { pub name: String, } /// Authentication information returned by the `check_auth` server function. /// /// The frontend uses this to determine whether the user is logged in /// and to display their profile (name, email, avatar). #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] pub struct AuthInfo { /// Whether the user has a valid session pub authenticated: bool, /// Keycloak subject identifier (unique user ID) pub sub: String, /// User email address pub email: String, /// User display name pub name: String, /// Avatar URL (from Keycloak picture claim) pub avatar_url: String, /// LibreChat instance URL for the sidebar chat link pub librechat_url: String, } /// Per-user LLM provider configuration stored in MongoDB. /// /// Controls which provider and model the user's chat sessions default /// to, and stores API keys for non-Ollama providers. #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] pub struct UserProviderConfig { /// Default provider name (e.g. "ollama", "openai") pub default_provider: String, /// Default model ID (e.g. "llama3.1:8b", "gpt-4o") pub default_model: String, /// OpenAI API key (empty if not configured) #[serde(default, skip_serializing_if = "Option::is_none")] pub openai_api_key: Option, /// Anthropic API key #[serde(default, skip_serializing_if = "Option::is_none")] pub anthropic_api_key: Option, /// HuggingFace API key #[serde(default, skip_serializing_if = "Option::is_none")] pub huggingface_api_key: Option, /// Custom Ollama URL override (empty = use server default) pub ollama_url_override: String, } /// Per-user preferences stored in MongoDB. /// /// Keyed by `sub` (Keycloak subject) and optionally scoped to an org. #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] pub struct UserPreferences { /// Keycloak subject identifier pub sub: String, /// Organization ID (from Keycloak Organizations) pub org_id: String, /// User-selected news/search topics pub custom_topics: Vec, /// Per-user Ollama URL override (empty = use server default) pub ollama_url_override: String, /// Per-user Ollama model override (empty = use server default) pub ollama_model_override: String, /// Recently searched queries for quick access pub recent_searches: Vec, /// LLM provider configuration #[serde(default)] pub provider_config: UserProviderConfig, }