Documentation
¶
Overview ¶
Package dsc provides deepseek client
Index ¶
- Variables
- type BalanceResponse
- type ChatRequest
- type ChatResponse
- type Choice
- type Client
- type Deepseek
- func (c *Deepseek) Balance() (*BalanceResponse, error)
- func (c *Deepseek) Chat(ctx context.Context, messages []prompt.Message, tools []toolcall.Tool) (*ChatResponse, error)
- func (c *Deepseek) FIM(ctx context.Context, req FIMRequest) (*FIMResponse, error)
- func (c *Deepseek) Models() (*ModelsResponse, error)
- type FIMChoice
- type FIMRequest
- type FIMResponse
- type FIMStreamChunk
- type FIMUsage
- type Model
- type ModelsResponse
- type Thinking
Constants ¶
This section is empty.
Variables ¶
DefaultMaxTokens 默认 max_tokens,可通过 config max-tokens 覆盖
V4Enabled deepseek-v4 专有参数开关,默认开启。
Functions ¶
This section is empty.
Types ¶
type BalanceResponse ¶
type ChatRequest ¶
type ChatRequest struct {
Model string `json:"model"`
Messages []prompt.Message `json:"messages"`
Tools []toolcall.Tool `json:"tools,omitzero"`
Stream bool `json:"stream"`
MaxTokens int `json:"max_tokens,omitzero"`
Thinking Thinking `json:"thinking"`
ReasoningEffort string `json:"reasoning_effort,omitzero"`
}
ChatRequest 扩展,支持 tools
type ChatResponse ¶
ChatResponse 响应
type Choice ¶
type Client ¶
type Client interface {
Models() (*ModelsResponse, error)
Balance() (*BalanceResponse, error)
FIM(ctx context.Context, req FIMRequest) (*FIMResponse, error)
Chat(ctx context.Context, messages []prompt.Message, tools []toolcall.Tool) (*ChatResponse, error)
}
type Deepseek ¶
type Deepseek struct {
// contains filtered or unexported fields
}
func (*Deepseek) Chat ¶
func (c *Deepseek) Chat(ctx context.Context, messages []prompt.Message, tools []toolcall.Tool) (*ChatResponse, error)
Chat 发送聊天请求
func (*Deepseek) FIM ¶
func (c *Deepseek) FIM(ctx context.Context, req FIMRequest) (*FIMResponse, error)
FIM 实现填充中间代码(Fill-In-the-Middle)功能。
通过 context.StreamKey 控制流式/非流式:
- false(默认):一次性返回完整补全结果
- true:通过 SSE 流式输出,实时打印补全内容
参考 API 文档: https://api.deepseek.com/beta/completions
type FIMChoice ¶
type FIMRequest ¶
type FIMRequest struct {
Model string `json:"model"`
Prompt string `json:"prompt"`
Suffix string `json:"suffix,omitzero"`
MaxTokens int `json:"max_tokens,omitzero"`
Temperature float64 `json:"temperature,omitzero"`
TopP float64 `json:"top_p,omitzero"`
Stream bool `json:"stream,omitzero"`
Echo bool `json:"echo,omitzero"`
Stop any `json:"stop,omitzero"`
}
FIMRequest FIM (Fill-In-the-Middle) completion request. For streaming, set Stream=true or use context.StreamKey.
type FIMResponse ¶
type FIMResponse struct {
ID string `json:"id"`
Choices []FIMChoice `json:"choices"`
Usage FIMUsage `json:"usage,omitzero"`
}
FIMResponse non-streaming FIM response.
type FIMStreamChunk ¶ added in v0.7.9
type FIMStreamChunk struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []FIMChoice `json:"choices"`
Usage *FIMUsage `json:"usage,omitzero"`
}
FIMStreamChunk SSE streaming response chunk for FIM.
type FIMUsage ¶ added in v0.7.9
type Model ¶
type ModelsResponse ¶
Source Files
¶
- client.go
- dsc.go
- dsc_chat.go
- dsc_chat_stream.go
- dsc_fim.go
Click to show internal directories.
Click to hide internal directories.