forked from NoFxAiOS/nofx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.go
More file actions
162 lines (141 loc) · 3.92 KB
/
Copy pathoptions.go
File metadata and controls
162 lines (141 loc) · 3.92 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package mcp
import (
"net/http"
"time"
)
// ClientOption client option function (Functional Options pattern)
type ClientOption func(*Config)
// ============================================================
// Dependency Injection Options
// ============================================================
// WithLogger sets custom logger
//
// Usage example:
// client := mcp.NewClient(mcp.WithLogger(customLogger))
func WithLogger(logger Logger) ClientOption {
return func(c *Config) {
c.Logger = logger
}
}
// WithHTTPClient sets custom HTTP client
//
// Usage example:
// httpClient := &http.Client{Timeout: 60 * time.Second}
// client := mcp.NewClient(mcp.WithHTTPClient(httpClient))
func WithHTTPClient(client *http.Client) ClientOption {
return func(c *Config) {
c.HTTPClient = client
}
}
// ============================================================
// Timeout and Retry Options
// ============================================================
// WithTimeout sets request timeout duration
//
// Usage example:
// client := mcp.NewClient(mcp.WithTimeout(60 * time.Second))
func WithTimeout(timeout time.Duration) ClientOption {
return func(c *Config) {
c.Timeout = timeout
c.HTTPClient.Timeout = timeout
}
}
// WithMaxRetries sets maximum retry count
//
// Usage example:
// client := mcp.NewClient(mcp.WithMaxRetries(5))
func WithMaxRetries(maxRetries int) ClientOption {
return func(c *Config) {
c.MaxRetries = maxRetries
}
}
// WithRetryWaitBase sets base retry wait duration
//
// Usage example:
// client := mcp.NewClient(mcp.WithRetryWaitBase(3 * time.Second))
func WithRetryWaitBase(waitTime time.Duration) ClientOption {
return func(c *Config) {
c.RetryWaitBase = waitTime
}
}
// ============================================================
// AI Parameter Options
// ============================================================
// WithMaxTokens sets maximum token count
//
// Usage example:
// client := mcp.NewClient(mcp.WithMaxTokens(4000))
func WithMaxTokens(maxTokens int) ClientOption {
return func(c *Config) {
c.MaxTokens = maxTokens
}
}
// WithTemperature sets temperature parameter
//
// Usage example:
// client := mcp.NewClient(mcp.WithTemperature(0.7))
func WithTemperature(temperature float64) ClientOption {
return func(c *Config) {
c.Temperature = temperature
}
}
// ============================================================
// Provider Configuration Options
// ============================================================
// WithAPIKey sets API Key
func WithAPIKey(apiKey string) ClientOption {
return func(c *Config) {
c.APIKey = apiKey
}
}
// WithBaseURL sets base URL
func WithBaseURL(baseURL string) ClientOption {
return func(c *Config) {
c.BaseURL = baseURL
}
}
// WithModel sets model name
func WithModel(model string) ClientOption {
return func(c *Config) {
c.Model = model
}
}
// WithProvider sets provider
func WithProvider(provider string) ClientOption {
return func(c *Config) {
c.Provider = provider
}
}
// WithUseFullURL sets whether to use full URL
func WithUseFullURL(useFullURL bool) ClientOption {
return func(c *Config) {
c.UseFullURL = useFullURL
}
}
// ============================================================
// Combined Options (Convenience Methods)
// ============================================================
// WithDeepSeekConfig sets DeepSeek configuration
//
// Usage example:
// client := mcp.NewClient(mcp.WithDeepSeekConfig("sk-xxx"))
func WithDeepSeekConfig(apiKey string) ClientOption {
return func(c *Config) {
c.Provider = ProviderDeepSeek
c.APIKey = apiKey
c.BaseURL = DefaultDeepSeekBaseURL
c.Model = DefaultDeepSeekModel
}
}
// WithQwenConfig sets Qwen configuration
//
// Usage example:
// client := mcp.NewClient(mcp.WithQwenConfig("sk-xxx"))
func WithQwenConfig(apiKey string) ClientOption {
return func(c *Config) {
c.Provider = ProviderQwen
c.APIKey = apiKey
c.BaseURL = DefaultQwenBaseURL
c.Model = DefaultQwenModel
}
}