Class BaseAIService

java.lang.Object
io.jenkins.plugins.explain_error.BaseAIService
Direct Known Subclasses:
GeminiService, OpenAIService

public abstract class BaseAIService extends Object
Base class for AI service implementations. Provides common functionality for different AI providers.
  • Field Details

    • LOGGER

      protected static final Logger LOGGER
    • MAPPER

      protected static final com.fasterxml.jackson.databind.ObjectMapper MAPPER
    • config

      protected final GlobalConfigurationImpl config
  • Constructor Details

  • Method Details

    • explainError

      public String explainError(String errorLogs) throws IOException
      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

      protected String buildPrompt(String errorLogs)
      Build the prompt for the AI service.
    • getApiUrl

      protected String 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

      protected abstract String buildRequestBody(String prompt) throws IOException
      Build the request body for the specific AI provider.
      Throws:
      IOException
    • parseResponse

      protected abstract String parseResponse(String responseBody) throws IOException
      Parse the response from the specific AI provider.
      Throws:
      IOException