Documentation
¶
Overview ¶
Package embeddings
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseRequestedTokens ¶ added in v0.19.0
ParseRequestedTokens extracts the token count a provider reports in an oversize message (e.g. "...however you requested 9523 tokens..."), returning 0 when no count is present.
Types ¶
type APIError ¶ added in v0.19.0
type APIError struct {
// Status is the HTTP status code, or 0 for a transport-level failure
// (connection refused, timeout) where no response was received.
Status int
// Code is the provider's machine error code when present (e.g.
// "context_length_exceeded"); empty when the provider omits it.
Code string
// Message is the provider's human-readable error message, or the
// transport error string when Status is 0.
Message string
// RequestedTokens is the token count the provider reported for the
// rejected input, parsed from Message; 0 when not reported.
RequestedTokens int
// Transient marks a transport-level failure (Status 0) as retryable.
Transient bool
}
APIError is a structured error from an embedding provider's HTTP API. It lets the embed pass tell three failure modes apart:
- oversize input (IsOversize) — the model rejected the text for exceeding its context window; the caller should chunk the input and embed the pieces rather than retry the whole thing.
- transient fault (Retryable) — a rate limit, server error, or transport failure; the same input may succeed on a later pass.
- any other deterministic rejection — neither of the above; retrying the same input is pointless, so the caller records it and stops.
It unwraps to vector.ErrEmbedding so existing errors.Is(err, vector.ErrEmbedding) checks keep working.
func AsAPIError ¶ added in v0.19.0
AsAPIError extracts an *APIError from err, if one is present in the chain.
func (*APIError) IsOversize ¶ added in v0.19.0
IsOversize reports whether the input was rejected for exceeding the model's context window — the signal to chunk the input and embed the pieces.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ollama implements pkg/embedding's Embedder client for Ollama's embedding APIs
|
Package ollama implements pkg/embedding's Embedder client for Ollama's embedding APIs |
|
Package openai implements pkg/embeddings's Embedder client for OpenAI's embeddings API.
|
Package openai implements pkg/embeddings's Embedder client for OpenAI's embeddings API. |
|
Package embeddingutils is the embeddings utility package
|
Package embeddingutils is the embeddings utility package |
Click to show internal directories.
Click to hide internal directories.