diff --git a/src/content/docs/docs/integrations/deepseek.mdx b/src/content/docs/docs/integrations/deepseek.mdx index 1de5e628..400b01e9 100644 --- a/src/content/docs/docs/integrations/deepseek.mdx +++ b/src/content/docs/docs/integrations/deepseek.mdx @@ -1,6 +1,6 @@ --- 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'; @@ -8,14 +8,83 @@ import CopyMarkdownButton from '../../../../components/CopyMarkdownButton.astro' import LanguageContent from '../../../../components/LanguageContent.astro';
- +
- :::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() +} +```