Class SpringAiLlmService

  • All Implemented Interfaces:
    com.embabel.agent.spi.LlmService , com.embabel.common.ai.model.AiModel , com.embabel.common.ai.model.LlmMetadata , com.embabel.common.ai.model.ModelMetadata , com.embabel.common.ai.prompt.PromptContributorConsumer , com.embabel.common.core.types.HasInfoString

    
    public final class SpringAiLlmService
     implements LlmService<SpringAiLlmService>, AiModel<ChatModel>
                        

    Spring AI implementation that provides decoupled LLM operations.

    Wraps a Spring AI ChatModel and provides the ability to create LlmMessageSender instances for making LLM calls without tight coupling to Spring AI throughout the codebase.

    This class is the recommended replacement for the deprecated com.embabel.common.ai.model.Llm class.

    • Constructor Detail

      • SpringAiLlmService

        SpringAiLlmService(String name, String provider, ChatModel chatModel, OptionsConverter<?> optionsConverter, LocalDate knowledgeCutoffDate, List<PromptContributor> promptContributors, PricingModel pricingModel)
        Parameters:
        name - Name of the LLM
        provider - Name of the provider (e.g.
        chatModel - The Spring AI ChatModel to use for LLM calls
        optionsConverter - Function to convert LlmOptions to Spring AI ChatOptions
        knowledgeCutoffDate - Model's knowledge cutoff date, if known
        promptContributors - List of prompt contributors for this model.
        pricingModel - Pricing model for this LLM, if known
      • SpringAiLlmService

        SpringAiLlmService(String name, String provider, ChatModel chatModel, OptionsConverter<?> optionsConverter, LocalDate knowledgeCutoffDate, List<PromptContributor> promptContributors)
        Parameters:
        name - Name of the LLM
        provider - Name of the provider (e.g.
        chatModel - The Spring AI ChatModel to use for LLM calls
        optionsConverter - Function to convert LlmOptions to Spring AI ChatOptions
        knowledgeCutoffDate - Model's knowledge cutoff date, if known
        promptContributors - List of prompt contributors for this model.
      • SpringAiLlmService

        SpringAiLlmService(String name, String provider, ChatModel chatModel, OptionsConverter<?> optionsConverter, LocalDate knowledgeCutoffDate)
        Parameters:
        name - Name of the LLM
        provider - Name of the provider (e.g.
        chatModel - The Spring AI ChatModel to use for LLM calls
        optionsConverter - Function to convert LlmOptions to Spring AI ChatOptions
        knowledgeCutoffDate - Model's knowledge cutoff date, if known
      • SpringAiLlmService

        SpringAiLlmService(String name, String provider, ChatModel chatModel, OptionsConverter<?> optionsConverter)
        Parameters:
        name - Name of the LLM
        provider - Name of the provider (e.g.
        chatModel - The Spring AI ChatModel to use for LLM calls
        optionsConverter - Function to convert LlmOptions to Spring AI ChatOptions
      • SpringAiLlmService

        SpringAiLlmService(String name, String provider, ChatModel chatModel)
        Parameters:
        name - Name of the LLM
        provider - Name of the provider (e.g.
        chatModel - The Spring AI ChatModel to use for LLM calls