aia 0.9.2 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 543eb535dae7c828b1dbd2a2dd981e566d27b1c5d8ad4c81d1fd21566015f175
4
- data.tar.gz: 021bf728dd9082c9fa1aca73d72001e4ed512d2c7ddd23cff044d5d9447a8d2d
3
+ metadata.gz: 9a4629811acd04507b4ca4f6902281dae7a3d35128af2a52b9278cf040fb85a4
4
+ data.tar.gz: 8d80eb38222142a366266091aae2863c2669f676fb9f362210abf12fb270c161
5
5
  SHA512:
6
- metadata.gz: 5b108c87dc2c82c0c347efa2b084ce1274b412324c33c2450a8174a655dca3be9c14e34b83347b90a9a7c8817b0eadb90a17f81536234eb38b8d09377f4a3221
7
- data.tar.gz: 43bbef3a40562333650251dde1ea5868b4cef29ed7b35c447429a75552899a6a73989ae87546320e8a51370675192f1d18d71c56eef8b98985beb863341f4869
6
+ metadata.gz: 5997271297a683a7664aab0b74612817fdf53b4d206e9cbc4d50b3cb8a7dc798922b3b60f7f762363723d6b77ab282309f10b6fbc25d110ac5bd4fb9a9435faf
7
+ data.tar.gz: cea1ffbd60baa36963339972b91557dc2fced33ee17e451513de13df3b0d582f3dceda3f6fb611b6f83cbd6b9d9069480cd92ef78507e75dcfa55c223d060889
data/.version CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.9.4
data/CHANGELOG.md CHANGED
@@ -1,6 +1,23 @@
1
1
  # Changelog
2
2
  ## [Unreleased]
3
+
3
4
  ## Released
5
+ ### [0.9.4] 2025-06-03
6
+ - using RubyLLM v1.3.0
7
+ - setting up a docs infrastructure to behave like the ruby_llm gem's guides side
8
+ - fixed bug in the text-to-image workflow
9
+ - discovered that ruby_llm does not have high level support for audio modes
10
+ - need to pay attention to the test suite
11
+ - also need to ensure the non text2text modes are working
12
+
13
+ ### [0.9.3rc1] 2025-05-24
14
+ - using ruby_llm v1.3.0rc1
15
+ - added a models database refresh based on integer days interval with the --refresh option
16
+ - config file now has a "last_refresh" String in format YYYY-MM-DD
17
+ - enhanced the robot figure to show more config items including tools
18
+ - fixed bug with the --require option with the specified libraries were not being loaded.
19
+ - fixed a bug in the prompt_manager gem which is now at v0.5.5
20
+
4
21
 
5
22
  ### [0.9.2] 2025-05-18
6
23
  - removing the MCP experiment
data/README.md CHANGED
@@ -18,7 +18,7 @@ AIA leverages the [prompt_manager gem](https://github.com/madbomber/prompt_manag
18
18
 
19
19
  **Wiki**: [Checkout the AIA Wiki](https://github.com/MadBomber/aia/wiki)
20
20
 
21
- **MCRubyLLM::Tool Support:** AIA now supports the integration of Tools for those models that support function callbacks. See the --tools, --allowed_tools and --rejected_tools options. Yes, functional callbacks provided for dynamic prompt just like the AIA directives so why have both? Well, AIA is older that functional callbacks. Directives or legacy but more than that not all models support functional callbacks. That means the old directives capability, shell and erb integration are still viable ways to provided dynamic extra content to your prompts.
21
+ **MCRubyLLM::Tool Support:** AIA now supports the integration of Tools for those models that support function callbacks. See the --tools, --allowed_tools and --rejected_tools options. Yes, functional callbacks provided for dynamic prompts just like the AIA directives, shell and ERB integrations so why have both? Well, AIA is older that functional callbacks. The AIA integrations are legacy but more than that not all models support functional callbacks. That means the AIA integrationsß∑ are still viable ways to provided dynamic extra content to your prompts.
22
22
 
23
23
  <!-- Tocer[start]: Auto-generated, don't remove. -->
24
24
 
@@ -27,11 +27,13 @@ AIA leverages the [prompt_manager gem](https://github.com/madbomber/prompt_manag
27
27
  - [Configuration Options](#configuration-options)
28
28
  - [Configuration Flexibility](#configuration-flexibility)
29
29
  - [Expandable Configuration](#expandable-configuration)
30
+ - [The Local Model Registry Refresh](#the-local-model-registry-refresh)
31
+ - [Important Note](#important-note)
30
32
  - [Shell Integration inside of a Prompt](#shell-integration-inside-of-a-prompt)
31
33
  - [Dynamic Shell Commands](#dynamic-shell-commands)
32
34
  - [Shell Command Safety](#shell-command-safety)
33
35
  - [Chat Session Use](#chat-session-use)
34
- - [*E*mbedded *R*u*B*y (ERB)](#embedded-ruby-erb)
36
+ - [Embedded Ruby (ERB)](#embedded-ruby-erb)
35
37
  - [Prompt Directives](#prompt-directives)
36
38
  - [Parameter and Shell Substitution in Directives](#parameter-and-shell-substitution-in-directives)
37
39
  - [Directive Syntax](#directive-syntax)
@@ -105,7 +107,8 @@ The following table provides a comprehensive list of configuration options, thei
105
107
  | presence_penalty | --presence_penalty | 0.0 | AIA_PRESENCE_PENALTY |
106
108
  | prompt_extname | | .txt | AIA_PROMPT_EXTNAME |
107
109
  | prompts_dir | -p, --prompts_dir | ~/.prompts | AIA_PROMPTS_DIR |
108
- | require_libs | --rq | [] | AIA_REQUIRE_LIBS |
110
+ | refresh | --refresh | 7 (days) | AIA_REFRESH |
111
+ | require_libs | --rq --require | [] | AIA_REQUIRE_LIBS |
109
112
  | role | -r, --role | | AIA_ROLE |
110
113
  | roles_dir | | ~/.prompts/roles | AIA_ROLES_DIR |
111
114
  | roles_prefix | --roles_prefix | roles | AIA_ROLES_PREFIX |
@@ -152,9 +155,25 @@ If you do not like the default regex used to identify parameters within the prom
152
155
 
153
156
  The configuration options are expandable through a config file, allowing you to add custom entries. For example, you can define a custom configuration item like "xyzzy" in your config file. This value can then be accessed in your prompts using `AIA.config.xyzzy` within a `//ruby` directive or an ERB block, enabling dynamic prompt generation based on your custom configurations.
154
157
 
158
+ ## The Local Model Registry Refresh
159
+
160
+ The `ruby_llm` gem maintains a registry of providers and models integrated with a new website that allows users to download the latest information about each model. This capability is scheduled for release in version 1.3.0 of the gem.
161
+
162
+ In anticipation of this new feature, the AIA tool has introduced the `--refresh` option, which specifies the number of days between updates to the centralized model registry. Here’s how the `--refresh` option works:
163
+
164
+ - A value of `0` (zero) updates the local model registry every time AIA is executed.
165
+ - A value of `1` (one) updates the local model registry once per day.
166
+ - etc.
167
+
168
+ The date of the last successful refresh is stored in the configuration file under the key `last_refresh`. The default configuration file is located at `~/.aia/config.yml`. When a refresh is successful, the `last_refresh` value is updated to the current date, and the updated configuration is saved in `AIA.config.config_file`.
169
+
170
+ ### Important Note
171
+
172
+ This approach to saving the `last_refresh` date can become cumbersome, particularly if you maintain multiple configuration files for different projects. The `last_refresh` date is only updated in the currently active configuration file. If you switch to a different project with a different configuration file, you may inadvertently hit the central model registry again, even if your local registry is already up to date.
173
+
155
174
  ## Shell Integration inside of a Prompt
156
175
 
157
- Using the option `--shell` enables AIA to access your terminal's shell environment from inside the prompt text.
176
+ AIA configures the `prompt_manager` gem to be fully integrated with your local shell by default. This is not an option - its a feature. If your prompt inclues text patterns like $HOME, ${HOME} or $(command) those patterns will be automatically replaced in the prompt text by the shell's value for those patterns.
158
177
 
159
178
  #### Dynamic Shell Commands
160
179
 
@@ -174,25 +193,25 @@ Given the following constraints $(cat ~/3_laws_of_robotics.txt) determine the be
174
193
 
175
194
  #### Shell Command Safety
176
195
 
177
- The catchphrase "the prompt is the code" within AIA means that you have the power to execute any command you want, but you must be careful not to execute commands that could cause harm. AIA is not going to protect you from doing something stupid. Sure that's a copout. I just can't think (actually I can) of all the ways you can mess things up writing code. Remember what we learned from Forrest Gump "Stupid is as stupid does." So don't do anything stupid. If someone gives you a prompt as says "run this with AIA" you had better review the prompt before processing it.
196
+ The catchphrase "the prompt is the code" within AIA means that you have the power to execute any command you want, but you must be careful not to execute commands that could cause harm. AIA is not going to protect you from doing something dumb. Sure that's a copout. I just can't think (actually I can) of all the ways you can mess things up writing code. Remember what we learned from Forrest Gump "Stupid is as stupid does." So don't break the dumb law. If someone gives you a prompt as says "run this with AIA" you had better review the prompt before processing it.
178
197
 
179
198
  #### Chat Session Use
180
199
 
181
- When you use the `--shell` option to start a chat session, shell integration is available in your follow up prompts. Suppose you started a chat session (--chat) using a role of "Ruby Expert" expecting to chat about changes that could be made to a specific class BUT you forgot to include the class source file as part of the context when you got started. You could enter this as your follow up prompt to keep going:
200
+ Shell integration is available in your follow up prompts within a chat session. Suppose you started a chat session (--chat) using a role of "Ruby Expert" expecting to chat about changes that could be made to a specific class BUT you forgot to include the class source file as part of the context when you got started. You could enter this as your follow up prompt to keep going:
182
201
 
183
202
  ```plaintext
184
203
  The class I want to chat about refactoring is this one: $(cat my_class.rb)
185
204
  ```
186
205
 
187
- That inserts the entire class source file into your follow up prompt. You can continue chatting with you AI Assistant about changes to the class.
206
+ That inserts the entire class source file into your follow up prompt. You can continue chatting with your AI Assistant about changes to the class.
188
207
 
189
- ## *E*mbedded *R*u*B*y (ERB)
208
+ ## Embedded Ruby (ERB)
190
209
 
191
- The inclusion of dynamic content through the shell integration provided by the `--shell` option is significant. AIA also provides the full power of embedded Ruby code processing within the prompt text.
210
+ The inclusion of dynamic content through the shell integration is significant. AIA also provides the full power of embedded Ruby code processing within the prompt text.
192
211
 
193
- The `--erb` option turns the prompt text file into a fully functioning ERB template. The [Embedded Ruby (ERB) template syntax (2024)](https://bophin-com.ngontinh24.com/article/language-embedded-ruby-erb-template-syntax) provides a good overview of the syntax and power of ERB.
212
+ AIA takes advantage of the `prompt_manager` gem to enable ERB integration in prompt text as a default. Its an always available feature of AIA prompts. The [Embedded Ruby (ERB) template syntax (2024)](https://bophin-com.ngontinh24.com/article/language-embedded-ruby-erb-template-syntax) provides a good overview of the syntax and power of ERB.
194
213
 
195
- Most websites that have information about ERB will give examples of how to use ERB to generate dynamic HTML content for web-based applications. That is a common use case for ERB. AIA on the other hand uses ERB to generate dynamic prompt text for LLM processing.
214
+ Most websites that have information about ERB will give examples of how to use ERB to generate dynamic HTML content for web-based applications. That is a common use case for ERB. AIA on the other hand uses ERB to generate dynamic or conditional prompt text for LLM processing.
196
215
 
197
216
  ## Prompt Directives
198
217
 
@@ -297,11 +316,11 @@ For example:
297
316
  //ruby puts "Hello from Ruby"
298
317
  ```
299
318
 
300
- You can also use the `--rq` option to specify Ruby libraries to require before executing Ruby code:
319
+ You can also use the `--require` option to specify Ruby libraries to require before executing Ruby code:
301
320
 
302
321
  ```bash
303
322
  # Command line
304
- aia --rq json,csv my_prompt
323
+ aia --rq json,csv --require os my_prompt
305
324
 
306
325
  # In chat
307
326
  //ruby JSON.parse('{"data": [1,2,3]}')["data"]
@@ -12,7 +12,6 @@ module AIA
12
12
  end
13
13
 
14
14
 
15
-
16
15
  def speak(text)
17
16
  return unless AIA.speak?
18
17
 
@@ -26,50 +25,34 @@ module AIA
26
25
  end
27
26
 
28
27
 
28
+ def process_prompt(prompt)
29
+ result = nil
30
+ @ui_presenter.with_spinner("Processing", determine_operation_type) do
31
+ result = send_to_client(prompt)
32
+ end
29
33
 
30
- def process_prompt(prompt, operation_type)
31
- @ui_presenter.with_spinner("Processing", operation_type) do
32
- send_to_client(prompt, operation_type)
34
+ unless result.is_a? String
35
+ result = result.content
33
36
  end
34
- end
35
37
 
38
+ result
39
+ end
36
40
 
37
41
 
38
- def send_to_client(prompt, operation_type)
42
+ # conversation is an Array of Hashes. Each entry is an interchange
43
+ # with the LLM.
44
+ def send_to_client(conversation)
39
45
  maybe_change_model
40
46
 
41
- case operation_type
42
- when :text_to_text
43
- AIA.client.chat(prompt)
44
- when :text_to_image
45
- AIA.client.chat(prompt)
46
- when :image_to_text
47
- AIA.client.chat(prompt)
48
- when :text_to_audio
49
- AIA.client.chat(prompt)
50
- when :audio_to_text
51
- if prompt.strip.end_with?('.mp3', '.wav', '.m4a', '.flac') && File.exist?(prompt.strip)
52
- AIA.client.transcribe(prompt.strip)
53
- else
54
- AIA.client.chat(prompt) # Fall back to regular chat
55
- end
56
- else
57
- AIA.client.chat(prompt)
58
- end
47
+ AIA.client.chat(conversation)
59
48
  end
60
49
 
61
50
 
62
51
  def maybe_change_model
63
- if AIA.client.model.is_a?(String)
64
- client_model = AIA.client.model # AiClient instance
65
- else
66
- client_model = AIA.client.model.id # RubyLLM::Model instance
67
- end
52
+ client_model = AIA.client.model.id # RubyLLM::Model instance
68
53
 
69
- # when adapter is ruby_llm must use model.id as the name
70
54
  unless AIA.config.model.downcase.include?(client_model.downcase)
71
- # FIXME: assumes that the adapter is AiClient. It might be RUbyLLM
72
- AIA.client = AIClientAdapter.new
55
+ AIA.client = AIA.client.class.new
73
56
  end
74
57
  end
75
58
 
@@ -100,7 +83,6 @@ module AIA
100
83
  end
101
84
 
102
85
 
103
-
104
86
  def process_next_prompts(response, prompt_handler)
105
87
  if @directive_processor.directive?(response)
106
88
  directive_result = @directive_processor.process(response, @history_manager.history)
@@ -110,16 +92,24 @@ module AIA
110
92
  end
111
93
 
112
94
 
113
- def determine_operation_type(model)
114
- model = model.to_s.downcase
115
- if model.include?('dall') || model.include?('image-generation')
95
+ def determine_operation_type
96
+ mode = AIA.config.client.model.modalities
97
+ if mode.supports?(:text_to_image)
116
98
  :text_to_image
117
- elsif model.include?('vision') || model.include?('image')
99
+ elsif mode.supports?(:image_to_text)
118
100
  :image_to_text
119
- elsif model.include?('whisper') || model.include?('audio')
101
+ elsif mode.supports?(:audio_to_text)
120
102
  :audio_to_text
121
- elsif model.include?('speech') || model.include?('tts')
103
+ elsif mode.supports?(:text_to_audio)
122
104
  :text_to_audio
105
+ elsif mode.supports?(:audio_to_audio)
106
+ :audio_to_audio
107
+ elsif mode.supports?(:image_to_image)
108
+ :image_to_image
109
+ elsif mode.supports?(:audio_to_image)
110
+ :audio_to_image
111
+ elsif mode.supports?(:image_to_audio)
112
+ :image_to_audio
123
113
  else
124
114
  :text_to_text
125
115
  end