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 +4 -4
- data/.version +1 -1
- data/CHANGELOG.md +17 -0
- data/README.md +32 -13
- data/lib/aia/chat_processor_service.rb +29 -39
- data/lib/aia/config.rb +261 -209
- data/lib/aia/context_manager.rb +7 -2
- data/lib/aia/directive_processor.rb +47 -2
- data/lib/aia/ruby_llm_adapter.rb +180 -63
- data/lib/aia/session.rb +5 -11
- data/lib/aia/utility.rb +17 -7
- data/lib/aia.rb +19 -4
- data/lib/extensions/ruby_llm/modalities.rb +26 -0
- data/lib/refinements/string.rb +16 -0
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a4629811acd04507b4ca4f6902281dae7a3d35128af2a52b9278cf040fb85a4
|
4
|
+
data.tar.gz: 8d80eb38222142a366266091aae2863c2669f676fb9f362210abf12fb270c161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5997271297a683a7664aab0b74612817fdf53b4d206e9cbc4d50b3cb8a7dc798922b3b60f7f762363723d6b77ab282309f10b6fbc25d110ac5bd4fb9a9435faf
|
7
|
+
data.tar.gz: cea1ffbd60baa36963339972b91557dc2fced33ee17e451513de13df3b0d582f3dceda3f6fb611b6f83cbd6b9d9069480cd92ef78507e75dcfa55c223d060889
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
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
|
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
|
-
- [
|
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
|
-
|
|
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
|
-
|
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
|
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
|
-
|
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
|
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
|
-
##
|
208
|
+
## Embedded Ruby (ERB)
|
190
209
|
|
191
|
-
The inclusion of dynamic content through the shell integration
|
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
|
-
|
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 `--
|
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
|
-
|
31
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
114
|
-
|
115
|
-
if
|
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
|
99
|
+
elsif mode.supports?(:image_to_text)
|
118
100
|
:image_to_text
|
119
|
-
elsif
|
101
|
+
elsif mode.supports?(:audio_to_text)
|
120
102
|
:audio_to_text
|
121
|
-
elsif
|
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
|