Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatRequest ¶
type ChatRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
MaxTokens *int `json:"max_tokens,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
}
ChatRequest is a non-streaming chat completion request.
type ChatResponse ¶
type ChatResponse struct {
Choices []struct {
Message Message `json:"message"`
} `json:"choices"`
Usage *ChatUsage `json:"usage,omitempty"`
Error *struct {
Message string `json:"message"`
} `json:"error,omitempty"`
}
ChatResponse mirrors the OpenAI chat completion response (non-streaming).
type ChatUsage ¶ added in v0.2.0
type ChatUsage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
PromptCacheHitTokens int `json:"prompt_cache_hit_tokens"`
PromptCacheMissTokens int `json:"prompt_cache_miss_tokens"`
}
ChatUsage is the token accounting block of an OpenAI-compatible response. PromptCacheHitTokens is the DeepSeek prompt_cache_hit_tokens field (input tokens served from the provider's prompt cache — the direct cost saving).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a fully-configurable OpenAI-compatible chat client.
func New ¶
New creates a chat client from config. apiKey is resolved from the config's declared env var at construction time.
func (*Client) ChatJSON ¶
ChatJSON asks the model to produce a JSON payload and unmarshals it into out.
func (*Client) SetTracker ¶ added in v0.2.0
SetTracker wires an optional usage tracker; token deltas are reported after every completion.
type Embedder ¶
type Embedder struct {
// contains filtered or unexported fields
}
Embedder produces vector embeddings for text via an OpenAI-compatible embeddings endpoint. Fully configurable (base_url/key/model/dimensions).
func NewEmbedder ¶
func NewEmbedder(cfg config.EmbeddingConfig) *Embedder
NewEmbedder creates an embedding client from config.
func (*Embedder) Dimensions ¶
Dimensions returns the configured vector dimensionality.
func (*Embedder) EmbedBatch ¶
EmbedBatch computes embeddings for multiple texts in one request.
func (*Embedder) SetTracker ¶ added in v0.2.0
SetTracker wires an optional usage tracker; embedding input tokens are reported after every request.