diff --git a/simplemind/providers/__init__.py b/simplemind/providers/__init__.py index 1f92912..c588b5a 100644 --- a/simplemind/providers/__init__.py +++ b/simplemind/providers/__init__.py @@ -9,6 +9,7 @@ from .ollama import Ollama from .openai import OpenAI from .xai import XAI +from .deepseek import Deepseek providers: List[Type[BaseProvider]] = [ Anthropic, @@ -18,6 +19,7 @@ Ollama, XAI, Amazon, + Deepseek, ] __all__ = [ @@ -31,4 +33,5 @@ "providers", "BaseProvider", "BaseTool", + "Deepseek" ] diff --git a/simplemind/providers/deepseek.py b/simplemind/providers/deepseek.py new file mode 100644 index 0000000..07942b6 --- /dev/null +++ b/simplemind/providers/deepseek.py @@ -0,0 +1,27 @@ +import os +from functools import cached_property + +from .openai import OpenAI + + +class Deepseek(OpenAI): + NAME = "deepseek" + DEFAULT_MODEL = "deepseek-chat" + + def __init__(self, api_key: str | None = None): + api_key = api_key or os.getenv("DEEPSEEK_API_KEY") + super().__init__(api_key=api_key) + self.endpoint = "https://api.deepseek.com/v1" + + @cached_property + def client(self): + """The raw OpenAI client.""" + if not self.api_key: + raise ValueError("DEEPSEEK API key is required") + try: + import openai as oa + except ImportError as exc: + raise ImportError( + "Please install the `openai` package: `pip install openai`" + ) from exc + return oa.OpenAI(api_key=self.api_key, base_url=self.endpoint)