Skip to content

Commit

Permalink
Merge pull request #55 from jin10086/deepseek
Browse files Browse the repository at this point in the history
add llm_provider  Deepseek
  • Loading branch information
kennethreitz authored Jan 27, 2025
2 parents 391bfaa + d963bc0 commit 752ccb1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
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)

0 comments on commit 752ccb1

Please sign in to comment.