Files
mistral-go-sdk/option.go
vikingowl 6332108c4d feat: Phase 1 foundation — client, chat types, ChatComplete
Implement core SDK skeleton with full chat completion support:
- Client with functional options (base URL, HTTP client, timeout, retry)
- APIError with sentinel checkers (IsNotFound, IsRateLimit, IsAuth)
- Chat types: Message (sealed interface, 4 types), ContentChunk (sealed
  interface, 7 types), Content (string|null|chunks union), Tool, ToolCall,
  ToolChoice, ResponseFormat with custom JSON marshal/unmarshal
- CompletionRequest/Response with discriminated union dispatch
- ChatComplete method with httptest-based tests (54 tests, all passing)
2026-03-05 19:30:57 +01:00

39 lines
749 B
Go

package mistral
import (
"net/http"
"time"
)
// Option configures a Client.
type Option func(*Client)
// WithBaseURL sets the API base URL.
func WithBaseURL(url string) Option {
return func(c *Client) {
c.baseURL = url
}
}
// WithHTTPClient sets the underlying HTTP client.
func WithHTTPClient(client *http.Client) Option {
return func(c *Client) {
c.httpClient = client
}
}
// WithTimeout sets the HTTP client timeout.
func WithTimeout(d time.Duration) Option {
return func(c *Client) {
c.httpClient.Timeout = d
}
}
// WithRetry configures retry behavior for transient errors.
func WithRetry(maxRetries int, baseDelay time.Duration) Option {
return func(c *Client) {
c.maxRetries = maxRetries
c.retryDelay = baseDelay
}
}