Class AIGenPipeline
- java.lang.Object
-
- net.stoerr.ai.aigenpipeline.commandline.AIGenPipeline
-
public class AIGenPipeline extends Object
The main entry point of the AI Generation Pipeline.
This class reads the command line arguments, reads the configuration files, and then executes the AI generation task.
-
-
Field Summary
Fields Modifier and Type Field Description static StringAIGENPIPELINE_CONFIGName of the environment variable where we read common configuration from.protected StringapiKeyprotected booleancheckstatic StringCONFIGFILEName of configuration files we scan upwards from the output directory.protected booleandryRunprotected PatternENVVARIABLE_PATTERNPattern for accessing an environment variable, e.g.static PrintStreamERRprotected Stringexplainprotected booleanhelpprotected StringhelpAIquestionprotected List<AIInOut>hintFilesprotected StringinfilePromptMarkerprotected List<AIInOut>inputFilesprotected Map<String,String>keyValuesprotected PrintStreamlogStreamprotected Stringmodelprotected StringorganizationIdstatic PrintStreamOUTprotected Stringoutputprotected StringoutputScanprotected booleanprintconfigprotected booleanprintdependencydiagramprotected List<AIInOut>promptFilesprotected RegenerationCheckStrategyregenerationCheckStrategyprotected FilerootDirprotected AIGenerationTasktaskprotected AIInOuttaskOutputprotected Integertokensprotected booleanupdateprotected Stringurlprotected booleanverboseprotected booleanversionprotected StringwritePartprotected WritingStrategywritingStrategy
-
Constructor Summary
Constructors Constructor Description AIGenPipeline()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidanswerHelpAIQuestion()This reads the collected texts of the website from /helpaitexts.md and gives them to the AI, and then has it answer the #helpAIquestion from that.protected List<AIGenArgumentList>collectArgLists(String[] args, File startDir)protected voidexecuteTask()protected StringgetVersion()protected booleanisIgnoreEnvironmentArgs(AIGenArgumentList args)protected booleanisStopCfgfileScan(AIGenArgumentList args)static voidmain(String[] args)AIChatBuildermakeChatBuilder()protected voidparseArguments(String[] args, File dir)protected voidprepareTask()protected voidprintHelp(boolean onerror)protected static voidprocessCommandFile(String cmdfilepath)Read command lines from the given file.protected voidreadArguments(String[] args, File startDir)protected voidrun()protected voidrun(String[] args)protected static voidrunWithCommandLine(String cmdline)protected voidrunWithOutputScan(String[] args)Scans for files inoutputScanand processes them.StringtoString()
-
-
-
Field Detail
-
AIGENPIPELINE_CONFIG
public static final String AIGENPIPELINE_CONFIG
Name of the environment variable where we read common configuration from.- See Also:
- Constant Field Values
-
CONFIGFILE
public static final String CONFIGFILE
Name of configuration files we scan upwards from the output directory.- See Also:
- Constant Field Values
-
OUT
public static final PrintStream OUT
-
ERR
public static final PrintStream ERR
-
ENVVARIABLE_PATTERN
protected final Pattern ENVVARIABLE_PATTERN
Pattern for accessing an environment variable, e.g. $FOO or ${FOO}
-
help
protected boolean help
-
verbose
protected boolean verbose
-
dryRun
protected boolean dryRun
-
check
protected boolean check
-
version
protected boolean version
-
helpAIquestion
protected String helpAIquestion
-
output
protected String output
-
taskOutput
protected AIInOut taskOutput
-
explain
protected String explain
-
url
protected String url
-
apiKey
protected String apiKey
-
organizationId
protected String organizationId
-
model
protected String model
-
task
protected AIGenerationTask task
-
rootDir
protected File rootDir
-
logStream
protected PrintStream logStream
-
tokens
protected Integer tokens
-
regenerationCheckStrategy
protected RegenerationCheckStrategy regenerationCheckStrategy
-
writingStrategy
protected WritingStrategy writingStrategy
-
writePart
protected String writePart
-
printconfig
protected boolean printconfig
-
infilePromptMarker
protected String infilePromptMarker
-
outputScan
protected String outputScan
-
printdependencydiagram
protected boolean printdependencydiagram
-
update
protected boolean update
-
-
Method Detail
-
main
public static void main(String[] args) throws IOException
- Throws:
IOException
-
processCommandFile
protected static void processCommandFile(String cmdfilepath) throws IOException
Read command lines from the given file. Empty lines separate individual command lines. Lines starting with a # are ignored (comments). This saves the startup time when calling the tool multiple times. Incompatible to all other options.- Throws:
IOException
-
runWithCommandLine
protected static void runWithCommandLine(String cmdline) throws IOException
- Throws:
IOException
-
run
protected void run(String[] args) throws IOException
- Throws:
IOException
-
makeChatBuilder
public AIChatBuilder makeChatBuilder()
-
run
protected void run() throws IOException- Throws:
IOException
-
prepareTask
protected void prepareTask() throws IOException- Throws:
IOException
-
executeTask
protected void executeTask()
-
runWithOutputScan
protected void runWithOutputScan(String[] args)
Scans for files inoutputScanand processes them.- Parameters:
args- the command line arguments
-
readArguments
protected void readArguments(String[] args, @Nonnull File startDir) throws IOException
- Throws:
IOException
-
collectArgLists
protected List<AIGenArgumentList> collectArgLists(String[] args, File startDir)
-
isStopCfgfileScan
protected boolean isStopCfgfileScan(AIGenArgumentList args)
-
isIgnoreEnvironmentArgs
protected boolean isIgnoreEnvironmentArgs(AIGenArgumentList args)
-
parseArguments
protected void parseArguments(String[] args, File dir) throws IOException
- Throws:
IOException
-
answerHelpAIQuestion
protected void answerHelpAIQuestion() throws IOExceptionThis reads the collected texts of the website from /helpaitexts.md and gives them to the AI, and then has it answer the #helpAIquestion from that.- Throws:
IOException- if the help texts could not be read
-
getVersion
protected String getVersion() throws IOException
- Throws:
IOException
-
printHelp
protected void printHelp(boolean onerror)
-
-