Documentation
¶
Index ¶
Constants ¶
const DefaultEndpoint = "http://localhost:11434"
DefaultEndpoint is the default Ollama API endpoint.
const DefaultModel = "nomic-embed-text"
DefaultModel is the default Ollama embedding model.
Variables ¶
This section is empty.
Functions ¶
func CosineSimilarity ¶
CosineSimilarity computes the cosine similarity between two vectors. Returns 0 if either vector is zero-length or has zero magnitude.
func DeserializeLegacyVector ¶
DeserializeLegacyVector decodes a pre-migration little-endian float64 blob.
func DeserializeVector ¶
DeserializeVector decodes a little-endian float32 blob into a float64 slice.
func SerializeVector ¶
SerializeVector encodes a vector as a little-endian float32 blob.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with an Ollama instance for embedding generation.
func NewClient ¶
func NewClient() *Client
NewClient creates an Ollama embedding client. It checks MNEMON_EMBED_ENDPOINT, MNEMON_EMBED_MODEL, and MNEMON_EMBED_DIMENSIONS env vars.
func NewClientWithModel ¶
NewClientWithModel creates an Ollama embedding client with an explicit model override. Resolution order for the model: explicit argument > MNEMON_EMBED_MODEL env var > DefaultModel. The endpoint and dimensions continue to be resolved from MNEMON_EMBED_ENDPOINT and MNEMON_EMBED_DIMENSIONS env vars.
func (*Client) Available ¶
Available returns true if the Ollama server is reachable and the model is loaded. Uses a 2s timeout to avoid blocking the CLI on unresponsive servers.