Package com.tnsai.llm

Interface LLMClientProvider

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface LLMClientProvider
SPI for creating LLM clients from provider configuration.

This interface decouples the core framework from concrete LLM provider implementations. The tnsai-llm module provides the default implementation via SpiLoader.

Since:
0.0.2
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    create(String provider, String model, float temperature, Integer maxTokens, Float topP)
    Creates an LLM client from the given configuration.
    Discovers the first available LLMClientProvider via ServiceLoader.
  • Method Details

    • create

      LLMClient create(String provider, String model, float temperature, Integer maxTokens, Float topP)
      Creates an LLM client from the given configuration.
      Parameters:
      provider - the provider name (e.g., "ollama", "openai", "anthropic")
      model - the model name
      temperature - the sampling temperature (0.0-2.0)
      maxTokens - optional max tokens (null for provider default)
      topP - optional top-p nucleus sampling (null for provider default)
      Returns:
      the created LLM client
      Throws:
      IllegalArgumentException - if provider is unknown or model is empty
    • discover

      static Optional<LLMClientProvider> discover()
      Discovers the first available LLMClientProvider via ServiceLoader.
      Returns:
      the provider if available