Class BaseAIProvider

java.lang.Object
hudson.model.AbstractDescribableImpl<BaseAIProvider>
io.jenkins.plugins.explain_error.provider.BaseAIProvider
All Implemented Interfaces:
ExtensionPoint, Describable<BaseAIProvider>
Direct Known Subclasses:
AzureOpenAIProvider, BedrockProvider, CustomOktaAIProvider, DeepSeekProvider, GeminiProvider, OllamaProvider, OpenAIProvider, QwenProvider

public abstract class BaseAIProvider extends AbstractDescribableImpl<BaseAIProvider> implements ExtensionPoint
  • Field Details

  • Constructor Details

    • BaseAIProvider

      public BaseAIProvider(String url, String model)
  • Method Details

    • createAssistant

      public abstract BaseAIProvider.Assistant createAssistant()
    • createFixAssistant

      public abstract FixAssistant createFixAssistant()
    • isNotValid

      public abstract boolean isNotValid(@CheckForNull TaskListener listener)
    • getUrl

      public String getUrl()
    • getModel

      public String getModel()
    • explainError

      public final String explainError(String errorLogs, TaskListener listener) throws ExplanationException
      Explain error logs using the configured AI provider.
      Parameters:
      errorLogs - the error logs to explain
      Returns:
      the AI explanation
      Throws:
      ExplanationException - if there's a communication error
    • explainError

      public final String explainError(String errorLogs, TaskListener listener, String language) throws ExplanationException
      Explain error logs using the configured AI provider.
      Parameters:
      errorLogs - the error logs to explain
      language - the preferred response language
      Returns:
      the AI explanation
      Throws:
      ExplanationException - if there's a communication error
    • explainError

      public final String explainError(String errorLogs, TaskListener listener, String language, String customContext) throws ExplanationException
      Explain error logs using the configured AI provider.
      Parameters:
      errorLogs - the error logs to explain
      listener - the task listener for logging
      language - the preferred response language
      customContext - additional custom context/instructions for the AI
      Returns:
      the AI explanation
      Throws:
      ExplanationException - if there's a communication error
    • explainError

      public final String explainError(String errorLogs, TaskListener listener, String language, String customContext, @CheckForNull Item item, @CheckForNull org.springframework.security.core.Authentication authentication) throws ExplanationException
      Explain error logs using the configured AI provider with item-scoped credentials context.
      Parameters:
      errorLogs - the error logs to explain
      listener - the task listener for logging
      language - the preferred response language
      customContext - additional custom context/instructions for the AI
      item - the item defining credentials scope
      authentication - the authentication used for credentials lookup
      Returns:
      the AI explanation
      Throws:
      ExplanationException - if there's a communication error
    • getDescriptor

      public BaseAIProvider.BaseProviderDescriptor getDescriptor()
      Specified by:
      getDescriptor in interface Describable<BaseAIProvider>
    • createAssistant

      public BaseAIProvider.Assistant createAssistant(@CheckForNull Item item, @CheckForNull org.springframework.security.core.Authentication authentication)
    • createFixAssistant

      public FixAssistant createFixAssistant(@CheckForNull Item item, @CheckForNull org.springframework.security.core.Authentication authentication)
    • isNotValid

      public boolean isNotValid(@CheckForNull TaskListener listener, @CheckForNull Item item, @CheckForNull org.springframework.security.core.Authentication authentication)
    • buildSystemPrompt

      protected final String buildSystemPrompt()
    • buildUserPrompt

      protected final String buildUserPrompt(String errorLogs, String language, String customContext)
    • newJenkinsHttpClientBuilder

      protected final HttpClient.Builder newJenkinsHttpClientBuilder()
    • newLangChainHttpClientBuilder

      protected final dev.langchain4j.http.client.HttpClientBuilder newLangChainHttpClientBuilder()
    • getProviderName

      public String getProviderName()