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,ChatModelAIProvider,CustomOktaAIProvider,LangGraphProvider
public abstract class BaseAIProvider
extends AbstractDescribableImpl<BaseAIProvider>
implements ExtensionPoint
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic classNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal JenkinsLogAnalysisanalyzeError(String errorLogs, TaskListener listener, String language, String customContext, Item item, org.springframework.security.core.Authentication authentication, Double temperature) Analyze error logs using the configured AI provider and return the structured result.protected final Stringprotected final StringbuildUserPrompt(String errorLogs, String language, String customContext) final BaseAIProvider.Assistantfinal BaseAIProvider.AssistantcreateAssistant(Item item, org.springframework.security.core.Authentication authentication) abstract BaseAIProvider.AssistantcreateAssistant(Item item, org.springframework.security.core.Authentication authentication, Double temperature) The single assistant factory providers implement.final BaseAIProvider.AssistantcreateAssistant(Double temperature) Create an assistant with a specific temperature setting.final FixAssistantabstract FixAssistantcreateFixAssistant(Item item, org.springframework.security.core.Authentication authentication) The single fix-assistant factory providers implement; the no-argcreateFixAssistant()is final and delegates here.final StringexplainError(String errorLogs, TaskListener listener) Explain error logs using the configured AI provider.final StringexplainError(String errorLogs, TaskListener listener, String language) Explain error logs using the configured AI provider.final StringexplainError(String errorLogs, TaskListener listener, String language, String customContext) Explain error logs using the configured AI provider.final StringexplainError(String errorLogs, TaskListener listener, String language, String customContext, Item item, org.springframework.security.core.Authentication authentication) Explain error logs using the configured AI provider with item-scoped credentials context.final StringexplainError(String errorLogs, TaskListener listener, String language, String customContext, Item item, org.springframework.security.core.Authentication authentication, Double temperature) Explain error logs using the configured AI provider with item-scoped credentials context.The endpoint URL this provider would call, used only to run connection diagnostics when a configuration test fails.getModel()protected final StringPreemptiveProxy-Authorizationheader value for the Jenkins proxy, ornullwhen no proxy credentials are configured.getUrl()abstract booleanisNotValid(TaskListener listener) booleanisNotValid(TaskListener listener, Item item, org.springframework.security.core.Authentication authentication) protected final HttpClient.Builderprotected final dev.langchain4j.http.client.HttpClientBuilder
-
Field Details
-
SYSTEM_PROMPT
- See Also:
-
USER_PROMPT_TEMPLATE
- See Also:
-
url
-
model
-
-
Constructor Details
-
BaseAIProvider
-
-
Method Details
-
createAssistant
public abstract BaseAIProvider.Assistant createAssistant(@CheckForNull Item item, @CheckForNull org.springframework.security.core.Authentication authentication, @CheckForNull Double temperature) The single assistant factory providers implement. It receives the full request context — credentials scope and temperature — so that a provider cannot accidentally drop a parameter by overriding the wrong overload (the narrowercreateAssistantvariants are final and delegate here). Providers without item-scoped credentials simply ignoreitem/authentication.- Parameters:
item- the item defining the credentials scope, ornullauthentication- the authentication for credentials lookup, ornulltemperature- the temperature to use, ornullfor the provider default- Returns:
- the assistant
-
createAssistant
-
createFixAssistant
public abstract FixAssistant createFixAssistant(@CheckForNull Item item, @CheckForNull org.springframework.security.core.Authentication authentication) The single fix-assistant factory providers implement; the no-argcreateFixAssistant()is final and delegates here.- Parameters:
item- the item defining the credentials scope, ornullauthentication- the authentication for credentials lookup, ornull- Returns:
- the fix assistant
-
isNotValid
-
getUrl
-
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 explainlanguage- 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 explainlistener- the task listener for logginglanguage- the preferred response languagecustomContext- 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 explainlistener- the task listener for logginglanguage- the preferred response languagecustomContext- additional custom context/instructions for the AIitem- the item defining credentials scopeauthentication- the authentication used for credentials lookup- 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, @CheckForNull Double temperature) throws ExplanationException Explain error logs using the configured AI provider with item-scoped credentials context.- Parameters:
errorLogs- the error logs to explainlistener- the task listener for logginglanguage- the preferred response languagecustomContext- additional custom context/instructions for the AIitem- the item defining credentials scopeauthentication- the authentication used for credentials lookuptemperature- the temperature to use, or null to let provider defaults apply- Returns:
- the AI explanation
- Throws:
ExplanationException- if there's a communication error
-
analyzeError
@NonNull public final JenkinsLogAnalysis analyzeError(String errorLogs, TaskListener listener, String language, String customContext, @CheckForNull Item item, @CheckForNull org.springframework.security.core.Authentication authentication, @CheckForNull Double temperature) throws ExplanationException Analyze error logs using the configured AI provider and return the structured result.explainError(java.lang.String, hudson.model.TaskListener)renders the same analysis as plain text.- Parameters:
errorLogs- the error logs to explainlistener- the task listener for logginglanguage- the preferred response languagecustomContext- additional custom context/instructions for the AIitem- the item defining credentials scopeauthentication- the authentication used for credentials lookuptemperature- the temperature to use, or null to let provider defaults apply- Returns:
- the structured AI analysis
- Throws:
ExplanationException- if there's a communication error
-
getDescriptor
- Specified by:
getDescriptorin interfaceDescribable<BaseAIProvider>
-
createAssistant
public final BaseAIProvider.Assistant createAssistant(@CheckForNull Item item, @CheckForNull org.springframework.security.core.Authentication authentication) -
createAssistant
Create an assistant with a specific temperature setting.- Parameters:
temperature- the temperature value, or null to let provider defaults apply- Returns:
- the assistant
-
createFixAssistant
-
isNotValid
public boolean isNotValid(@CheckForNull TaskListener listener, @CheckForNull Item item, @CheckForNull org.springframework.security.core.Authentication authentication) -
buildSystemPrompt
-
buildUserPrompt
-
newJenkinsHttpClientBuilder
-
getProxyAuthorizationHeader
PreemptiveProxy-Authorizationheader value for the Jenkins proxy, ornullwhen no proxy credentials are configured.Sent as a user-set header instead of relying on a JDK
Authenticator: with an Authenticator present, the JDK HttpClient drops user-set Authorization headers (JDK-8326949, fixed only in JDK 24), which silently removes the API key from AI requests on Jenkins instances with an authenticated proxy. -
getEffectiveEndpointForDiagnostics
The endpoint URL this provider would call, used only to run connection diagnostics when a configuration test fails. Providers with a fixed or derivable default endpoint should override this to return it when no explicit URL is configured.- Returns:
- the effective endpoint URL, or
nullwhen unknown
-
newLangChainHttpClientBuilder
protected final dev.langchain4j.http.client.HttpClientBuilder newLangChainHttpClientBuilder() -
getProviderName
-