Learn about the provider abstraction layer in Polyglot.
LLMProvider
and EmbeddingsProvider
- Builder classes for configuring and creating driversLLMProvider
class is a builder that configures and creates inference drivers. It provides a fluent interface for setting up LLM configurations:
withLLMPreset(string $preset)
: Set configuration presetwithConfig(LLMConfig $config)
: Set explicit configurationwithConfigOverrides(array $overrides)
: Override specific config valueswithDsn(string $dsn)
: Configure via DSN stringwithHttpClient(HttpClient $client)
: Set custom HTTP clientwithDriver(CanHandleInference $driver)
: Set explicit drivercreateDriver()
: Build and return the configured driverEmbeddingsProvider
class builds and configures embeddings drivers:
withPreset(string $preset)
: Set configuration presetwithConfig(EmbeddingsConfig $config)
: Set explicit configurationwithDsn(string $dsn)
: Configure via DSN stringwithHttpClient(HttpClient $client)
: Set custom HTTP clientwithDriver(CanHandleVectorization $driver)
: Set explicit drivercreateDriver()
: Build and return the configured driverModularLLMDriver
is a central component that implements the CanHandleInference
interface using adapters:
InferenceDriverFactory
creates the appropriate driver for each LLM provider:
EmbeddingsDriverFactory
creates embeddings drivers: