// 1. Load existing config if possible
- File configFile = getConfigurationFile(configFileOption);
-
- if (configFile.exists() && configFile.isFile()) {
- System.out.println("Found existing configuration at " + configFile.getAbsolutePath());
- System.out.println("I will check whether everything is valid, and if not, allow you to fix it.\n");
- config = loadConfiguration(configFile);
- } else {
- // If no config found, create a fresh one
- System.out.println("No existing configuration found. Let's create one!\n");
- config = new Configuration();
- }
+ File configFile = loadOrCreateConfiguration();
// 2. Validate and fix each parameter
checkAndFixAllParameters();
}
}
+ private File loadOrCreateConfiguration() throws IOException {
+ File configFile = getConfigurationFile(configFileOption);
+
+ if (configFile.exists() && configFile.isFile()) {
+ System.out.println("Found existing configuration at " + configFile.getAbsolutePath());
+ System.out.println("I will check whether everything is valid, and if not, allow you to fix it.\n");
+ config = loadConfiguration(configFile);
+ } else {
+ // If no config found, create a fresh one
+ System.out.println("No existing configuration found. Let's create one!\n");
+ config = new Configuration();
+ }
+ return configFile;
+ }
+
/**
* Step-by-step checking (and possibly fixing) of each main config parameter.
*/
private void checkAndFixAllParameters() {
- // 2.1 mail_directory
- while (true) {
- File mailDir = config.getMailDirectory();
- if (mailDir == null || !mailDir.isDirectory() || !mailDir.exists()) {
- System.out.println("Mail directory is missing or invalid.");
- String defaultVal = (mailDir == null) ? "~/.config/alyverkko-cli/mail" : mailDir.getPath();
- String userInput = CLIHelper.askString(
- "Enter the mail directory path (will create if it doesn't exist)",
- defaultVal
- );
- mailDir = new File(userInput);
- config.setMailDirectory(mailDir);
-
- // Attempt to create if not exist
- if (!mailDir.exists()) {
- boolean created = mailDir.mkdirs();
- if (!created) {
- Utils.printRedMessageToConsole("Failed to create mail directory. Check permissions?");
- }
- }
- } else {
- // If valid, confirm or let user fix
- if (askBoolean("Mail directory is: " + mailDir.getAbsolutePath() + " . Is this OK?", TRUE)) {
- break;
- }
- // Otherwise loop around to let them reenter
- config.setMailDirectory(null); // Force re-check
- }
- }
+ checkMailDirectory();
// 2.2 models_directory
while (true) {
float newTemp = askFloat(
"\nEnter default temperature (0-3). Lower => more deterministic, higher => more creative.",
oldTemp,
- 0f, 3f
+ 0f, 3f, false
);
+
+
config.setDefaultTemperature(newTemp);
// 2.6 thread_count
int newThreadCount = askInteger(
"\nEnter number of CPU threads for AI generation. Typically 6 for a 12-core CPU, for example.",
oldThreadCount,
- 1, null
+ 1, null, false
);
config.setThreadCount(newThreadCount);
int newBatchCount = askInteger(
"\nEnter number of CPU threads for input prompt processing (all cores is often fine).",
oldBatchThreadCount,
- 1, null
+ 1, null, false
);
config.setBatchThreadCount(newBatchCount);
}
+ private void checkMailDirectory() {
+ System.out.println("Älyverkko-cli uses a 'mail' directory to store and discover tasks that it has to solve. " +
+ "AI generated solutions are appended at the end of the task file. " +
+ "Tt should be a directory that you can write to. Current mail directory is: ");
+
+ System.out.println(config.getMailDirectory() + "\n");
+
+ // 2.1 mail_directory
+ while (true) {
+ File mailDir = config.getMailDirectory();
+ if (mailDir == null || !mailDir.isDirectory() || !mailDir.exists()) {
+ System.out.println("Mail directory is missing or invalid.");
+ String defaultVal = (mailDir == null) ? "~/.config/alyverkko-cli/mail" : mailDir.getPath();
+ String userInput = CLIHelper.askString(
+ "Enter the mail directory path (will create if it doesn't exist)",
+ defaultVal
+ );
+ mailDir = new File(userInput);
+ config.setMailDirectory(mailDir);
+
+ // Attempt to create if not exist
+ if (!mailDir.exists()) {
+ boolean created = mailDir.mkdirs();
+ if (!created) {
+ Utils.printRedMessageToConsole("Failed to create mail directory. Check permissions?");
+ }
+ }
+ } else {
+
+ System.out.println("Mail directory is: " + mailDir.getAbsolutePath());
+
+
+ System.out.println(" If you want to change it, please enter a new path.");
+
+ // If valid, confirm or let user fix
+ if (askBoolean("Mail directory is: " + mailDir.getAbsolutePath() + " . Is this OK?", TRUE)) {
+ break;
+ }
+ // Otherwise loop around to let them reenter
+ config.setMailDirectory(null); // Force re-check
+ }
+ }
+ }
+
/**
* Offer to remove model references in config if the file does not exist.
* Then autodiscover new .gguf files and offer to add them.
cm.setFilesystemPath(relativePath);
int ctxSize = askInteger(
"Enter context size in tokens (e.g. 64000).",
- 64000, 1024, 128000
+ 64000, 1024, 128000, false
);
cm.setContextSizeTokens(ctxSize);
cm.setEndOfTextMarker(null);
}
int contextSize = askInteger(
"Enter context size in tokens (e.g. 64000).",
- 64000, 1024, 128000
+ 64000, 1024, 128000, false
);
// Check for duplicates