Skip to content

Add support for embedding generation #130

@Jameswlepage

Description

@Jameswlepage

Summary

Implement embedding generation capabilities as outlined in docs/ARCHITECTURE.md and the development roadmap (#8, milestone 0.4.0).

Embeddings enable vector representations of text/content for use with vector databases, semantic search, and similarity comparisons.

Scope

Domain Layer

  • Embedding DTO (src/Embeddings/DTO/Embedding.php) — vector validation, dimension helpers
  • EmbeddingResult implementing ResultInterface — carries embeddings, token usage, provider metadata
  • EmbeddingOperation for async/long-running embedding jobs

Builder & Client APIs

  • PromptBuilder::withEmbeddingInput(string|Message $input) — collect inputs for embedding
  • PromptBuilder::generateEmbeddingsResult() / generateEmbeddingsOperation() / generateEmbeddings()
  • Matching methods on AiClient for traditional API surface
  • Capability inference routes through CapabilityEnum::embeddingGeneration

Provider Contracts & Registry

  • EmbeddingGenerationModelInterface
  • EmbeddingGenerationOperationModelInterface
  • WithEmbeddingOperationsInterface
  • ProviderRegistry discovery for embedding-capable models

Provider Implementations

  • OpenAI embedding model metadata & adapter
  • Google / Anthropic stubs or implementations as available

Testing & CLI

  • Unit tests for DTOs, builder flows, client methods, provider adapters
  • Mock embedding model in test fixtures
  • CLI support (--capability=embeddings, output formats)

Documentation

  • README quick-start examples (fluent + traditional)
  • Architecture/requirements doc updates

Related

Open Questions

  1. Input shape for multiple documents — new withEmbeddingInputs() vs. reusing message stack?
  2. Helper transformers on EmbeddingResult (e.g., toVectors(), toAssociativeArray())?
  3. Provider-specific options (dimensions) — surface through ModelConfig / SupportedOption?

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature]New feature to highlight in changelogs.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions