NAME

Langertha::Embedder - Embedding abstraction wrapping an engine with optional model override

VERSION

version 0.302

SYNOPSIS

use Langertha::Engine::OpenAI;
use Langertha::Embedder;

my $engine = Langertha::Engine::OpenAI->new(
    api_key => $ENV{OPENAI_API_KEY},
    model   => 'text-embedding-3-small',
);

my $embedder = Langertha::Embedder->new(
    engine  => $engine,
    plugins => ['Langfuse'],
);

my $vector = $embedder->simple_embedding('Hello world');

# Override model per-embedder
my $large = Langertha::Embedder->new(
    engine => $engine,
    model  => 'text-embedding-3-large',
);

DESCRIPTION

Langertha::Embedder wraps any engine that consumes Langertha::Role::Embedding and adds an optional model override plus plugin lifecycle hooks via Langertha::Role::PluginHost.

Use this class when you need multiple embedding configurations from the same engine instance, or when you want plugin observability (e.g. Langertha::Plugin::Langfuse) without modifying the engine.

engine

The LLM engine to delegate embedding requests to. Must consume Langertha::Role::Embedding.

model

Optional model name override. When set, overrides the engine's embedding_model for requests made through this Embedder.

simple_embedding

my $vector = $embedder->simple_embedding($text);

Returns the embedding vector for $text. If model is set, uses it as an override; otherwise delegates directly to the engine's simple_embedding. Plugin hooks plugin_before_embedding and plugin_after_embedding are fired around the request.

SEE ALSO

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/langertha/issues.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de> https://raudss.us/

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.