Skip to content

Add Ollama embedding client #235

@theantichris

Description

@theantichris

Summary

Add an embedding client to the LLM package that calls Ollama's /api/embed endpoint. This is the foundation for the memory system's vector search.

Details

New files:

  • internal/llm/embed.go
  • internal/llm/embed_test.go

Types:

  • EmbedRequest{Model, Input string}
  • EmbedResponse{Embeddings [][]float64}

Function:

  • Embed(ctx, host, model, input string) ([]float64, error) — POST to /api/embed using carlmjohnson/requests

Error:

  • ErrEmbed = errors.New("neural embedding generation failed")

Testing:

  • Table-driven tests with httptest.NewServer (same pattern as ollama_test.go)
  • Cases: successful embedding, model not found (404), unexpected status, empty input

Notes:

  • No changes to existing code
  • Follow the same HTTP pattern used in Chat() and StreamChat() in ollama.go
  • Use handleHTTPErrors() for consistent error handling

Acceptance Criteria

  • Embed() function returns embedding vector from Ollama
  • Proper error handling for 404 (model not found) and other HTTP errors
  • Table-driven tests pass with mocked Ollama endpoint
  • No changes to existing files

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions