-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdeepseek.go
60 lines (48 loc) · 2.28 KB
/
deepseek.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package deepseek
import (
"context"
"github.com/go-deepseek/deepseek/client"
"github.com/go-deepseek/deepseek/config"
"github.com/go-deepseek/deepseek/request"
"github.com/go-deepseek/deepseek/response"
)
const DEFAULT_TIMEOUT_SECONDS = 120
const (
DEEPSEEK_CHAT_MODEL = "deepseek-chat"
DEEPSEEK_REASONER_MODEL = "deepseek-reasoner"
)
// Client interface defines methods for interacting with the DeepSeek API.
type Client interface {
// CallChatCompletionsChat calls chat api with model=deepseek-chat and stream=false.
// It returns response from DeepSeek-V3 model.
CallChatCompletionsChat(ctx context.Context, chatReq *request.ChatCompletionsRequest) (*response.ChatCompletionsResponse, error)
// CallChatCompletionsReasoner calls chat api with model=deepseek-reasoner and stream=false.
// It returns response from DeepSeek-R1 model.
CallChatCompletionsReasoner(ctx context.Context, chatReq *request.ChatCompletionsRequest) (*response.ChatCompletionsResponse, error)
// StreamChatCompletionsChat calls chat api with model=deepseek-chat and stream=true.
// It returns response from DeepSeek-V3 model.
StreamChatCompletionsChat(ctx context.Context, chatReq *request.ChatCompletionsRequest) (response.StreamReader, error)
// StreamChatCompletionsReasoner calls chat api with model=deepseek-reasoner and stream=true.
// It returns response from DeepSeek-R1 model.
StreamChatCompletionsReasoner(ctx context.Context, chatReq *request.ChatCompletionsRequest) (response.StreamReader, error)
// PingChatCompletions is a ping to check go deepseek client is working fine.
PingChatCompletions(ctx context.Context, inputMessage string) (outputMessge string, err error)
}
// NewClient returns deeseek client which uses given deepseek API key.
func NewClient(apiKey string) (Client, error) {
config := NewConfigWithDefaults()
config.ApiKey = apiKey
return NewClientWithConfig(config)
}
// NewClientWithConfig returns deeseek client with given client config.
func NewClientWithConfig(config config.Config) (Client, error) {
return client.NewClient(config)
}
// NewConfigWithDefaults returns client config with default values.
func NewConfigWithDefaults() config.Config {
config := config.Config{
TimeoutSeconds: DEFAULT_TIMEOUT_SECONDS,
DisableRequestValidation: false,
}
return config
}