{"repo": "asankilp/marsho-chat", "files": {"src-tauri/src/configs/config.rs": {"e8bc8629846c62c55df29beee4078e5dea701131": {"t": 1786067656.382593, "n": 1940, "h": "0b9a5d70dc330a27", "c": "use serde::{Deserialize, Serialize};\nuse serde_json::Value;\nuse std::path::Path;\n\n// pub enum ConfigType {\n// MarshoCfg,\n// ModelCfg,\n// }\n\n#[derive(Debug, Deserialize, Serialize, Clone)]\npub struct MarshoConfig {\n pub base_url: String,\n pub api_key: String,\n pub stream: bool,\n pub system_prompt: String,\n}\n\nimpl Default for MarshoConfig {\n fn default() -> Self {\n Self {\n base_url: \"https://api.deepseek.com\".to_string(),\n api_key: \"\".to_string(),\n stream: true,\n system_prompt: String::from(\"你是一只可爱的猫娘,你的名字叫Marsho\"),\n }\n }\n}\n\n#[derive(Debug, Deserialize, Serialize)]\npub struct ModelConfig {\n pub model: String,\n}\n\nimpl Default for ModelConfig {\n fn default() -> Self {\n Self {\n model: \"deepseek-reasoner\".to_string(),\n }\n }\n}\n\npub fn load_model_config() -> anyhow::Result {\n let config_path = \"model_config.yaml\";\n let config_str = serde_yaml::to_string(&ModelConfig::default())?;\n let path = Path::new(config_path);\n\n if !path.exists() {\n std::fs::write(config_path, config_str)?;\n }\n\n let json_str = std::fs::read_to_string(config_path)?;\n serde_yaml::from_str(&json_str).map_err(Into::into)\n}\n\npub fn load_marsho_config() -> anyhow::Result {\n let config_path = \"config.yaml\";\n let path = Path::new(config_path);\n\n if !path.exists() {\n let config_str = serde_yaml::to_string(&MarshoConfig::default())?;\n std::fs::write(config_path, config_str)?;\n }\n\n let settings = config::Config::builder()\n .add_source(config::File::with_name(config_path))\n .build()?;\n\n settings.try_deserialize().map_err(Into::into)\n}\n\npub fn save_marsho_config(config: &Value) -> anyhow::Result<()> {\n let config_path = \"config.yaml\";\n let config_str = serde_yaml::to_string(config)?;\n std::fs::write(config_path, config_str)?;\n Ok(())\n}"}}}}