Documentation
¶
Overview ¶
Package deepseek provides a Genkit plugin for DeepSeek's models.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ModelRef ¶
func ModelRef(id string, config *ChatConfig) ai.ModelRef
ModelRef names a DeepSeek model and carries the config to generate with, so the config is typed at the call site instead of an any the model checks at runtime. A nil config leaves the request's config unset.
ai.WithModel(deepseek.ModelRef("deepseek-v4-pro", &deepseek.ChatConfig{
Thinking: &deepseek.ThinkingConfig{Type: "disabled"},
}))
id is the model ID, with or without the provider prefix.
Types ¶
type ChatConfig ¶
type ChatConfig struct {
compat_oai.RequestConfig
// Temperature controls the degree of randomness in token selection, from
// 0 to 2; DeepSeek's default is 1.
Temperature *float64 `` /* 178-byte string literal not displayed */
// TopP is the nucleus sampling threshold, up to 1.
TopP *float64 `json:"topP,omitempty" jsonschema:"maximum=1" jsonschema_description:"Nucleus sampling threshold, up to 1."`
// MaxOutputTokens is the maximum number of tokens to generate, sent as the
// API's max_tokens.
MaxOutputTokens int `` /* 148-byte string literal not displayed */
// StopSequences stop generation when produced by the model, up to sixteen.
StopSequences []string `` /* 149-byte string literal not displayed */
// LogProbs requests log probabilities for the output tokens.
LogProbs *bool `json:"logProbs,omitempty" jsonschema_description:"Requests log probabilities for the output tokens."`
// TopLogProbs is how many of the most likely tokens to return log
// probabilities for at each position, from 0 to 20; it requires LogProbs.
TopLogProbs *int `` /* 205-byte string literal not displayed */
// UserID identifies the end user a request is made on behalf of, up to 512
// characters of [a-zA-Z0-9_-]. DeepSeek partitions its context cache by
// this ID, so end users neither read nor evict each other's cached
// prefixes; sent as the API's user_id, not OpenAI's user.
UserID string `` /* 297-byte string literal not displayed */
// ReasoningEffort adjusts how hard the model thinks, [ReasoningEffortLow]
// to [ReasoningEffortMax]; DeepSeek's default is high. Sent as the API's
// top-level reasoning_effort: the create-chat-completion reference also
// documents it nested inside thinking, but the service silently ignores it
// there and reads only the top-level field the thinking-mode guide's
// examples use.
ReasoningEffort ReasoningEffort `` /* 172-byte string literal not displayed */
// Thinking controls the thinking mode of DeepSeek models, which is on by
// default; sent as the API's thinking field.
Thinking *ThinkingConfig `json:"thinking,omitempty" jsonschema_description:"Thinking mode controls, on by default; sent as the API's thinking field."`
}
ChatConfig is the per-request config for DeepSeek models: the generation fields DeepSeek accepts plus its thinking controls. See https://api-docs.deepseek.com/api/create-chat-completion.
DeepSeek no longer supports the frequency and presence penalties, so those are deliberately absent.
func (ChatConfig) ApplyToChatCompletion ¶
func (c ChatConfig) ApplyToChatCompletion(params *openai.ChatCompletionNewParams)
ApplyToChatCompletion implements compat_oai.ChatConfig: the generation fields land on their chat completion counterparts, MaxOutputTokens on the max_tokens DeepSeek reads, ReasoningEffort on the SDK's reasoning_effort, and the fields DeepSeek names differently than OpenAI, thinking and user_id, ride as extra request fields.
type DeepSeek ¶
type DeepSeek struct {
// APIKey is the DeepSeek API key. If empty, DEEPSEEK_API_KEY is consulted.
APIKey string
// Opts contains additional OpenAI client request options, such as
// [option.WithBaseURL] for a different endpoint, e.g. DeepSeek's beta one
// (DEEPSEEK_BASE_URL works too). Options supplied here are applied after
// the plugin defaults, so they win on overlap.
Opts []option.RequestOption
// Models overrides what the plugin knows about a DeepSeek model, keyed by
// model ID, bare or provider-prefixed. Every DeepSeek model already works
// without an entry: known IDs carry curated capabilities and the rest take
// the DeepSeek defaults. Supply an entry only to correct or extend what the
// plugin resolves, most often for a model released after this version of
// the plugin.
//
// &deepseek.DeepSeek{Models: map[string]ai.ModelOptions{
// "deepseek-v4-pro": {Supports: &ai.ModelSupports{Multiturn: true, Tools: true}},
// }}
//
// Fields left at their zero value keep what the plugin resolves, so an
// entry can pin one capability without restating the label or the
// versions. Entries apply to the models Init registers as well as the
// ones [DeepSeek.ListActions] advertises and [DeepSeek.ResolveAction] builds,
// which is the way to describe a curated model differently: Init has
// already registered those and nothing can re-register them.
Models map[string]ai.ModelOptions
// contains filtered or unexported fields
}
DeepSeek configures the DeepSeek plugin.
func (*DeepSeek) ListActions ¶
func (d *DeepSeek) ListActions(ctx context.Context) []api.ActionDesc
ListActions lists the models the configured DeepSeek endpoint exposes, described by the plugin's config schema and capabilities.
func (*DeepSeek) ResolveAction ¶
ResolveAction dynamically builds a model exposed by the DeepSeek endpoint, described by the plugin's config schema and capabilities.
type ReasoningEffort ¶
type ReasoningEffort string
ReasoningEffort is how hard a DeepSeek model thinks before it answers.
const ( // ReasoningEffortLow is the fastest, shallowest reasoning. ReasoningEffortLow ReasoningEffort = "low" // ReasoningEffortHigh is deeper reasoning. ReasoningEffortHigh ReasoningEffort = "high" // ReasoningEffortMax is the deepest reasoning. ReasoningEffortMax ReasoningEffort = "max" )
type ThinkingConfig ¶
type ThinkingConfig struct {
// Type turns thinking [ThinkingTypeEnabled] or [ThinkingTypeDisabled].
Type ThinkingType `json:"type,omitempty" jsonschema:"enum=enabled,enum=disabled" jsonschema_description:"Turns thinking enabled or disabled."`
}
ThinkingConfig configures the thinking mode of DeepSeek models.
type ThinkingType ¶
type ThinkingType string
ThinkingType turns the thinking mode of DeepSeek models on or off.
const ( // ThinkingTypeEnabled turns thinking on, which is DeepSeek's default. ThinkingTypeEnabled ThinkingType = "enabled" // ThinkingTypeDisabled turns thinking off. ThinkingTypeDisabled ThinkingType = "disabled" )