Package io.jenkins.plugins.explain_error
Class BaseAIService
java.lang.Object
io.jenkins.plugins.explain_error.BaseAIService
- Direct Known Subclasses:
GeminiService,OpenAIService
Base class for AI service implementations.
Provides common functionality for different AI providers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final GlobalConfigurationImplprotected static final Loggerprotected static final com.fasterxml.jackson.databind.ObjectMapper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract HttpRequestbuildHttpRequest(HttpRequest.Builder requestBuilder, String requestBody) Build the HTTP request for the specific AI provider.protected StringbuildPrompt(String errorLogs) Build the prompt for the AI service.protected abstract StringbuildRequestBody(String prompt) Build the request body for the specific AI provider.explainError(String errorLogs) Explain error logs using the configured AI provider.protected StringGet the API URL, potentially with model substitution for providers that need it.protected abstract StringparseResponse(String responseBody) Parse the response from the specific AI provider.
-
Field Details
-
LOGGER
-
MAPPER
protected static final com.fasterxml.jackson.databind.ObjectMapper MAPPER -
config
-
-
Constructor Details
-
BaseAIService
-
-
Method Details
-
explainError
Explain error logs using the configured AI provider.- Parameters:
errorLogs- the error logs to explain- Returns:
- the AI explanation
- Throws:
IOException- if there's a communication error
-
buildPrompt
Build the prompt for the AI service. -
getApiUrl
Get the API URL, potentially with model substitution for providers that need it. -
buildHttpRequest
protected abstract HttpRequest buildHttpRequest(HttpRequest.Builder requestBuilder, String requestBody) Build the HTTP request for the specific AI provider. -
buildRequestBody
Build the request body for the specific AI provider.- Throws:
IOException
-
parseResponse
Parse the response from the specific AI provider.- Throws:
IOException
-