Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/canonrebel04_android-ai-agent.json
T

1 line
20 KiB
JSON

{"repo": "canonrebel04/android-ai-agent", "files": {"src/provider/deepseek.rs": {"3e7e75765fda3f79f2c253920351e9c5fba7a304": {"t": 1785746252.4377975, "n": 4837, "h": "f25857c3e8804820", "c": "//! DeepSeek provider — supports both OpenAI-compatible and Anthropic-compatible APIs.\n//!\n//! OpenAI API: https://api.deepseek.com (Bearer auth)\n//! Anthropic API: https://api.deepseek.com/anthropic (x-api-key auth, model auto-mapped)\n//!\n//! Models: deepseek-v4-flash (cheap, 1M context), deepseek-v4-pro (powerful, 1M context)\n//! Both support thinking mode via `thinking: {type: \"enabled\"}` field.\n//! Pricing: flash $0.14/$0.28 per 1M in/out, pro $0.435/$0.87 (75% off currently).\n\nuse super::openai_compat;\nuse super::{LlmError, LlmProvider, LlmRequest, LlmResponse};\nuse futures_util::Stream;\nuse std::future::Future;\nuse std::pin::Pin;\n\npub struct DeepSeekProvider {\n api_key: String,\n /// Use Anthropic-compatible API (https://api.deepseek.com/anthropic) instead of OpenAI.\n pub use_anthropic_api: bool,\n /// Enable thinking mode (adds reasoning_content to responses).\n pub thinking_enabled: bool,\n}\n\nimpl DeepSeekProvider {\n pub fn new(api_key: String) -> Self {\n Self {\n api_key,\n use_anthropic_api: false,\n thinking_enabled: false,\n }\n }\n\n /// Use the Anthropic-compatible API endpoint.\n pub fn with_anthropic_api(mut self) -> Self {\n self.use_anthropic_api = true;\n self\n }\n\n /// Enable thinking mode for reasoning-capable tasks.\n pub fn with_thinking(mut self) -> Self {\n self.thinking_enabled = true;\n self\n }\n}\n\nimpl LlmProvider for DeepSeekProvider {\n fn base_url(&self) -> &str {\n if self.use_anthropic_api {\n \"https://api.deepseek.com/anthropic\"\n } else {\n \"https://api.deepseek.com\"\n }\n }\n\n fn auth_header(&self) -> (&str, &str) {\n if self.use_anthropic_api {\n (\"x-api-key\", &self.api_key)\n } else {\n (\"Authorization\", &self.api_key)\n }\n }\n\n fn call(\n &self,\n client: &reqwest::Client,\n request: &LlmRequest,\n ) -> impl Future<Output = Result<LlmResponse, LlmError>> + Send {\n let api_key = self.api_key.clone();\n let base_url = self.base_url().to_string();\n let thinking = self.thinking_enabled;\n let model = request.model.clone();\n let max_tokens = request.max_tokens;\n let temperature = request.temperature;\n let messages: Vec<_> = request\n .messages\n .iter()\n .map(|m| serde_json::json!({\"role\": m.role, \"content\": m.content}))\n .collect();\n\n async move {\n let mut body = serde_json::json!({\n \"model\": model,\n \"messages\": messages,\n \"max_tokens\": max_tokens,\n \"temperature\": temperature,\n });\n\n // Add thinking mode if enabled\n if thinking {\n body[\"thinking\"] = serde_json::json!({\"type\": \"enabled\"});\n body[\"reasoning_effort\"] = serde_json::json!(\"medium\");\n }\n\n let url = format!(\"{}/chat/completions\", base_url.trim_end_matches('/'));\n\n let resp = client\n .post(&url)\n .header(\"Authorization\", format!(\"Bearer {}\", api_key))\n .header(\"Content-Type\", \"application/json\")\n .json(&body)\n .send()\n .await\n .map_err(LlmError::Http)?;\n\n let resp = resp.error_for_status().map_err(LlmError::Http)?;\n let json: serde_json::Value = resp.json().await.map_err(LlmError::Http)?;\n\n openai_compat::parse_openai_response(&json, &model)\n }\n }\n\n fn call_stream(\n &self,\n _client: &reqwest::Client,\n _request: &LlmRequest,\n ) -> Pin<Box<dyn Stream<Item = Result<String, LlmError>> + Send>> {\n Box::pin(async_stream::try_stream! {\n yield \"DeepSeek streaming not implemented\".to_string();\n })\n }\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n\n #[test]\n fn test_deepseek_base_url() {\n let provider = DeepSeekProvider::new(\"sk-test\".into());\n assert_eq!(provider.base_url(), \"https://api.deepseek.com\");\n\n let anthropic = DeepSeekProvider::new(\"sk-test\".into()).with_anthropic_api();\n assert_eq!(anthropic.base_url(), \"https://api.deepseek.com/anthropic\");\n }\n\n #[test]\n fn test_deepseek_auth_header() {\n let provider = DeepSeekProvider::new(\"sk-test\".into());\n assert_eq!(provider.auth_header(), (\"Authorization\", \"sk-test\"));\n\n let anthropic = DeepSeekProvider::new(\"sk-test\".into()).with_anthropic_api();\n assert_eq!(anthropic.auth_header(), (\"x-api-key\", \"sk-test\"));\n }\n\n #[test]\n fn test_thinking_enabled_by_default() {\n let provider = DeepSeekProvider::new(\"sk-test\".into());\n assert!(!provider.thinking_enabled);\n }\n}\n"}, "e20873689cbd5c47a4f493d78bc018d4f3a8f3a5": {"t": 1785761099.7904377, "n": 4837, "h": "f25857c3e8804820", "c": "//! DeepSeek provider — supports both OpenAI-compatible and Anthropic-compatible APIs.\n//!\n//! OpenAI API: https://api.deepseek.com (Bearer auth)\n//! Anthropic API: https://api.deepseek.com/anthropic (x-api-key auth, model auto-mapped)\n//!\n//! Models: deepseek-v4-flash (cheap, 1M context), deepseek-v4-pro (powerful, 1M context)\n//! Both support thinking mode via `thinking: {type: \"enabled\"}` field.\n//! Pricing: flash $0.14/$0.28 per 1M in/out, pro $0.435/$0.87 (75% off currently).\n\nuse super::openai_compat;\nuse super::{LlmError, LlmProvider, LlmRequest, LlmResponse};\nuse futures_util::Stream;\nuse std::future::Future;\nuse std::pin::Pin;\n\npub struct DeepSeekProvider {\n api_key: String,\n /// Use Anthropic-compatible API (https://api.deepseek.com/anthropic) instead of OpenAI.\n pub use_anthropic_api: bool,\n /// Enable thinking mode (adds reasoning_content to responses).\n pub thinking_enabled: bool,\n}\n\nimpl DeepSeekProvider {\n pub fn new(api_key: String) -> Self {\n Self {\n api_key,\n use_anthropic_api: false,\n thinking_enabled: false,\n }\n }\n\n /// Use the Anthropic-compatible API endpoint.\n pub fn with_anthropic_api(mut self) -> Self {\n self.use_anthropic_api = true;\n self\n }\n\n /// Enable thinking mode for reasoning-capable tasks.\n pub fn with_thinking(mut self) -> Self {\n self.thinking_enabled = true;\n self\n }\n}\n\nimpl LlmProvider for DeepSeekProvider {\n fn base_url(&self) -> &str {\n if self.use_anthropic_api {\n \"https://api.deepseek.com/anthropic\"\n } else {\n \"https://api.deepseek.com\"\n }\n }\n\n fn auth_header(&self) -> (&str, &str) {\n if self.use_anthropic_api {\n (\"x-api-key\", &self.api_key)\n } else {\n (\"Authorization\", &self.api_key)\n }\n }\n\n fn call(\n &self,\n client: &reqwest::Client,\n request: &LlmRequest,\n ) -> impl Future<Output = Result<LlmResponse, LlmError>> + Send {\n let api_key = self.api_key.clone();\n let base_url = self.base_url().to_string();\n let thinking = self.thinking_enabled;\n let model = request.model.clone();\n let max_tokens = request.max_tokens;\n let temperature = request.temperature;\n let messages: Vec<_> = request\n .messages\n .iter()\n .map(|m| serde_json::json!({\"role\": m.role, \"content\": m.content}))\n .collect();\n\n async move {\n let mut body = serde_json::json!({\n \"model\": model,\n \"messages\": messages,\n \"max_tokens\": max_tokens,\n \"temperature\": temperature,\n });\n\n // Add thinking mode if enabled\n if thinking {\n body[\"thinking\"] = serde_json::json!({\"type\": \"enabled\"});\n body[\"reasoning_effort\"] = serde_json::json!(\"medium\");\n }\n\n let url = format!(\"{}/chat/completions\", base_url.trim_end_matches('/'));\n\n let resp = client\n .post(&url)\n .header(\"Authorization\", format!(\"Bearer {}\", api_key))\n .header(\"Content-Type\", \"application/json\")\n .json(&body)\n .send()\n .await\n .map_err(LlmError::Http)?;\n\n let resp = resp.error_for_status().map_err(LlmError::Http)?;\n let json: serde_json::Value = resp.json().await.map_err(LlmError::Http)?;\n\n openai_compat::parse_openai_response(&json, &model)\n }\n }\n\n fn call_stream(\n &self,\n _client: &reqwest::Client,\n _request: &LlmRequest,\n ) -> Pin<Box<dyn Stream<Item = Result<String, LlmError>> + Send>> {\n Box::pin(async_stream::try_stream! {\n yield \"DeepSeek streaming not implemented\".to_string();\n })\n }\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n\n #[test]\n fn test_deepseek_base_url() {\n let provider = DeepSeekProvider::new(\"sk-test\".into());\n assert_eq!(provider.base_url(), \"https://api.deepseek.com\");\n\n let anthropic = DeepSeekProvider::new(\"sk-test\".into()).with_anthropic_api();\n assert_eq!(anthropic.base_url(), \"https://api.deepseek.com/anthropic\");\n }\n\n #[test]\n fn test_deepseek_auth_header() {\n let provider = DeepSeekProvider::new(\"sk-test\".into());\n assert_eq!(provider.auth_header(), (\"Authorization\", \"sk-test\"));\n\n let anthropic = DeepSeekProvider::new(\"sk-test\".into()).with_anthropic_api();\n assert_eq!(anthropic.auth_header(), (\"x-api-key\", \"sk-test\"));\n }\n\n #[test]\n fn test_thinking_enabled_by_default() {\n let provider = DeepSeekProvider::new(\"sk-test\".into());\n assert!(!provider.thinking_enabled);\n }\n}\n"}, "bca8b16f537dde9b46f5bb67788e6a3f3aea4105": {"t": 1785761101.1207042, "n": 4837, "h": "804b2aded3da24da", "c": "//! DeepSeek provider — supports both OpenAI-compatible and Anthropic-compatible APIs.\n//!\n//! OpenAI API: https://api.deepseek.com (Bearer auth)\n//! Anthropic API: https://api.deepseek.com/anthropic (x-api-key auth, model auto-mapped)\n//!\n//! Models: deepseek-v4-flash (cheap, 1M context), deepseek-v4-pro (powerful, 1M context)\n//! Both support thinking mode via `thinking: {type: \"enabled\"}` field.\n//! Pricing: flash $0.14/$0.28 per 1M in/out, pro $0.435/$0.87 (75% off currently).\n\nuse super::openai_compat;\nuse super::{LlmError, LlmProvider, LlmRequest, LlmResponse};\nuse std::future::Future;\nuse futures_util::Stream;\nuse std::pin::Pin;\n\npub struct DeepSeekProvider {\n api_key: String,\n /// Use Anthropic-compatible API (https://api.deepseek.com/anthropic) instead of OpenAI.\n pub use_anthropic_api: bool,\n /// Enable thinking mode (adds reasoning_content to responses).\n pub thinking_enabled: bool,\n}\n\nimpl DeepSeekProvider {\n pub fn new(api_key: String) -> Self {\n Self {\n api_key,\n use_anthropic_api: false,\n thinking_enabled: false,\n }\n }\n\n /// Use the Anthropic-compatible API endpoint.\n pub fn with_anthropic_api(mut self) -> Self {\n self.use_anthropic_api = true;\n self\n }\n\n /// Enable thinking mode for reasoning-capable tasks.\n pub fn with_thinking(mut self) -> Self {\n self.thinking_enabled = true;\n self\n }\n}\n\nimpl LlmProvider for DeepSeekProvider {\n fn base_url(&self) -> &str {\n if self.use_anthropic_api {\n \"https://api.deepseek.com/anthropic\"\n } else {\n \"https://api.deepseek.com\"\n }\n }\n\n fn auth_header(&self) -> (&str, &str) {\n if self.use_anthropic_api {\n (\"x-api-key\", &self.api_key)\n } else {\n (\"Authorization\", &self.api_key)\n }\n }\n\n fn call(\n &self,\n client: &reqwest::Client,\n request: &LlmRequest,\n ) -> impl Future<Output = Result<LlmResponse, LlmError>> + Send {\n let api_key = self.api_key.clone();\n let base_url = self.base_url().to_string();\n let thinking = self.thinking_enabled;\n let model = request.model.clone();\n let max_tokens = request.max_tokens;\n let temperature = request.temperature;\n let messages: Vec<_> = request\n .messages\n .iter()\n .map(|m| serde_json::json!({\"role\": m.role, \"content\": m.content}))\n .collect();\n\n async move {\n let mut body = serde_json::json!({\n \"model\": model,\n \"messages\": messages,\n \"max_tokens\": max_tokens,\n \"temperature\": temperature,\n });\n\n // Add thinking mode if enabled\n if thinking {\n body[\"thinking\"] = serde_json::json!({\"type\": \"enabled\"});\n body[\"reasoning_effort\"] = serde_json::json!(\"medium\");\n }\n\n let url = format!(\"{}/chat/completions\", base_url.trim_end_matches('/'));\n\n let resp = client\n .post(&url)\n .header(\"Authorization\", format!(\"Bearer {}\", api_key))\n .header(\"Content-Type\", \"application/json\")\n .json(&body)\n .send()\n .await\n .map_err(LlmError::Http)?;\n\n let resp = resp.error_for_status().map_err(LlmError::Http)?;\n let json: serde_json::Value = resp.json().await.map_err(LlmError::Http)?;\n\n openai_compat::parse_openai_response(&json, &model)\n }\n }\n\n fn call_stream(\n &self,\n _client: &reqwest::Client,\n _request: &LlmRequest,\n ) -> Pin<Box<dyn Stream<Item = Result<String, LlmError>> + Send>> {\n Box::pin(async_stream::try_stream! {\n yield \"DeepSeek streaming not implemented\".to_string();\n })\n }\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n\n #[test]\n fn test_deepseek_base_url() {\n let provider = DeepSeekProvider::new(\"sk-test\".into());\n assert_eq!(provider.base_url(), \"https://api.deepseek.com\");\n\n let anthropic = DeepSeekProvider::new(\"sk-test\".into()).with_anthropic_api();\n assert_eq!(anthropic.base_url(), \"https://api.deepseek.com/anthropic\");\n }\n\n #[test]\n fn test_deepseek_auth_header() {\n let provider = DeepSeekProvider::new(\"sk-test\".into());\n assert_eq!(provider.auth_header(), (\"Authorization\", \"sk-test\"));\n\n let anthropic = DeepSeekProvider::new(\"sk-test\".into()).with_anthropic_api();\n assert_eq!(anthropic.auth_header(), (\"x-api-key\", \"sk-test\"));\n }\n\n #[test]\n fn test_thinking_enabled_by_default() {\n let provider = DeepSeekProvider::new(\"sk-test\".into());\n assert!(!provider.thinking_enabled);\n }\n}\n"}, "f570ee2574929d12e3ba617cb1ba13270dff5972": {"t": 1785761102.8152075, "n": 4496, "h": "9dc56284bce6fcad", "c": "//! DeepSeek provider — supports both OpenAI-compatible and Anthropic-compatible APIs.\n//!\n//! OpenAI API: https://api.deepseek.com (Bearer auth)\n//! Anthropic API: https://api.deepseek.com/anthropic (x-api-key auth, model auto-mapped)\n//!\n//! Models: deepseek-v4-flash (cheap, 1M context), deepseek-v4-pro (powerful, 1M context)\n//! Both support thinking mode via `thinking: {type: \"enabled\"}` field.\n//! Pricing: flash $0.14/$0.28 per 1M in/out, pro $0.435/$0.87 (75% off currently).\n\nuse super::openai_compat;\nuse super::{LlmError, LlmProvider, LlmRequest, LlmResponse};\nuse std::future::Future;\n\npub struct DeepSeekProvider {\n api_key: String,\n /// Use Anthropic-compatible API (https://api.deepseek.com/anthropic) instead of OpenAI.\n pub use_anthropic_api: bool,\n /// Enable thinking mode (adds reasoning_content to responses).\n pub thinking_enabled: bool,\n}\n\nimpl DeepSeekProvider {\n pub fn new(api_key: String) -> Self {\n Self {\n api_key,\n use_anthropic_api: false,\n thinking_enabled: false,\n }\n }\n\n /// Use the Anthropic-compatible API endpoint.\n pub fn with_anthropic_api(mut self) -> Self {\n self.use_anthropic_api = true;\n self\n }\n\n /// Enable thinking mode for reasoning-capable tasks.\n pub fn with_thinking(mut self) -> Self {\n self.thinking_enabled = true;\n self\n }\n}\n\nimpl LlmProvider for DeepSeekProvider {\n fn base_url(&self) -> &str {\n if self.use_anthropic_api {\n \"https://api.deepseek.com/anthropic\"\n } else {\n \"https://api.deepseek.com\"\n }\n }\n\n fn auth_header(&self) -> (&str, &str) {\n if self.use_anthropic_api {\n (\"x-api-key\", &self.api_key)\n } else {\n (\"Authorization\", &self.api_key)\n }\n }\n\n fn call(\n &self,\n client: &reqwest::Client,\n request: &LlmRequest,\n ) -> impl Future<Output = Result<LlmResponse, LlmError>> + Send {\n let api_key = self.api_key.clone();\n let base_url = self.base_url().to_string();\n let thinking = self.thinking_enabled;\n let model = request.model.clone();\n let max_tokens = request.max_tokens;\n let temperature = request.temperature;\n let messages: Vec<_> = request\n .messages\n .iter()\n .map(|m| serde_json::json!({\"role\": m.role, \"content\": m.content}))\n .collect();\n\n async move {\n let mut body = serde_json::json!({\n \"model\": model,\n \"messages\": messages,\n \"max_tokens\": max_tokens,\n \"temperature\": temperature,\n });\n\n // Add thinking mode if enabled\n if thinking {\n body[\"thinking\"] = serde_json::json!({\"type\": \"enabled\"});\n body[\"reasoning_effort\"] = serde_json::json!(\"medium\");\n }\n\n let url = format!(\"{}/chat/completions\", base_url.trim_end_matches('/'));\n\n let resp = client\n .post(&url)\n .header(\"Authorization\", format!(\"Bearer {}\", api_key))\n .header(\"Content-Type\", \"application/json\")\n .json(&body)\n .send()\n .await\n .map_err(LlmError::Http)?;\n\n let resp = resp.error_for_status().map_err(LlmError::Http)?;\n let json: serde_json::Value = resp.json().await.map_err(LlmError::Http)?;\n\n openai_compat::parse_openai_response(&json, &request.model)\n }\n }\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n\n #[test]\n fn test_deepseek_base_url() {\n let provider = DeepSeekProvider::new(\"sk-test\".into());\n assert_eq!(provider.base_url(), \"https://api.deepseek.com\");\n\n let anthropic = DeepSeekProvider::new(\"sk-test\".into()).with_anthropic_api();\n assert_eq!(anthropic.base_url(), \"https://api.deepseek.com/anthropic\");\n }\n\n #[test]\n fn test_deepseek_auth_header() {\n let provider = DeepSeekProvider::new(\"sk-test\".into());\n assert_eq!(provider.auth_header(), (\"Authorization\", \"sk-test\"));\n\n let anthropic = DeepSeekProvider::new(\"sk-test\".into()).with_anthropic_api();\n assert_eq!(anthropic.auth_header(), (\"x-api-key\", \"sk-test\"));\n }\n\n #[test]\n fn test_thinking_enabled_by_default() {\n let provider = DeepSeekProvider::new(\"sk-test\".into());\n assert!(!provider.thinking_enabled);\n }\n}\n"}}}}