Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add llm_provider Deepseek #55

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions simplemind/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -18,6 +19,7 @@
Ollama,
XAI,
Amazon,
Deepseek,
]

__all__ = [
Expand All @@ -31,4 +33,5 @@
"providers",
"BaseProvider",
"BaseTool",
"Deepseek"
]
27 changes: 27 additions & 0 deletions simplemind/providers/deepseek.py
Original file line number Diff line number Diff line change
@@ -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)