Documentation
¶
Index ¶
- Constants
- type ChatCompletionRequest
- type ChatCompletionResponse
- type Choice
- type DeepSeekClient
- func (c *DeepSeekClient) Generate(ctx context.Context, prompt string, options ...interfaces.GenerateOption) (string, error)
- func (c *DeepSeekClient) GenerateDetailed(ctx context.Context, prompt string, options ...interfaces.GenerateOption) (*interfaces.LLMResponse, error)
- func (c *DeepSeekClient) GenerateStream(ctx context.Context, prompt string, options ...interfaces.GenerateOption) (<-chan interfaces.StreamEvent, error)
- func (c *DeepSeekClient) GenerateWithTools(ctx context.Context, prompt string, tools []interfaces.Tool, ...) (string, error)
- func (c *DeepSeekClient) GenerateWithToolsDetailed(ctx context.Context, prompt string, tools []interfaces.Tool, ...) (*interfaces.LLMResponse, error)
- func (c *DeepSeekClient) GenerateWithToolsStream(ctx context.Context, prompt string, tools []interfaces.Tool, ...) (<-chan interfaces.StreamEvent, error)
- func (c *DeepSeekClient) Name() string
- func (c *DeepSeekClient) SupportsStreaming() bool
- type FunctionCall
- type FunctionDef
- type Message
- type Option
- type ResponseFormatParam
- type StreamChoice
- type StreamChunk
- type StreamDelta
- type Tool
- type ToolCall
- type ToolResult
- type Usage
Constants ¶
const ( // DefaultBaseURL is the default DeepSeek API base URL DefaultBaseURL = "https://api.deepseek.com" // DefaultModel is the default DeepSeek model DefaultModel = "deepseek-chat" // DefaultMaxIterations is the default maximum number of tool calling iterations DefaultMaxIterations = 10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
PresencePenalty float64 `json:"presence_penalty,omitempty"`
Stop []string `json:"stop,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Stream bool `json:"stream,omitempty"`
Tools []Tool `json:"tools,omitempty"`
ToolChoice interface{} `json:"tool_choice,omitempty"`
ResponseFormat *ResponseFormatParam `json:"response_format,omitempty"`
}
ChatCompletionRequest represents a request to the DeepSeek Chat Completion API
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []Choice `json:"choices"`
Usage Usage `json:"usage"`
}
ChatCompletionResponse represents a response from the DeepSeek Chat Completion API
type Choice ¶
type Choice struct {
Index int `json:"index"`
Message Message `json:"message"`
FinishReason string `json:"finish_reason"`
}
Choice represents a completion choice
type DeepSeekClient ¶
type DeepSeekClient struct {
APIKey string
Model string
BaseURL string
HTTPClient *http.Client
// contains filtered or unexported fields
}
DeepSeekClient implements the LLM interface for DeepSeek
func NewClient ¶
func NewClient(apiKey string, options ...Option) *DeepSeekClient
NewClient creates a new DeepSeek client
func (*DeepSeekClient) Generate ¶
func (c *DeepSeekClient) Generate(ctx context.Context, prompt string, options ...interfaces.GenerateOption) (string, error)
Generate generates text based on the provided prompt
func (*DeepSeekClient) GenerateDetailed ¶
func (c *DeepSeekClient) GenerateDetailed(ctx context.Context, prompt string, options ...interfaces.GenerateOption) (*interfaces.LLMResponse, error)
GenerateDetailed generates text and returns detailed response information including token usage
func (*DeepSeekClient) GenerateStream ¶
func (c *DeepSeekClient) GenerateStream( ctx context.Context, prompt string, options ...interfaces.GenerateOption, ) (<-chan interfaces.StreamEvent, error)
GenerateStream implements interfaces.StreamingLLM.GenerateStream
func (*DeepSeekClient) GenerateWithTools ¶
func (c *DeepSeekClient) GenerateWithTools(ctx context.Context, prompt string, tools []interfaces.Tool, options ...interfaces.GenerateOption) (string, error)
GenerateWithTools implements interfaces.LLM.GenerateWithTools
func (*DeepSeekClient) GenerateWithToolsDetailed ¶
func (c *DeepSeekClient) GenerateWithToolsDetailed(ctx context.Context, prompt string, tools []interfaces.Tool, options ...interfaces.GenerateOption) (*interfaces.LLMResponse, error)
GenerateWithToolsDetailed implements interfaces.LLM.GenerateWithToolsDetailed
func (*DeepSeekClient) GenerateWithToolsStream ¶
func (c *DeepSeekClient) GenerateWithToolsStream( ctx context.Context, prompt string, tools []interfaces.Tool, options ...interfaces.GenerateOption, ) (<-chan interfaces.StreamEvent, error)
GenerateWithToolsStream implements interfaces.StreamingLLM.GenerateWithToolsStream with iterative tool calling
func (*DeepSeekClient) Name ¶
func (c *DeepSeekClient) Name() string
Name returns the name of the LLM provider
func (*DeepSeekClient) SupportsStreaming ¶
func (c *DeepSeekClient) SupportsStreaming() bool
SupportsStreaming returns true if this LLM supports streaming
type FunctionCall ¶
FunctionCall represents a function call
type FunctionDef ¶
type FunctionDef struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters interface{} `json:"parameters"`
}
FunctionDef represents a function definition
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
Name string `json:"name,omitempty"`
}
Message represents a message in the chat
type Option ¶
type Option func(*DeepSeekClient)
Option represents an option for configuring the DeepSeek client
func WithBaseURL ¶
WithBaseURL sets the base URL for the DeepSeek client
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client
func WithLogger ¶
WithLogger sets the logger for the DeepSeek client
type ResponseFormatParam ¶
type ResponseFormatParam struct {
Type string `json:"type"`
JSONSchema interface{} `json:"json_schema,omitempty"`
}
ResponseFormatParam represents the response format parameter
type StreamChoice ¶
type StreamChoice struct {
Index int `json:"index"`
Delta StreamDelta `json:"delta"`
FinishReason string `json:"finish_reason,omitempty"`
}
StreamChoice represents a choice in a streaming response
type StreamChunk ¶
type StreamChunk struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []StreamChoice `json:"choices"`
Usage *Usage `json:"usage,omitempty"`
}
StreamChunk represents a chunk from the DeepSeek streaming API
type StreamDelta ¶
type StreamDelta struct {
Role string `json:"role,omitempty"`
Content string `json:"content,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}
StreamDelta represents the delta content in a streaming chunk
type Tool ¶
type Tool struct {
Type string `json:"type"`
Function FunctionDef `json:"function"`
}
Tool represents a tool/function definition
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function FunctionCall `json:"function"`
}
ToolCall represents a tool call in the response
type ToolResult ¶
ToolResult represents the result of a tool execution