From: Svjatoslav Agejenko Date: Sun, 14 Dec 2025 18:58:33 +0000 (+0200) Subject: Add support for optional `model_alias` in skill configuration and update model select... X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=d1646c4b7888432b166ce10940efc710299d361f;p=alyverkko-cli.git Add support for optional `model_alias` in skill configuration and update model selection logic. - Introduced `model_alias` field in `SkillConfig` to associate skills with specific models. - Updated model selection hierarchy: TOCOMPUTE > skill config alias > default model. - Revised documentation to reflect `model_alias` usage and examples. --- diff --git a/doc/index.org b/doc/index.org index 299aab1..ff2cdd4 100644 --- a/doc/index.org +++ b/doc/index.org @@ -187,11 +187,14 @@ A /skill/ is a predefined behavioral configuration for the AI, implemented as a YAML file in the skills directory. Each skill defines: -- A [[id:89bc60f0-89d4-4e10-ae80-8f824f2e3c55][system prompt]] that establishes the AI's role and behavior +- A [[id:89bc60f0-89d4-4e10-ae80-8f824f2e3c55][system prompt]] that establishes the AI's role and behavior. + - System prompt will have special marker == where + specific user task will be injected. - Optional generation parameters ([[id:24a0a54b-828b-4c78-8208-504390848fbc][temperature]], [[id:047f5bf7-e964-49ac-a666-c7ac75754e54][top-p]] , etc.) -- The == placeholder where user input gets injected +- Optional [[id:074af969-8a9b-407d-a605-6725fe4e8580][Model]] alias that will be selected when this skill gets + invoked. Skills function as specialized "personas" for different task types. For example, a =summary.yaml= skill might contain instructions @@ -204,6 +207,9 @@ instructions, letting you focus on the actual content of your request rather than constantly redefining how the AI should behave. *** Model +:PROPERTIES: +:ID: 074af969-8a9b-407d-a605-6725fe4e8580 +:END: A /model/ refers to a specific AI language model implementation in GGUF format, capable of processing tasks. Each model is configured @@ -766,91 +772,55 @@ to the installation process. ** Your Setup Journey - What to Expect -Here's what you'll be doing, explained simply with /why/ each step -matters: - -*** 1. Installing Java & Maven (The Foundation) +Before we start actual setup, here's brief overview of what you'll be +doing: +*Installing Java & Maven (The Foundation)* - *What*: Install JDK 21+ and Apache Maven - *Why*: Älyverkko CLI is written in Java - these tools let you build - and run the application. - - *Don't worry*: On Debian/Ubuntu, it's just - : sudo apt install openjdk-21-jdk maven - -*Key insight*: Java was chosen because it's cross-platform, -memory-safe, and perfect for long-running background processes like -our AI task processor. + and run the application. *Key insight*: Java was chosen because it's + cross-platform, memory-safe, and perfect for long-running background + processes like our AI task processor. -*** 2. Building llama.cpp (Your AI Engine) +*Building llama.cpp (Your AI Engine):* - *What*: Download and compile the [[https://github.com/ggml-org/llama.cpp][llama.cpp]] project from GitHub. - *Why*: This is the [[id:01b0d389-75d4-420f-8d5c-cae29900301f][actual "brain" that runs large language models]] on *your CPU*. We build from source (rather than using rebuilt binaries) so it can optimize for /your specific CPU/ - squeezing out maximum performance from your hardware. -*** 3. Adding AI Models (The Brains) -:PROPERTIES: -:ID: 2ff850f6-6d7b-4603-879a-59a51d378ffe -:END: +*Adding AI Models (The Brains):* - *What*: Download GGUF format model files (typically 4-30GB each) - *Where*: From Hugging Face Hub ([[https://huggingface.co/models?search=gguf][search "GGUF"]]). - *Why*: These contain the actual neural networks that power the AI. -- *Don't worry*: Start with one model (like Mistral 7B) - you can add - more later. -- *Key insight*: GGUF format was created specifically for CPU - inference. - -#+begin_quote -❓ Why not smaller models? Larger models (even running slowly on CPU) -produce significantly better results for complex tasks - it's worth -the wait. -#+end_quote - -*** 4. Running the Interactive Wizard (=alyverkko-cli wizard=) -- *What*: Launch the configuration wizard that asks simple questions. -- *Why*: To connect all the pieces without you needing to edit complex - YAML files. -- *Don't worry*: It's interactive! You'll answer questions like "Where did - you put your AI models?" with easy prompts. -- *Key insight*: This creates your personal - =~/.config/alyverkko-cli.yaml= file. - -#+begin_quote -🌟 Pro tip: The wizard automatically detects your models and suggests -reasonable defaults - you're not starting from scratch. -#+end_quote - -*** 5. Setting Up "Skills" (Your Custom Instructions) -:PROPERTIES: -:ID: 1ba0c510-4c11-4f23-8746-eb9675c3e60c -:END: -- *What*: Create simple YAML files defining how the AI should behave - for different tasks. +*Running the Interactive Wizard setup wizard:* +- *What*: Launch the configuration wizard that asks simple questions. + You'll answer questions like "Where did you put your AI models?" + with easy prompts. *Key insight*: This creates your personal + =~/.config/alyverkko-cli.yaml= file. Note: The wizard automatically + detects your models and suggests reasonable defaults - you're not + starting from scratch. + +*Setting Up "Skills" (Your Custom Instructions)* +- *What*: You will create simple YAML files defining how the AI should + behave for different tasks. - *Why*: So you don't have to rewrite instructions every time ("be a - coding assistant" vs "be a writing editor"). -- *Don't worry*: Start with sample skills ([[https://www3.svjatoslav.eu/projects/alyverkko-cli/examples/skills/default.yaml][default.yaml]], - [[https://www3.svjatoslav.eu/projects/alyverkko-cli/examples/skills/summary.yaml][summary.yaml]]) - you can modify them gradually. -- *Key insight*: [[id:6579abb4-8386-418b-9457-cae6c3345dfb][Skills let you create specialized AI personas]] without - changing models. - -#+begin_quote -Idea: Your =writer.yaml= skill might instruct the AI to "always -provide well-reasoned responses in academic tone" -#+end_quote - -*** 6. Preparing Your First Task (The Magic Moment) + coding assistant" vs "be a writing editor"). *Don't worry*: You can + start with sample skills and you can modify them gradually. + +*Preparing Your First Task (The Magic Moment)* - *What*: Create [[id:140c53cb-8032-4a04-83ed-d1818b1cfc52][task]] text file with your request, prefixed with *TOCOMPUTE:* -- *Why*: This triggers the background processing system -- *Key insight*: File-based interaction isn't primitive - it's - intentional design for batch processing. +- *Why*: This triggers the background processing system and verifies + that everything is working correctly. ** Installation :PROPERTIES: :ID: 0b705a37-9b84-4cd5-878a-fedc9ab09b12 :END: + At the moment, to use Älyverkko CLI, you need to: - Download sources and build [[https://github.com/ggerganov/llama.cpp][llama.cpp]] project. - Download [[id:f5740953-079b-40f4-87d8-b6d1635a8d39][sources]] and build Älyverkko CLI project. @@ -1040,6 +1010,7 @@ Each skill file contains: #+begin_src yaml prompt: "Full system prompt text here" + model_alias: mistral # Optional temperature: 0.8 # Optional top_p: 0.95 # Optional top_k: 20 # Optional @@ -1059,6 +1030,7 @@ the actual user prompt during execution. #+begin_src yaml temperature: 0.9 top_p: 0.95 + model_alias: mistral prompt: | <|im_start|>system User will provide you with task that needs to be solved along with @@ -1236,7 +1208,6 @@ After AI processing completes, a new file is created with: innovations #+end_example - ** Task preparation :PROPERTIES: :ID: 4b7900e4-77c1-45e7-9c54-772d0d3892ea diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/task_processor/TaskProcessorCommand.java b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/task_processor/TaskProcessorCommand.java index f8031f5..07b96f4 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/commands/task_processor/TaskProcessorCommand.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/commands/task_processor/TaskProcessorCommand.java @@ -32,7 +32,7 @@ import static java.nio.file.StandardWatchEventKinds.*; *

* Usage: *

- *   alyverkko-cli mail
+ *   alyverkko-cli process
  * 
*/ public class TaskProcessorCommand implements Command { @@ -250,7 +250,7 @@ public class TaskProcessorCommand implements Command { } try { - Task task = buildMailQueryFromTaskFile(file); + Task task = buildTaskFromFile(file); TaskProcess aiTask = new TaskProcess(task); String aiGeneratedResponse = aiTask.runAiQuery(); @@ -289,13 +289,18 @@ public class TaskProcessorCommand implements Command { } /** - * Builds a MailQuery object from the contents of a file. + * Builds a Task object from the contents of a file. + * + * This method now implements a three-level hierarchy for model selection: + * 1. Explicit model specified in TOCOMPUTE line (the highest priority) + * 2. Model alias defined in the skill configuration (if present) + * 3. Default "default" model (the lowest priority) * * @param file the file to read. * @return the constructed MailQuery. * @throws IOException if reading the file fails. */ - private Task buildMailQueryFromTaskFile(File file) throws IOException { + private Task buildTaskFromFile(File file) throws IOException { Task result = new Task(); String inputFileContent = getFileContentsAsString(file); @@ -316,8 +321,9 @@ public class TaskProcessorCommand implements Command { result.systemPrompt = skill.getPrompt(); result.skill = skill; - // Set AI model - String modelAlias = fileProcessingSettings.getOrDefault("model", "default"); + // Set AI model using hierarchy: TOCOMPUTE > skill config > default + String modelAlias = fileProcessingSettings.getOrDefault("model", + skill.getModelAlias() != null ? skill.getModelAlias() : "default"); Optional modelOptional = modelLibrary.findModelByAlias(modelAlias); if (!modelOptional.isPresent()) { throw new IllegalArgumentException("Model with alias '" + modelAlias + "' not found."); diff --git a/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/SkillConfig.java b/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/SkillConfig.java index 9508654..ec242e0 100644 --- a/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/SkillConfig.java +++ b/src/main/java/eu/svjatoslav/alyverkko_cli/configuration/SkillConfig.java @@ -28,4 +28,17 @@ public class SkillConfig { @JsonProperty("repeat_penalty") private Float repeatPenalty; + /** + * Optional model alias to use for this skill. If specified, this model will be used by default + * when the skill is invoked, unless overridden by the task's TOCOMPUTE line. + * + * Example usage in skill YAML file: + * model_alias: "mistral" + * + * This creates a convenient way to associate specific skills with appropriate models + * without requiring users to specify the model in every task file. + */ + @JsonProperty("model_alias") + private String modelAlias; + } \ No newline at end of file