Documentation
¶
Index ¶
- Constants
- func GetReasoningContent(message *schema.Message) (string, bool)
- func HasPrefix(message *schema.Message) bool
- func SetPrefix(message *schema.Message)
- func SetReasoningContent(message *schema.Message, content string)
- func WithExtraFields(extraFields map[string]interface{}) model.Option
- type ChatModel
- func (cm *ChatModel) BindForcedTools(tools []*schema.ToolInfo) error
- func (cm *ChatModel) BindTools(tools []*schema.ToolInfo) error
- func (cm *ChatModel) Generate(ctx context.Context, in []*schema.Message, opts ...model.Option) (outMsg *schema.Message, err error)
- func (cm *ChatModel) GetType() string
- func (cm *ChatModel) IsCallbacksEnabled() bool
- func (cm *ChatModel) Stream(ctx context.Context, in []*schema.Message, opts ...model.Option) (outStream *schema.StreamReader[*schema.Message], err error)
- func (cm *ChatModel) WithTools(tools []*schema.ToolInfo) (model.ToolCallingChatModel, error)
- type ChatModelConfig
- type ResponseFormatType
- type ThinkingConfig
Constants ¶
View Source
const ( ResponseFormatTypeText = "text" ResponseFormatTypeJSONObject = "json_object" )
Variables ¶
This section is empty.
Functions ¶
func SetReasoningContent ¶
func WithExtraFields ¶
WithExtraFields returns a request-level option that merges the provided key/value pairs into the top-level JSON payload sent to the DeepSeek API.
Keys that collide with fields already populated by this component (e.g. "model", "messages", "temperature", "thinking", ...) will override them, which mirrors the behavior of the underlying deepseek-go SDK.
Passing a nil or empty map is a no-op.
Example:
msg, err := cm.Generate(ctx, in,
deepseek.WithExtraFields(map[string]interface{}{
"chat_template_kwargs": map[string]interface{}{
"thinking": true,
},
}),
)
Types ¶
type ChatModel ¶
type ChatModel struct {
// contains filtered or unexported fields
}
func NewChatModel ¶
func NewChatModel(_ context.Context, config *ChatModelConfig) (*ChatModel, error)
func (*ChatModel) BindForcedTools ¶
func (*ChatModel) IsCallbacksEnabled ¶
type ChatModelConfig ¶
type ChatModelConfig struct {
// APIKey is your authentication key
// Required
APIKey string `json:"api_key"`
// Timeout specifies the maximum duration to wait for API responses
// Optional. Default: 5 minutes
Timeout time.Duration `json:"timeout"`
// HTTPClient specifies the client to send HTTP requests.
// Optional. Default http.DefaultClient
HTTPClient *http.Client `json:"http_client"`
// BaseURL is your custom deepseek endpoint url
// Optional. Default: https://api.deepseek.com/
BaseURL string `json:"base_url"`
// Path sets the path for the API request. Defaults to "chat/completions", if not set.
// Example usages would be "/c/chat/" or any http after the baseURL extension
Path string `json:"path"`
// Model specifies the ID of the model to use
// Required
Model string `json:"model"`
// MaxTokens limits the maximum number of tokens that can be generated in the chat completion
// Range: [1, 8192].
// Optional. Default: 4096
MaxTokens int `json:"max_tokens,omitempty"`
// Temperature specifies what sampling temperature to use
// Generally recommend altering this or TopP but not both.
// Range: [0.0, 2.0]. Higher values make output more random
// Optional. Default: 1.0
Temperature float32 `json:"temperature,omitempty"`
// TopP controls diversity via nucleus sampling
// Generally recommend altering this or Temperature but not both.
// Range: [0.0, 1.0]. Lower values make output more focused
// Optional. Default: 1.0
TopP float32 `json:"top_p,omitempty"`
// Stop sequences where the API will stop generating further tokens
// Optional. Example: []string{"\n", "User:"}
Stop []string `json:"stop,omitempty"`
// PresencePenalty prevents repetition by penalizing tokens based on presence
// Range: [-2.0, 2.0]. Positive values increase likelihood of new topics
// Optional. Default: 0
PresencePenalty float32 `json:"presence_penalty,omitempty"`
// ResponseFormat specifies the format of the model's response
// Optional. Use for structured outputs
ResponseFormatType ResponseFormatType `json:"response_format_type,omitempty"`
// FrequencyPenalty prevents repetition by penalizing tokens based on frequency
// Range: [-2.0, 2.0]. Positive values decrease likelihood of repetition
// Optional. Default: 0
FrequencyPenalty float32 `json:"frequency_penalty,omitempty"`
// LogProbs specifies whether to return log probabilities of the output tokens.
LogProbs bool `json:"log_probs"`
// TopLogProbs specifies the number of most likely tokens to return at each token position, each with an associated log probability.
TopLogProbs int `json:"top_log_probs"`
// ThinkingConfig controls the switch between thinking and non-thinking mode.
ThinkingConfig *ThinkingConfig `json:"thinking_config,omitempty"`
}
type ResponseFormatType ¶
type ResponseFormatType string
type ThinkingConfig ¶
type ThinkingConfig = deepseek.ThinkingConfig
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
generate
command
|
|
|
generate_with_prefix
command
|
|
|
intent_tool
command
|
|
|
stream
command
|
|
|
tool_call_reasoning
command
|
Click to show internal directories.
Click to hide internal directories.