Class AbstractLLMClient

java.lang.Object
com.tnsai.llm.providers.AbstractLLMClient
All Implemented Interfaces:
com.tnsai.llm.LLMClient
Direct Known Subclasses:
AbstractOpenAICompatibleClient, AnthropicClient, CohereClient, GeminiClient, MiniMaxClient, OllamaClient, OpenAIClient, ReplicateClient, VertexAIClient, WatsonxClient, ZhipuAIClient

public abstract class AbstractLLMClient extends Object implements com.tnsai.llm.LLMClient
Abstract base class for LLM client implementations.

Provides common functionality for all LLM providers:

  • Retry configuration with standard defaults
  • Common retriable error detection
  • Injectable HTTP client (defaults to shared instance)
  • Standard model configuration fields

Usage


 public class MyLLMClient extends AbstractLLMClient {
     public MyLLMClient(String model, float temperature, Integer maxTokens, String apiKey) {
         super(model, temperature, maxTokens, apiKey, "MY_API_KEY", "https://api.example.com");
     }

     @Override
     public ChatResponse chat(String message, Optional<String> systemPrompt, ...) {
         // Implementation
     }
 }
 
Author:
TnsAI Team
  • Method Details

    • getBaseUrl

      public String getBaseUrl()
    • getCallTimeoutMs

      public int getCallTimeoutMs()
    • getModel

      public String getModel()
      Specified by:
      getModel in interface com.tnsai.llm.LLMClient
    • getTemperature

      public float getTemperature()
      Specified by:
      getTemperature in interface com.tnsai.llm.LLMClient
    • getTopP

      public Optional<Float> getTopP()
      Specified by:
      getTopP in interface com.tnsai.llm.LLMClient
    • getMaxTokens

      public Optional<Integer> getMaxTokens()
      Specified by:
      getMaxTokens in interface com.tnsai.llm.LLMClient