Interface AiProviderClient

All Known Implementing Classes:
AnthropicClient, OllamaClient, OpenAiCompatibleClient

public interface AiProviderClient
Provider-specific client abstraction used to communicate with external AI inference services.

Implementations of this interface encapsulate the protocol and request formatting required to interact with a particular AI provider such as OpenAI, Ollama, Anthropic, or OpenRouter. The interface isolates the rest of the application from provider-specific details including authentication, endpoint layout, and response normalization.

Instances are typically created by the AI integration layer during initialization of the AiSuggestionEngine. Each client is responsible for transforming a class-level analysis request into the provider’s native API format and mapping the response back into the internal AiClassSuggestion representation used by the application.

Provider Responsibilities

  • constructing provider-specific HTTP requests
  • handling authentication and API keys
  • sending inference requests
  • parsing and validating AI responses
  • normalizing results into AiClassSuggestion

Implementations are expected to be stateless and thread-safe unless explicitly documented otherwise.

See Also:
  • Method Details

    • isAvailable

      boolean isAvailable()
      Determines whether the provider is reachable and usable in the current runtime environment.

      Implementations typically perform a lightweight availability check such as probing the provider's base endpoint or verifying that required configuration (for example, API keys or local services) is present.

      This method is primarily used when AiProvider.AUTO selection is enabled so the system can choose the first available provider.

      Returns:
      true if the provider appears available and ready to accept inference requests; false otherwise
    • suggestForClass

      AiClassSuggestion suggestForClass(String fqcn, String classSource, String taxonomyText, List<PromptBuilder.TargetMethod> targetMethods) throws AiSuggestionException
      Requests AI-based security classification for a parsed test class.

      The implementation submits the provided class source code together with the taxonomy specification to the underlying AI provider. The provider analyzes the class and produces structured classification results for the class itself and for each test method contained within the class.

      The response is normalized into an AiClassSuggestion instance containing both class-level metadata and a list of AiMethodSuggestion objects describing individual test methods.

      Parameters:
      fqcn - fully qualified name of the analyzed class
      classSource - complete source code of the class being analyzed
      taxonomyText - security taxonomy definition guiding the AI classification
      targetMethods - deterministically extracted JUnit test methods that must be classified
      Returns:
      normalized AI classification result
      Throws:
      AiSuggestionException - if the request fails due to provider errors, malformed responses, or communication failures
      See Also: