io.codemodder.plugins.llm.SarifPluginLLMCodemod Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of codemodder-plugin-llm Show documentation
Show all versions of codemodder-plugin-llm Show documentation
Codemod plugin for augmenting transformation with LLM assisted analysis and fixes
package io.codemodder.plugins.llm;
import io.codemodder.RuleSarif;
import io.codemodder.SarifPluginRawFileChanger;
import java.util.Objects;
/** A base class for LLM codemods that process SARIF and use the OpenAI service. */
public abstract class SarifPluginLLMCodemod extends SarifPluginRawFileChanger {
protected final OpenAIService openAI;
public SarifPluginLLMCodemod(RuleSarif sarif, final OpenAIService openAI) {
super(sarif);
this.openAI = Objects.requireNonNull(openAI);
}
/**
* Indicates whether the codemod should run.
*
* Subclasses can override this method to add additional hecks but should call
* super.shouldRun() to ensure the OpenAI service is available.
*/
@Override
public boolean shouldRun() {
return openAI.isServiceAvailable();
}
}