Skip to content

Commit

Permalink
added a guide on how to use DeepSeek LLMs with aisuite
Browse files Browse the repository at this point in the history
  • Loading branch information
Riddhimaan-Senapati committed Jan 10, 2025
1 parent f4f51d8 commit 4e429e0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aisuite/providers/deepseek_provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import openai
import os
from aisuite.provider import Provider
from aisuite.provider import Provider, LLMError


class DeepseekProvider(Provider):
Expand Down
1 change: 1 addition & 0 deletions guides/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Here are the instructions for:
- [OpenAI](openai.md)
- [SambaNova](sambanova.md)
- [xAI](xai.md)
- [DeepSeek](deepseek.md)

Unless otherwise stated, these guides have not been endorsed by the providers.

Expand Down
46 changes: 46 additions & 0 deletions guides/deepseek.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# DeepSeek

To use DeepSeek with `aisuite`, you’ll need an [DeepSeek account](https://platform.deepseek.com). After logging in, go to the [API Keys](https://platform.deepseek.com/api_keys) section in your account settings and generate a new key. Once you have your key, add it to your environment as follows:

```shell
export DEEPSEEK_API_KEY="your-deepseek-api-key"
```

## Create a Chat Completion

(Note: The DeepSeek uses an API format consistent with OpenAI, hence why we need to install OpenAI, there is no DeepSeek Library at least not for now)

Install the `openai` Python client:

Example with pip:
```shell
pip install openai
```

Example with poetry:
```shell
poetry add openai
```

In your code:
```python
import aisuite as ai
client = ai.Client()

provider = "deepseek"
model_id = "deepseek-chat"

messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What’s the weather like in San Francisco?"},
]

response = client.chat.completions.create(
model=f"{provider}:{model_id}",
messages=messages,
)

print(response.choices[0].message.content)
```

Happy coding! If you’d like to contribute, please read our [Contributing Guide](../CONTRIBUTING.md).

0 comments on commit 4e429e0

Please sign in to comment.