Interface AiProviderClient
- All Known Implementing Classes:
AnthropicClient,OllamaClient,OpenAiCompatibleClient
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 Summary
Modifier and TypeMethodDescriptionbooleanDetermines whether the provider is reachable and usable in the current runtime environment.suggestForClass(String fqcn, String classSource, String taxonomyText, List<PromptBuilder.TargetMethod> targetMethods) Requests AI-based security classification for a parsed test class.
-
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.AUTOselection is enabled so the system can choose the first available provider.- Returns:
trueif the provider appears available and ready to accept inference requests;falseotherwise
-
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
AiClassSuggestioninstance containing both class-level metadata and a list ofAiMethodSuggestionobjects describing individual test methods.- Parameters:
fqcn- fully qualified name of the analyzed classclassSource- complete source code of the class being analyzedtaxonomyText- security taxonomy definition guiding the AI classificationtargetMethods- 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:
-