Class AnthropicProvider

java.lang.Object
dev.agenor.adapters.llm.anthropic.AnthropicProvider
All Implemented Interfaces:
LLMProvider

public class AnthropicProvider extends Object implements LLMProvider
  • Method Details

    • chat

      public CompletableFuture<LLMResponse> chat(LLMRequest request)
      Description copied from interface: LLMProvider
      Send a chat completion request to the LLM.

      This is the primary method for interacting with the LLM. It sends a request containing messages and configuration, and returns a response asynchronously.

      Specified by:
      chat in interface LLMProvider
      Returns:
      CompletableFuture containing the LLM response
    • chatStream

      public CompletableFuture<Void> chatStream(LLMRequest request, Consumer<StreamingChunk> handler)
      Description copied from interface: LLMProvider
      Stream a chat completion request to the LLM.

      Similar to LLMProvider.chat(LLMRequest), but provides streaming updates as the response is generated. This is useful for long responses where you want to show incremental progress to users.

      Example usage:

      
       provider.chatStream(request, chunk -> {
           System.out.print(chunk.content());
       }).thenRun(() -> {
           System.out.println("\nStreaming complete");
       });
       
      Specified by:
      chatStream in interface LLMProvider
      Returns:
      CompletableFuture that completes when streaming is finished
    • getAvailableModels

      public CompletableFuture<List<String>> getAvailableModels()
      Description copied from interface: LLMProvider
      Get the list of available models from this provider.

      Returns a list of model identifiers that can be used with this provider. Model names are provider-specific (e.g., "gpt-4", "claude-3-opus", "llama2").

      Specified by:
      getAvailableModels in interface LLMProvider
      Returns:
      CompletableFuture containing list of available model names
    • getProviderName

      public String getProviderName()
      Description copied from interface: LLMProvider
      Get the name of this provider.

      Returns a human-readable identifier for this provider, such as "OpenAI", "Anthropic", or "Ollama".

      Specified by:
      getProviderName in interface LLMProvider
      Returns:
      the provider name
    • getDefaultModel

      public String getDefaultModel()
      Description copied from interface: LLMProvider
      Get the default model for this provider.

      Returns a reasonable default model that can be used if the user doesn't specify one. This should be a balanced model that works well for general purposes.

      Specified by:
      getDefaultModel in interface LLMProvider
      Returns:
      the default model name, or null if no default is available
    • builder

      public static AnthropicProvider.Builder builder()