Files

1 line
5.2 KiB
JSON

{"repo": "areevai/flowcat", "files": {"flowcat-services/src/llm/deepseek.rs": {"37b09bafd6a50cb65936411b40b09e77386e83e3": {"t": 1785746248.9166038, "n": 2396, "h": "cf3e16b8bf56a6e1", "c": "// SPDX-License-Identifier: Apache-2.0\n//\n//! **DeepSeek** LLM — a thin **(W)rapper** over [`OpenAiLlm`](super::OpenAiLlm).\n//!\n//! DeepSeek exposes an **OpenAI-compatible** chat-completions endpoint (verified\n//! against pipecat `services/deepseek/llm.py`, which is\n//! `class DeepSeekLLMService(OpenAILLMService)`), so this is the reference [`OpenAiLlm`]\n//! pointed at [`DEEPSEEK_API_BASE`] with the [`DEEPSEEK_DEFAULT_MODEL`] default. Behind the\n//! `llm-deepseek` feature (which enables `llm-openai`).\n\nuse async_trait::async_trait;\nuse futures::stream::BoxStream;\n\nuse flowcat_core::error::Result;\nuse flowcat_core::processor::frame::{Frame, LlmContext, StartParams};\nuse flowcat_core::service::{LlmService, Tool};\n\nuse super::{OpenAiLlm, OpenAiLlmBuilder};\n\n/// DeepSeek's OpenAI-compatible API base.\npub const DEEPSEEK_API_BASE: &str = \"https://api.deepseek.com/v1\";\n/// DeepSeek's default model.\npub const DEEPSEEK_DEFAULT_MODEL: &str = \"deepseek-chat\";\n\n/// DeepSeek LLM service — an [`OpenAiLlm`] pointed at the DeepSeek base URL.\npub struct DeepSeekLlm {\n inner: OpenAiLlm,\n}\n\nimpl DeepSeekLlm {\n /// Construct bound to `api_key`, using [`DEEPSEEK_DEFAULT_MODEL`].\n pub fn new(api_key: impl Into<String>) -> Self {\n Self::with_model(api_key, DEEPSEEK_DEFAULT_MODEL)\n }\n\n /// Construct bound to `api_key` with an explicit `model`.\n pub fn with_model(api_key: impl Into<String>, model: impl Into<String>) -> Self {\n let inner = OpenAiLlmBuilder::new(api_key)\n .base_url(DEEPSEEK_API_BASE)\n .model(model)\n .build();\n Self { inner }\n }\n}\n\n#[async_trait]\nimpl LlmService for DeepSeekLlm {\n fn name(&self) -> &str {\n \"deepseek\"\n }\n\n async fn start(&mut self, params: &StartParams) -> Result<()> {\n self.inner.start(params).await\n }\n\n async fn run_llm<'a>(&'a mut self, ctx: &'a LlmContext) -> Result<BoxStream<'a, Frame>> {\n self.inner.run_llm(ctx).await\n }\n\n fn set_tools(&mut self, tools: Vec<Tool>) {\n self.inner.set_tools(tools)\n }\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n\n #[test]\n fn constructs_with_base_and_default_model() {\n // Construction must not panic; the name is the provider id.\n assert_eq!(DeepSeekLlm::new(\"k\").name(), \"deepseek\");\n assert_eq!(DeepSeekLlm::with_model(\"k\", \"custom\").name(), \"deepseek\");\n }\n}\n"}, "6bbe70fa356b68497477dfe4e741fe5b19408fec": {"t": 1785761067.464202, "n": 2396, "h": "cf3e16b8bf56a6e1", "c": "// SPDX-License-Identifier: Apache-2.0\n//\n//! **DeepSeek** LLM — a thin **(W)rapper** over [`OpenAiLlm`](super::OpenAiLlm).\n//!\n//! DeepSeek exposes an **OpenAI-compatible** chat-completions endpoint (verified\n//! against pipecat `services/deepseek/llm.py`, which is\n//! `class DeepSeekLLMService(OpenAILLMService)`), so this is the reference [`OpenAiLlm`]\n//! pointed at [`DEEPSEEK_API_BASE`] with the [`DEEPSEEK_DEFAULT_MODEL`] default. Behind the\n//! `llm-deepseek` feature (which enables `llm-openai`).\n\nuse async_trait::async_trait;\nuse futures::stream::BoxStream;\n\nuse flowcat_core::error::Result;\nuse flowcat_core::processor::frame::{Frame, LlmContext, StartParams};\nuse flowcat_core::service::{LlmService, Tool};\n\nuse super::{OpenAiLlm, OpenAiLlmBuilder};\n\n/// DeepSeek's OpenAI-compatible API base.\npub const DEEPSEEK_API_BASE: &str = \"https://api.deepseek.com/v1\";\n/// DeepSeek's default model.\npub const DEEPSEEK_DEFAULT_MODEL: &str = \"deepseek-chat\";\n\n/// DeepSeek LLM service — an [`OpenAiLlm`] pointed at the DeepSeek base URL.\npub struct DeepSeekLlm {\n inner: OpenAiLlm,\n}\n\nimpl DeepSeekLlm {\n /// Construct bound to `api_key`, using [`DEEPSEEK_DEFAULT_MODEL`].\n pub fn new(api_key: impl Into<String>) -> Self {\n Self::with_model(api_key, DEEPSEEK_DEFAULT_MODEL)\n }\n\n /// Construct bound to `api_key` with an explicit `model`.\n pub fn with_model(api_key: impl Into<String>, model: impl Into<String>) -> Self {\n let inner = OpenAiLlmBuilder::new(api_key)\n .base_url(DEEPSEEK_API_BASE)\n .model(model)\n .build();\n Self { inner }\n }\n}\n\n#[async_trait]\nimpl LlmService for DeepSeekLlm {\n fn name(&self) -> &str {\n \"deepseek\"\n }\n\n async fn start(&mut self, params: &StartParams) -> Result<()> {\n self.inner.start(params).await\n }\n\n async fn run_llm<'a>(&'a mut self, ctx: &'a LlmContext) -> Result<BoxStream<'a, Frame>> {\n self.inner.run_llm(ctx).await\n }\n\n fn set_tools(&mut self, tools: Vec<Tool>) {\n self.inner.set_tools(tools)\n }\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n\n #[test]\n fn constructs_with_base_and_default_model() {\n // Construction must not panic; the name is the provider id.\n assert_eq!(DeepSeekLlm::new(\"k\").name(), \"deepseek\");\n assert_eq!(DeepSeekLlm::with_model(\"k\", \"custom\").name(), \"deepseek\");\n }\n}\n"}}}}