import eu.svjatoslav.alyverkko_cli.Command;
import eu.svjatoslav.alyverkko_cli.configuration.Configuration;
import eu.svjatoslav.alyverkko_cli.configuration.ConfigurationHelper;
-import eu.svjatoslav.alyverkko_cli.configuration.ConfigurationModel;
+import eu.svjatoslav.alyverkko_cli.configuration.Model;
import eu.svjatoslav.commons.cli_helper.parameter_parser.Parser;
import eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.FileOption;
return;
}
- List<ConfigurationModel> existingModels = configuration.getModels();
+ List<Model> existingModels = configuration.getModels();
if (existingModels == null) {
existingModels = new ArrayList<>();
configuration.setModels(existingModels);
}
private void addNewModel(String relativePath) {
- ConfigurationModel newModel = getNewModel(relativePath);
+ Model newModel = getNewModel(relativePath);
configuration.getModels().add(newModel);
System.out.println("Added new model: " + newModel.getAlias() + " (" + newModel.getFilesystemPath() + ")");
configurationUpdated = true;
modelsUpdated = true;
}
- private ConfigurationModel getNewModel(String relativePath) {
+ private Model getNewModel(String relativePath) {
String suggestedAlias = suggestAlias(relativePath);
- ConfigurationModel newModel = new ConfigurationModel();
+ Model newModel = new Model();
newModel.setAlias(suggestedAlias + "-new");
newModel.setFilesystemPath(relativePath);
newModel.setContextSizeTokens(32768); // Default context size
private void annotateMissingModels() {
// Process existing models to add/remove -missing suffix
- for (ConfigurationModel model : configuration.getModels()) {
+ for (Model model : configuration.getModels()) {
File modelFile = new File(configuration.getModelsDirectory(), model.getFilesystemPath());
if (!modelFile.exists()) {
if (!model.getAlias().endsWith("-missing")) {
package eu.svjatoslav.alyverkko_cli.commands.task_processor;
-import eu.svjatoslav.alyverkko_cli.configuration.ConfigurationModel;
+import eu.svjatoslav.alyverkko_cli.configuration.Model;
import eu.svjatoslav.alyverkko_cli.configuration.SkillConfig;
import static eu.svjatoslav.alyverkko_cli.Main.configuration;
/**
* The AI model to be used for processing this query.
*/
- public ConfigurationModel model;
+ public Model model;
/**
* The start time of the query (milliseconds since epoch).
import eu.svjatoslav.alyverkko_cli.*;
import eu.svjatoslav.alyverkko_cli.configuration.ConfigurationHelper;
-import eu.svjatoslav.alyverkko_cli.configuration.ConfigurationModel;
+import eu.svjatoslav.alyverkko_cli.configuration.Model;
import eu.svjatoslav.alyverkko_cli.configuration.SkillConfig;
import eu.svjatoslav.alyverkko_cli.configuration.ModelLibrary;
import eu.svjatoslav.commons.cli_helper.parameter_parser.Parser;
// Set AI model using hierarchy: TOCOMPUTE > skill config > default
String modelAlias = fileProcessingSettings.getOrDefault("model",
skill.getModelAlias() != null ? skill.getModelAlias() : "default");
- Optional<ConfigurationModel> modelOptional = modelLibrary.findModelByAlias(modelAlias);
+ Optional<Model> modelOptional = modelLibrary.findModelByAlias(modelAlias);
if (!modelOptional.isPresent()) {
throw new IllegalArgumentException("Model with alias '" + modelAlias + "' not found.");
}
/**
* The list of models defined in this configuration.
*/
- private List<ConfigurationModel> models;
+ private List<Model> models;
/**
+++ /dev/null
-package eu.svjatoslav.alyverkko_cli.configuration;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import lombok.Data;
-
-
-/**
- * Represents a single AI model configuration entry, including alias,
- * path to the model file, token context size, and an optional
- * end-of-text marker.
- */
-@Data
-public class ConfigurationModel {
-
- /**
- * A short name for the model, e.g., "default" or "mistral".
- */
- private String alias;
-
- /**
- * Model-specific temperature value overriding global default.
- */
- private Float temperature;
-
- /**
- * Model-specific top-p value overriding global default.
- */
- @JsonProperty("top_p")
- private Float topP;
-
- @JsonProperty("min_p")
- private Float minP;
-
- @JsonProperty("top_k")
- private Float topK;
-
- /**
- * Model-specific repeat penalty value overriding global default.
- */
- @JsonProperty("repeat_penalty")
- private Float repeatPenalty;
-
- /**
- * The path to the model file (GGUF, etc.), relative to
- * {@link Configuration#getModelsDirectory()} or fully qualified.
- */
- @JsonProperty("filesystem_path")
- private String filesystemPath;
-
- /**
- * The maximum context size the model supports, in tokens.
- */
- @JsonProperty("context_size_tokens")
- private int contextSizeTokens;
-
- /**
- * Optional text marker signifying the end of text for this model.
- * If non-null, it will be used to strip trailing tokens from the AI response.
- */
- @JsonProperty("end_of_text_marker")
- private String endOfTextMarker;
-
- /**
- * Optional string that indicates the start of the final answer in the model's output.
- * When specified, the response is split into ASSISTANT and FINAL ANSWER sections based on this indicator.
- */
- @JsonProperty("final_answer_indicator")
- private String finalAnswerIndicator;
-
- /**
- * <p>Prints the model's metadata to standard output in a consistent format. This includes the model's alias,
- * filesystem path, and context token capacity. The output format is designed to be both human-readable and
- * machine-parsable when needed.
- * <p>Typical output:
- * <pre>
- * Model: default
- * Path: /path/to/model.gguf
- * Context size: 32768
- * </pre>
- */
- public void printModelDetails() {
- System.out.println("Model: " + alias);
- System.out.println(" Path: " + filesystemPath);
- System.out.println(" Context size: " + contextSizeTokens);
- }
-
-}
--- /dev/null
+package eu.svjatoslav.alyverkko_cli.configuration;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+
+/**
+ * Represents a single AI model configuration entry, including alias,
+ * path to the model file, token context size, and an optional
+ * end-of-text marker.
+ */
+@Data
+public class Model {
+
+ /**
+ * A short name for the model, e.g., "default" or "mistral".
+ */
+ private String alias;
+
+ /**
+ * Model-specific temperature value overriding global default.
+ */
+ private Float temperature;
+
+ /**
+ * Model-specific top-p value overriding global default.
+ */
+ @JsonProperty("top_p")
+ private Float topP;
+
+ @JsonProperty("min_p")
+ private Float minP;
+
+ @JsonProperty("top_k")
+ private Float topK;
+
+ /**
+ * Model-specific repeat penalty value overriding global default.
+ */
+ @JsonProperty("repeat_penalty")
+ private Float repeatPenalty;
+
+ /**
+ * The path to the model file (GGUF, etc.), relative to
+ * {@link Configuration#getModelsDirectory()} or fully qualified.
+ */
+ @JsonProperty("filesystem_path")
+ private String filesystemPath;
+
+ /**
+ * The maximum context size the model supports, in tokens.
+ */
+ @JsonProperty("context_size_tokens")
+ private int contextSizeTokens;
+
+ /**
+ * Optional text marker signifying the end of text for this model.
+ * If non-null, it will be used to strip trailing tokens from the AI response.
+ */
+ @JsonProperty("end_of_text_marker")
+ private String endOfTextMarker;
+
+ /**
+ * Optional string that indicates the start of the final answer in the model's output.
+ * When specified, the response is split into ASSISTANT and FINAL ANSWER sections based on this indicator.
+ */
+ @JsonProperty("final_answer_indicator")
+ private String finalAnswerIndicator;
+
+ /**
+ * <p>Prints the model's metadata to standard output in a consistent format. This includes the model's alias,
+ * filesystem path, and context token capacity. The output format is designed to be both human-readable and
+ * machine-parsable when needed.
+ * <p>Typical output:
+ * <pre>
+ * Model: default
+ * Path: /path/to/model.gguf
+ * Context size: 32768
+ * </pre>
+ */
+ public void printModelDetails() {
+ System.out.println("Model: " + alias);
+ System.out.println(" Path: " + filesystemPath);
+ System.out.println(" Context size: " + contextSizeTokens);
+ }
+
+}
/**
* The list of all successfully loaded models in this library.
*/
- private final List<ConfigurationModel> models;
+ private final List<Model> models;
/**
* The default model for this library (e.g., the first successfully
* loaded model in the list).
*/
- private static ConfigurationModel defaultModel;
+ private static Model defaultModel;
/**
* Base directory containing the model files.
/**
* Constructs a library of AI models from the provided list of
- * {@link ConfigurationModel}s, ignoring those whose paths do not exist.
+ * {@link Model}s, ignoring those whose paths do not exist.
*
* @param modelsBaseDirectory the root directory where model files are stored.
* @param configModels a list of model configurations.
*/
- public ModelLibrary(File modelsBaseDirectory, List<ConfigurationModel> configModels) {
+ public ModelLibrary(File modelsBaseDirectory, List<Model> configModels) {
this.modelsBaseDirectory = modelsBaseDirectory;
this.models = new ArrayList<>();
- for (ConfigurationModel configModel : configModels) {
+ for (Model configModel : configModels) {
addModel(configModel);
}
* @param model the model to add.
* @throws RuntimeException if a model with the same alias already exists.
*/
- public void addModel(ConfigurationModel model) {
+ public void addModel(Model model) {
if (findModelByAlias(model.getAlias()).isPresent()) {
throw new RuntimeException("Model with alias \"" + model.getAlias() + "\" already exists!");
}
/**
* @return the list of loaded models in this library.
*/
- public List<ConfigurationModel> getModels() {
+ public List<Model> getModels() {
return models;
}
* @param alias the model alias to look for.
* @return an {@link Optional} describing the found model, or empty if none match.
*/
- public Optional<ConfigurationModel> findModelByAlias(String alias) {
+ public Optional<Model> findModelByAlias(String alias) {
return models.stream()
.filter(model -> model.getAlias().equals(alias))
.findFirst();
/**
* @return the default model (first loaded model).
*/
- public ConfigurationModel getDefaultModel() {
+ public Model getDefaultModel() {
return defaultModel;
}
*/
public void printModels() {
System.out.println("Available models:\n");
- for (ConfigurationModel model : models) {
+ for (Model model : models) {
model.printModelDetails();
System.out.println();
}
}
- public String getModelFullFilesystemPath(ConfigurationModel model) {
+ public String getModelFullFilesystemPath(Model model) {
return new File(modelsBaseDirectory, model.getFilesystemPath()).getAbsolutePath();
}