Skip to content
Open
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
79 changes: 74 additions & 5 deletions src/content/docs/docs/integrations/deepseek.mdx
Original file line number Diff line number Diff line change
@@ -1,21 +1,90 @@
---
title: DeepSeek Plugin
description: Learn how to configure and use Genkit DeepSeek plugin to access DeepSeek models in JavaScript.
description: Learn how to configure and use Genkit DeepSeek plugin to access DeepSeek models in JavaScript and Go.
---

import LanguageSelector from '../../../../components/LanguageSelector.astro';
import CopyMarkdownButton from '../../../../components/CopyMarkdownButton.astro';
import LanguageContent from '../../../../components/LanguageContent.astro';

<div style="display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 1rem 0 1rem 0;">
<LanguageSelector supportedLanguages="js" />
<LanguageSelector supportedLanguages="js go" />
<CopyMarkdownButton />
</div>

<LanguageContent lang="go">
:::note[Feature unavailable for Go]
The DeepSeek plugin has not yet been made available for Go.
:::
The DeepSeek plugin provides access to DeepSeek models through OpenAI-compatible endpoints in Go.

## Configuration
```go
import "github.com/firebase/genkit/go/plugins/compat_oai/deepseek"
```
```go
g := genkit.Init(context.Background(), genkit.WithPlugins(&deepseek.DeepSeek{
Opts: []option.RequestOption{
option.WithAPIKey("DEEPSEEK_API_KEY"),
},
}))
```
You must provide an API key from DeepSeek. You can get an API key from the [DeepSeek Platform](https://platform.deepseek.com/sign_in)

## Supported Models
- `deepseek-chat`
- `deepseek-reasoner`

More information about the supported models and its capabilities can be found in the [DeepSeek API docs](https://api-docs.deepseek.com/quick_start/pricing)

## Usage Example
```go
import (
"context"
"math"

"github.com/firebase/genkit/go/ai"
"github.com/firebase/genkit/go/genkit"
oai_deepseek "github.com/firebase/genkit/go/plugins/compat_oai/deepseek"
"github.com/openai/openai-go"
)

func main() {
ctx := context.Background()

// DEEPSEEK_API_KEY and DEEPSEEK_BASE_URL environment values will be read automatically unless
// they are provided via `option.RequestOption{}`
g := genkit.Init(ctx,
genkit.WithPlugins(&oai_deepseek.DeepSeek{}),
genkit.WithDefaultModel("deepseek/deepseek-chat"))

// Define a tool for calculating gablorkens
gablorkenTool := genkit.DefineTool(g, "gablorken", "use when need to calculate a gablorken",
func(ctx *ai.ToolContext, input struct {
Value float64
Over float64
},
) (float64, error) {
return math.Pow(input.Value, input.Over), nil
},
)

genkit.DefineStreamingFlow(g, "streaming tool", func(ctx context.Context, input any, cb ai.ModelStreamCallback) (string, error) {
config := &openai.ChatCompletionNewParams{
Temperature: openai.Float(0.5),
}
resp, err := genkit.Generate(ctx,
g,
ai.WithPrompt("calculate the gablorken of value 3 over 5"),
ai.WithTools(gablorkenTool),
ai.WithStreaming(cb),
ai.WithConfig(config))
if err != nil {
return "", err
}
return resp.Text(), nil
})

<-ctx.Done()
}
```
</LanguageContent>

<LanguageContent lang="python">
Expand Down