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
      Return the models this provider recognises.

      Model names are provider-specific (e.g., "gpt-4", "claude-3-opus", "llama2"). This is not a live query against the provider's API: an adapter may report a fixed list it ships with, so a model missing from it can still be requested by name — see LLMRequest.Builder.model(String) — it simply will not appear here.

      Specified by:
      getAvailableModels in interface LLMProvider
      Returns:
      CompletableFuture containing the model identifiers this provider recognises
    • 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()