aia 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84dc61c76d34c0a5c37db65b31c8412e3c81fb74b4aa33bf6550747601948727
4
- data.tar.gz: 481d77b6a396f420f260c517d74b66406197002e5350808f22bb2182cf1beff6
3
+ metadata.gz: 926de232dae7c4e214ae72129e7da50bb4ca130388bc47e78d102ae4e5ddcfde
4
+ data.tar.gz: 6b57f7aa93ef06246465a3e143f444b0cb61105f1fd775fbce791d0b46fabc7d
5
5
  SHA512:
6
- metadata.gz: b241f244f12d35b26ebaec39eeedbf709784e49b3f5b3e79bbd3bbf636f7b2bdc225924fda305a99a366c1880b222b2b40de3c2fb4d9117c63183ae6e2e9a114
7
- data.tar.gz: b9514f576ef22a7f828815cf50885014d64a7c4f1fa728fcfd2072b3a40708ec636aeb9fdc5cfd3fa7b9e0a6a39235690b6fea308dbf68c37b9c8492db75663c
6
+ metadata.gz: dae3b2adb921947200e1cc819c6f3f3918251a1298a752ed9ee7b19da7a515e66e6f87b21402b30ab6e81e03769bdba9d73f23101b42ef87c9ca8a8f5a8baf62
7
+ data.tar.gz: 5ba9e32129ab8331aec76ddcda9d81445835c28fefe308c5b27bb65fe1780c41f2d5f0727eb1702a0403da342c89892c6186fcd553d13587174a2ff5f0d5f6d8
@@ -0,0 +1,5 @@
1
+ label: "## Table of Contents"
2
+ patterns:
3
+ - "README.md"
4
+ - doc/*.md
5
+ root_dir: "."
data/.semver CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 4
4
- :patch: 4
3
+ :minor: 5
4
+ :patch: 0
5
5
  :special: ''
6
6
  :metadata: ''
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  ## [Unreleased]
2
- ## [0.4.4] 2023-01-01
3
- - fixed first issue of the year. Issue 14 with te --role option actually writing the role content into the prime prompts file.
2
+ ## [0.5.0] 2024-01-05
3
+ - breaking changes:
4
+ - changed `--config` to `--config_file`
5
+ - changed `--env` to `--shell`
6
+ - changed `--output` to `--out_file`
7
+ - changed default `out_file` to `STDOUT`
4
8
 
5
9
  ## [0.4.3] 2023-12-31
6
10
  - added --env to process embedded system environment variables and shell commands within a prompt.
data/README.md CHANGED
@@ -1,14 +1,15 @@
1
1
  # AI Assistant (AIA)
2
2
 
3
- `aia` is a command-line utility that integrates prameterized prompt management with generative AI (gen-AI) execution.
3
+ `aia` is a command-line utility that facilitates interaction with AI models. It automates the management of pre-compositional prompts and executes generative AI (Gen-AI) commands on those prompts.
4
4
 
5
- Uses the gem "prompt_manager" to manage the prompts sent to the `mods` command-line utility. Uses the command line tools "ripgrep" to search for prompts to send and "fzf" to select the prompts that match the search term.
5
+ It leverages the `prompt_manager` gem to manage prompts for the `mods` and `sgpt` CLI utilities. It utilizes "ripgrep" for searching for prompt files. It uses `fzf` for prompt selection based on a search term and fuzzy matching.
6
6
 
7
- **Most Recent Change**
7
+ **Most Recent Change**: Refer to the [Changelog](CHANGELOG.md)
8
8
 
9
- v0.4.3 - Added the --env and --erb options. Prompts can now be dynamic.
10
- v0.4.2 - Added a --role option to be prepended to a primary prompt.
11
- v0.4.1 - Added --chat and --speak options. Prompt directives are now supported.
9
+ v0.5.0 - Breaking changes:
10
+ - `--config` is now `--config_file`
11
+ - `--env` is now `--shell`
12
+ - `--output` is now `--out_file`
12
13
 
13
14
  <!-- Tocer[start]: Auto-generated, don't remove. -->
14
15
 
@@ -16,15 +17,20 @@ v0.4.1 - Added --chat and --speak options. Prompt directives are now supported.
16
17
 
17
18
  - [Installation](#installation)
18
19
  - [Usage](#usage)
19
- - [System Environment Variables (envar)](#system-environment-variables-envar)
20
- - [System Environment Variables inside of a Prompt](#system-environment-variables-inside-of-a-prompt)
20
+ - [Configuration Using Envars](#configuration-using-envars)
21
+ - [Shell Integration inside of a Prompt](#shell-integration-inside-of-a-prompt)
22
+ - [Access to System Environment Variables](#access-to-system-environment-variables)
23
+ - [Dynamic Shell Commands](#dynamic-shell-commands)
21
24
  - [*E*mbedded *R*u*B*y (ERB)](#embedded-ruby-erb)
22
25
  - [Prompt Directives](#prompt-directives)
26
+ - [`aia` Specific Directive Commands](#aia-specific-directive-commands)
27
+ - [//config](#config)
28
+ - [Backend Directive Commands](#backend-directive-commands)
23
29
  - [All About ROLES](#all-about-roles)
24
30
  - [Other Ways to Insert Roles into Prompts](#other-ways-to-insert-roles-into-prompts)
25
31
  - [External CLI Tools Used](#external-cli-tools-used)
26
32
  - [Shell Completion](#shell-completion)
27
- - [Ny Most Powerful Prompt](#ny-most-powerful-prompt)
33
+ - [My Most Powerful Prompt](#my-most-powerful-prompt)
28
34
  - [Development](#development)
29
35
  - [Contributing](#contributing)
30
36
  - [License](#license)
@@ -91,7 +97,7 @@ ARGUMENTS
91
97
 
92
98
  OPTIONS
93
99
  --chat begin a chat session with the backend after the initial prompt response; will
94
- set --no-output so that the backend response comes to STDOUT.
100
+ set --no-out_file so that the backend response comes to STDOUT.
95
101
 
96
102
  --completion SHELL_NAME
97
103
 
@@ -101,7 +107,7 @@ OPTIONS
101
107
  Invokes an editor on the prompt file. You can make changes to the prompt file,
102
108
  save it and the newly saved prompt will be processed by the backend.
103
109
 
104
- --env This option tells aia to replace references to system environment variables in
110
+ --shell This option tells aia to replace references to system environment variables in
105
111
  the prompt with the value of the envar. envars are like $HOME and ${HOME} in
106
112
  this example their occurance will be replaced by the value of ENV[‘HOME’].
107
113
  Also the dynamic shell command in the pattern $(shell command) will be executed
@@ -153,7 +159,7 @@ OPTIONS
153
159
  -m, --[no]-markdown
154
160
  Format with Markdown - default is true
155
161
 
156
- -o, --[no]-output PATH_TO_OUTPUT_FILE
162
+ -o, --[no]-out_file PATH_TO_OUTPUT_FILE
157
163
  Out FILENAME - default is ./temp.md
158
164
 
159
165
  -p, --prompts PATH_TO_DIRECTORY
@@ -202,8 +208,8 @@ OpenAI ACCOUNT IS REQUIRED
202
208
 
203
209
  USAGE NOTES
204
210
  aia is designed for flexibility, allowing users to pass prompt ids and context files
205
- as arguments. Some options change the behavior of the output, such as --output for
206
- specifying a file or --no-output for disabling file output in favor of standard output
211
+ as arguments. Some options change the behavior of the output, such as ---out_file for
212
+ specifying a file or --no-out_file for disabling file output in favor of standard output
207
213
  (STDPIT).
208
214
 
209
215
  The --completion option displays a script that enables prompt ID auto-completion for
@@ -250,9 +256,9 @@ AUTHOR
250
256
  AIA 2024-01-01 aia(1)
251
257
  ```
252
258
 
253
- ## System Environment Variables (envar)
259
+ ## Configuration Using Envars
254
260
 
255
- The `aia` configuration defaults can be over-ridden by envars with the prefix "AIA_" followed by the config item name also in uppercase. All configuration items can be over-ridden in this way by an envar. The following table show a few examples.
261
+ The `aia` configuration defaults can be over-ridden by system environment variables *(envars)* with the prefix "AIA_" followed by the config item name also in uppercase. All configuration items can be over-ridden in this way by an envar. The following table show a few examples.
256
262
 
257
263
  | Config Item | Default Value | envar key |
258
264
  | ------------- | ------------- | --------- |
@@ -265,58 +271,123 @@ The `aia` configuration defaults can be over-ridden by envars with the prefix "A
265
271
  | log_file | ~/.prompts/_prompts.log | AIA_LOG_FILE |
266
272
  | markdown | true | AIA_MARKDOWN |
267
273
  | model | gpt-4-1106-preview | AIA_MODEL |
268
- | output_file | temp.md | AIA_OUTPUT_FILE |
274
+ | out_file | STDOUT | AIA_OUT_FILE |
269
275
  | prompts_dir | ~/.prompts | AIA_PROMPTS_DIR |
270
276
  | VERBOSE | FALSE | AIA_VERBOSE |
271
277
 
272
278
 
273
- See the `@options` hash in the `cli.rb` file for a complete list. There are some config items that do not necessarily make sense for use as an envar over-ride. For example if you set `export AIA_DUMP=yaml` then `aia` would dump a config file in HAML format and exit every time it is ran until you finally did `unset AIA_DUMP`
279
+ See the `@options` hash in the `cli.rb` file for a complete list. There are some config items that do not necessarily make sense for use as an envar over-ride. For example if you set `export AIA_DUMP=yaml` then `aia` would dump a config file in YAML format and exit every time it is ran until you finally did `unset AIA_DUMP`
274
280
 
275
281
  In addition to these config items for `aia` the optional command line parameters for the backend prompt processing utilities (mods and sgpt) can also be set using envars with the "AIA_" prefix. For example "export AIA_TOPP=1.0" will set the "--topp 1.0" command line option for the `mods` utility when its used as the backend processor.
276
282
 
277
- ### System Environment Variables inside of a Prompt
283
+ ## Shell Integration inside of a Prompt
278
284
 
279
- The cpmmand line option "--env" instructs `aia` to replace any system environment variable references in the prompt text with the value of the system envornment variable. So patterns like $HOME and ${HOME} in the prompt will be replaced with the value of ENV['HOME'].
285
+ Using the option `--shell` enables `aia` to access your terminal's shell environment from inside the prompt text.
280
286
 
281
- As an added bonus, dynamic content can be inserted into the prompt using the pattern $(shell command) where the output of the shell command will replace the $(...) pattern.
287
+ #### Access to System Environment Variables
288
+
289
+ `aia` can replace any system environment variable (envar) references in the prompt text with the value of the envar. Patterns like $USER and ${USER} in the prompt will be replaced with that envar's value - the name of the user's account. Any envar can be used.
290
+
291
+ #### Dynamic Shell Commands
292
+
293
+ Dynamic content can be inserted into the prompt using the pattern $(shell command) where the output of the shell command will replace the $(...) pattern.
294
+
295
+ Consider the power to tailoring a prompt to your specific operating system:
296
+
297
+ ```
298
+ As a system administration on a $(uname -v) platform what is the best way to [DO_SOMETHING]
299
+ ```
300
+
301
+ or insert content from a file in your home directory:
302
+
303
+ ```
304
+ Given the following constraints $(cat ~/3_laws_of_robotics.txt) determine the best way to instruct my roomba to clean my kids room.
305
+ ```
282
306
 
283
- That's enough power to get anyone into deep trouble. Wait there's more coming. Do you want a full programming language in your prompt? Feel like running the prompt through ERB before sending it to the backend? I've been thinking about it. Should be a simple thing to do. Yes it was.
284
307
 
285
308
  ## *E*mbedded *R*u*B*y (ERB)
286
309
 
287
- The --erb options now submits the prompt text through the ERB parser for execution before environment variable, keyword and dynamic shell replace take place. With this much dynamic prompt manipulation we should really be able to get into trouble!
310
+ 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.
311
+
312
+ 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.
313
+
314
+ Most websites that have information about ERB will give examples of how to use ERB to generate dynamice 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.
288
315
 
289
- If you are not a Rubyist and do not know about ERB see this [webpage](https://ruby-doc.org/stdlib-3.0.0/libdoc/erb/rdoc/ERB.html) for some information about the power of embedded Ruby.
290
316
 
291
317
  ## Prompt Directives
292
318
 
293
- Downstream processing directives were added to the `prompt_manager` gem at version 0.4.1. These directives are lines in the prompt text file that begin with "//"
319
+ Downstream processing directives were added to the `prompt_manager` gem used by `au` at version 0.4.1. These directives are lines in the prompt text file that begin with "//" having this pattern:
320
+
321
+ ```
322
+ //command parameters
323
+ ```
324
+
325
+ There is no space between the "//" and the command.
294
326
 
295
- For example if a prompt text file has this line:
327
+ ### `aia` Specific Directive Commands
296
328
 
297
- > //config chat? = true
329
+ At this time `aia` only has one directive command `//config`
298
330
 
299
- That prompt will enter the chat loop regardles of the presents of a "--chat" CLI option or the setting of the envar AIA_CHAT.
331
+ #### //config
300
332
 
301
- BTW did I mention that `aia` supports a chat mode where you can send an initial prompt to the backend and then followup the backend's reponse with additional keyboard entered questions, instructions, prompts etc.
333
+ The `//config` directive within a prompt text file is used to tailor the specific configuration environment for the prompt. All configuration items are available to have their values changed. The order of value assignment for a configuration item starts with the default value which is replaced by the envar value which is replaced by the command line option value which is replaced by the value from the config file.
302
334
 
303
- See the [AIA::Directives](lib/aia/directives.rb) class to see what directives are available on the fromend within `aia`.
335
+ The `//config` is the last and final way of changing the value for a configuration item for a specific prompt.
304
336
 
305
- See the [AIA::Mods](lib/aia/tools/mods.rb) class to for directives that are available to the `mods` backend.
337
+ The switch options are treated like booleans. They are either `true` or `false`. Their name within the context of a `//config` directive always ends with a "?" character - question mark.
306
338
 
307
- See the [AIA::Sgpt](lib/aia/tools/sgpt.rb) class to for directives that are available to the `sgpt` backend.
339
+ To set the value of a switch using ``//config` for example `--terse` or `--chat` to this:
340
+
341
+ ```
342
+ //config chat? = true
343
+ //config terse? = true
344
+ ```
345
+
346
+ A configuration item such as `--out_file` or `--model` has an associated value on the command line. To set that value with the `//config` directive do it like this:
347
+
348
+ ```
349
+ //config model = gpt-3.5-turbo
350
+ //config out_file = temp.md
351
+ //config backend = mods
352
+ ```
353
+
354
+ ### Backend Directive Commands
355
+
356
+ See the source code for the directives supported by the backends which at this time are configuration-based as well.
357
+
358
+ - [mods](lib/aia/tools/mods.rb)
359
+ - [sgpt](lib/aia/tools/sgpt.rb)
360
+
361
+ FOr example `mods` has a configuration item `topp` which can be set by a directive in a prompt text file directly.
362
+
363
+ ```
364
+ //topp 1.5
365
+ ```
366
+
367
+ If `mods` is not the backend the `//topp` direcive is ignored.
308
368
 
309
369
  ## All About ROLES
310
370
 
311
- `aia` provides the "-r --role" CLI option to identify a prompt ID within your prompts directory which defines the context within which the LLM is to provide its response. The text of the role ID is pre-pended to the text of the primary prompt to form a complete prompt to be processed by the backend.
371
+ `aia` provides the `--role` CLI option to identify a prompt ID within your prompts directory which defines the context within which the LLM is to provide its response. The text of the role ID is pre-pended to the text of the primary prompt to form a complete prompt to be processed by the backend.
312
372
 
313
373
  For example consider:
314
374
 
315
- > aia -r ruby refactor my_class.rb
375
+ ```shell
376
+ aia -r ruby refactor my_class.rb
377
+ ```
378
+
379
+ Within the prompts directory the contents of the text file `ruby.txt` will be pre-pre-pended to the contents of the `refactor.txt` file to produce a complete prompt. That complete prompt will have any parameters then directives processed before sending the prompt text to the backend.
316
380
 
317
- Within the prompts directory the contents of the text file `ruby.txt` will be pre-pre-pended to the contents of the refactor.txt file to produce a complete prompt. That complete prompt will have any parameters then directives processed before sending the prompt text to the backend.
381
+ Note that `--role` is just a way of saying add this prompt text file to the front of this other prompt text file. The contents of the "role" prompt could be anything. It does not necessarily have be an actual role.
382
+
383
+ You might consider have a sub-directory of your `prompts_dir` name `role` in which you put the prompt files that describe the various roles that you commonly use with your prompts. `aia` fully supports a directory tree within the `prompts_dir` as a way of organization or classification of your different prompt text files.
384
+
385
+ ```shell
386
+ aia -r roles/sw_eng doc_the_methods my_class.rb
387
+ ```
388
+
389
+ In this example the prompt text file `$AIA_PROMPTS_DIR/roles/sw_eng.txt` is prepended to the prompt text file `$AIA_PROMPTS_DIR/doc_the_methods.txt`
318
390
 
319
- Note that "role" is just a way of saying add this prompt to the front of this other prompt. The contents of the "role" prompt could be anything. It does not necessarily have be an actual role.
320
391
 
321
392
  ### Other Ways to Insert Roles into Prompts
322
393
 
@@ -360,13 +431,15 @@ export EDITOR="subl -w"
360
431
 
361
432
  You can setup a completion function in your shell that will complete on the prompt_id saved in your `prompts_dir` - functions for `bash`, `fish` and `zsh` are available. To get a copy of these functions do this:
362
433
 
363
- > `aia --completion bash`
434
+ ```shell
435
+ aia --completion bash
436
+ ```
364
437
 
365
438
  If you're not a fan of "born again" replace `bash` with one of the others.
366
439
 
367
440
  Copy the function to a place where it can be installed in your shell's instance. This might be a `.profile` or `.bashrc` file, etc.
368
441
 
369
- ## Ny Most Powerful Prompt
442
+ ## My Most Powerful Prompt
370
443
 
371
444
  This is just between you and me so don't go blabbing this around to everyone. My most power prompt is in a file named `ad_hoc.txt`. It looks like this:
372
445
 
@@ -376,11 +449,17 @@ Yep. Just a single parameter for which I can provide a value of anything that i
376
449
 
377
450
  Which do you think is better to have in your shell's history file?
378
451
 
379
- > mods "As a certified public accountant specializing in forensic audit and analysis of public company financial statements, what do you think of mine? What is the best way to hide the millions dracma that I've skimmed?" < financial_statement.txt
452
+ ```shell
453
+ mods "As a certified public accountant specializing in forensic audit and analysis of public company financial statements, what do you think of mine? What is the best way to hide the millions dracma that I've skimmed?" < financial_statement.txt
454
+ ```
380
455
 
381
- > aia ad_hoc financial_statement.txt
456
+ or
382
457
 
383
- Both do the same thing; however, aia does not put the text of the prompt into the shell's history file.... of course the keyword/parameter value is saved in the prompt's JSON file and the prompt with the response are logged unless --no-log is specified; but, its not messing up the shell history!
458
+ ```shell
459
+ aia ad_hoc financial_statement.txt
460
+ ```
461
+
462
+ Both do the same thing; however, `aia` does not put the text of the prompt into the shell's history file.... of course the keyword/parameter value is saved in the prompt's JSON file and the prompt with the response are logged unless `--no-log` is specified; but, its not messing up the shell history!
384
463
 
385
464
  ## Development
386
465
 
@@ -394,16 +473,9 @@ I've designed `aia` so that it should be easy to integrate other backend LLM pro
394
473
 
395
474
  When you find problems with `aia` please note them as an issue. This thing was written mostly by a human and you know how error prone humans are. There should be plenty of errors to find.
396
475
 
397
- Also I'm interested in doing more with the prompt directives. I'm thinking that there is a way to include dynamic content into the prompt computationally. Maybe something like tjos wpi;d be easu tp dp:
398
-
399
- > //insert url https://www.whitehouse.gov/briefing-room/
400
- > //insert file path_to_file.txt
401
-
402
- or maybe incorporating the contents of system environment variables into prompts using $UPPERCASE or $(command) or ${envar_name} patterns.
403
-
404
- I've also been thinking that the REGEX used to identify a keyword within a prompt could be a configuration item. I chose to use square brackets and uppercase in the default regex; maybe, you have a collection of prompt files that use some other regex. Why should it be one way and not the other.
476
+ I've been thinking that the REGEX used to identify a keyword within a prompt could be a configuration item. I chose to use square brackets and uppercase in the default regex; maybe, you have a collection of prompt files that use some other regex. Why should it be one way and not the other.
405
477
 
406
- Also I'm not happy with the way where I hve some command line options for external command hard coded. I think they should be part of the configuration as well. For example the way I'm using `rg` and `fzf` may not be the way that you want to use them.
478
+ Also I'm not happy with the way where I a some command line options for external command hard coded. I think they should be part of the configuration as well. For example the way I'm using `rg` and `fzf` may not be the way that you want to use them.
407
479
 
408
480
  ## License
409
481
 
@@ -0,0 +1,474 @@
1
+ ## AIA and Pre-compositional AI Prompts
2
+
3
+ Pre-compositional templating of prompts using `AIA` endows prompt engineers with a significant level of power typically reserved for specialized gen-AI applications. `AIA` is a versatile command-line utility, with capabilities limited only by the imagination behind the prompts you create.
4
+
5
+ A pre-compositional prompt acts as a foundational template, which can be expanded into a fully fleshed-out prompt. This prompt is then handed off to a generative AI processor to transform into a response that meets your specific requirements.
6
+
7
+ <!-- Tocer[start]: Auto-generated, don't remove. -->
8
+
9
+ ## Table of Contents
10
+
11
+ - [Introduction](#introduction)
12
+ - [Large Language Models (LLM)](#large-language-models-llm)
13
+ - [Running AIA](#running-aia)
14
+ - [Set Up a Prompts Directory](#set-up-a-prompts-directory)
15
+ - [AIA Supports Parameterized Prompts](#aia-supports-parameterized-prompts)
16
+ - [Create a Parameterized Prompt](#create-a-parameterized-prompt)
17
+ - [The Next Parts](#the-next-parts)
18
+ - [Comments](#comments)
19
+ - [Line Comments](#line-comments)
20
+ - [End of File Block Comment](#end-of-file-block-comment)
21
+ - [Directives](#directives)
22
+ - [The `config` Directive](#the-config-directive)
23
+ - [Parameter Substitution in Directives](#parameter-substitution-in-directives)
24
+ - [Shell Integration](#shell-integration)
25
+ - [Accessing System Environment Variables](#accessing-system-environment-variables)
26
+ - [Contextual System Environment Variables](#contextual-system-environment-variables)
27
+ - [Invoking Shell Commands](#invoking-shell-commands)
28
+ - [Harnessing Ruby's Capabilities](#harnessing-rubys-capabilities)
29
+ - [The Concept of Binding](#the-concept-of-binding)
30
+ - [ERB Syntax at a Glance](#erb-syntax-at-a-glance)
31
+ - [Conditional Logic](#conditional-logic)
32
+ - [Accessing Current Data](#accessing-current-data)
33
+ - [Summary of AIA Command-Line Tool](#summary-of-aia-command-line-tool)
34
+
35
+ <!-- Tocer[finish]: Auto-generated, don't remove. -->
36
+
37
+
38
+
39
+ ## Introduction
40
+
41
+ The pre-compositional prompt management as utilized by the `AIA` (AI Assistant) command-line utility are a powerful extension to using the GPT technology in the terminal. If terminal programs and command-line interfaces (CLIs) aren't part of your workflow, then the current version of `AIA` may not be suitable for you.
42
+
43
+ `AIA` requires a Ruby environment. To install and run `AIA` you must have Ruby installed on your system. If you are not sure if your system has Ruby installed do this in your terminal to find out:
44
+
45
+ ```shell
46
+ ruby --version
47
+ ```
48
+
49
+ To install Ruby on your machine, follow the official [Ruby installation guide](https://www.ruby-lang.org/en/documentation/installation/).
50
+
51
+ With Ruby installed, you can set up `AIA` through your terminal with this command:
52
+
53
+ ```shell
54
+ gem install aia
55
+ ```
56
+
57
+ For the full potential of `AIA`, these CLI utilities are also needed:
58
+
59
+ ```shell
60
+ brew install ripgrep fzf mods
61
+ ```
62
+
63
+ For operating systems other than macOS, such as Linux or Windows, use their respective package managers (`apt`, `yum`, `dnf`, `scoop`, `choco`, etc.) to install the following tools:
64
+
65
+ - `ripgrep`: An advanced search tool akin to `grep`.
66
+ - `fzf`: A versatile command-line fuzzy finder.
67
+ - `mods`: An AI-enhanced command-line tool for processing the outputs of other commands.
68
+
69
+ ### Large Language Models (LLM)
70
+
71
+ LLMs and GPTs (Generative Pre-trained Transformers) have sparked a revolution in AI by predicting text, word, sentence, pixel, and sound sequences that fit patterns initiated by a user prompt. This revolution started when computer scientist realized that syntactic approaches to language translations were ineffective in creating good translations. A statistical approach was created in which the probabilities of one set of language characters or phrases meant the same as another languages characters or phrases.
72
+
73
+ For example after analysing a large number of documents about the American government the phrase "The White" is most likely followed by "House." Its not magic. Its not thinking. Its statistics or magic if you believe that matematics is magic.
74
+
75
+ ### Running AIA
76
+
77
+ Executing the command:
78
+
79
+ ```shell
80
+ aia
81
+ ```
82
+
83
+ will prompt:
84
+
85
+ ```shell
86
+ Please provide a prompt ID.
87
+ ```
88
+
89
+ `AIA` requires a prompt ID to function. A prompt ID corresponds to the base name of a text file in your `prompts_dir` directory. To define your prompts directory, you can set an environment variable (`AIA_PROMPTS_DIR`) or specify the path directly as a command-line option. To see all of the `AIA` command-line options do:
90
+
91
+ ```shell
92
+ aia --help
93
+ ```
94
+
95
+ ### Set Up a Prompts Directory
96
+
97
+ The easiest way to tell `AIA` where the prompts directory is located is using the system environment variable $AIA_PROMPTS_DIR
98
+
99
+ ```shell
100
+ export AIA_PROMPTS_DIR=~/my_prompts
101
+ mkdir $AIA_PROMPTS_DIR
102
+ ```
103
+
104
+ ## AIA Supports Parameterized Prompts
105
+
106
+ `AIA`'s first layer of pre-compositional prompt management is parameterization -— where placeholders within a prompt are replaced with user-defined values. By default, `AIA` considers any uppercase sequence within square brackets as a placeholder.
107
+
108
+ Examples of placeholders include:
109
+
110
+ - `[KEYWORD]`
111
+ - `[USER_ROLE]`
112
+ - `[COMPUTER_LANGUAGE]`
113
+
114
+ When using `AIA` with a sample prompt:
115
+
116
+ ```shell
117
+ As a [ROLE], I want to [DO_SOMETHING].
118
+ ```
119
+
120
+ `AIA` will ask for substitutions for each placeholder (keyword/parameter), saving your responses with the prompt file for future use. The last-used value for each placeholder is the default for subsequent uses of that specific prompt.
121
+
122
+ ### Create a Parameterized Prompt
123
+
124
+ Let's create a simple yet flexible prompt file:
125
+
126
+ ```shell
127
+ echo "[DO_WHAT]" > $AIA_PROMPTS_DIR/ad_hoc.txt
128
+ ```
129
+
130
+ The associated "Prompt ID" is "ad_hoc" -— the basename of the file sans the ".txt" extension. Using the "ad_hoc" prompt ID:
131
+
132
+ ```shell
133
+ aia ad_hoc
134
+ ```
135
+
136
+ results in an interaction to specify a value for `[DO_WHAT]`. For instance, entering "tell me a joke" to replace "[DO_WHAT]" will generate a response but whether its a funny joke or a dad joke is completely up to the electrons that controll the statistics of the LLM. :)
137
+
138
+ ### The Next Parts
139
+
140
+ Subsequent sections in this series cover:
141
+
142
+ - **Comments and Directives**: Lines starting with "#" are comments and ignored during processing. Lines starting with "//" are directives and are executed (e.g., "//config chat? = true" to set interactive chat mode for the prompt.)
143
+
144
+ - **Shell Integration**: Access to system environment variables and dynamic shell commands using the `--shell` option.
145
+
146
+ - **Embedded RuBy (ERB)**: For expert users, the option `--erb` allows Ruby code to be embedded in prompts (`<%= ruby_code %>`), offering unparalleled flexibility in prompt composition. This is one way to embed current data into prompts for LLMs which do not have access to current real-time data.
147
+
148
+ > A pre-compositional prompt essentially serves as a template that expands into a full prompt, which is then processed by a generative AI to yield a tailored response.
149
+ >
150
+ > To recap, a prompt ID corresponds to the basename of a text file in a prompts directory. The simplest way to inform `AIA` of your prompts directory is through the environment variable `$AIA_PROMPTS_DIR`. For a prompt ID `ad_hoc`, `AIA` will read the prompt from `$AIA_PROMPTS_DIR/ad_hoc.txt`.
151
+ >
152
+ > NOTE: If you're on MacOS or another system where file extensions aren't visible in the terminal by default, consider adjusting your system settings to display file extensions.
153
+
154
+ ## Comments
155
+
156
+ AI prompts can be thought of as programs that an AI processes to generate responses. Sometimes you get the desired outcome, and other times you don't. Iteration often precedes success, and you may later forget the rationale behind your original construction. Non-processable comments serve as documentation.
157
+
158
+ Comments can also shed light on the expected values for specific keywords or parameters.
159
+
160
+ Both comments and prompt content are fully searchable.
161
+
162
+ ### Line Comments
163
+
164
+ A line beginning with the `#` character is treated as a line comment and is disregarded during prompt processing. Line comments are useful for providing metadata such as the file path, prompt description, author, or other identifying details.
165
+
166
+ Since line comments are searchable, they can also provide auxiliary context relevant to the prompt.
167
+
168
+ Below is an example of a `multi_step` prompt file with line comments:
169
+
170
+ ```shell
171
+ # ~/prompts/multi_step.txt
172
+ # Description: A template for multi-step prompts
173
+
174
+ # Provide the LLM with the response format
175
+ [STEP_1]
176
+
177
+ # Define the role for the LLM
178
+ [STEP_2]
179
+
180
+ # Specify the task for the LLM
181
+ [STEP_3]
182
+ ```
183
+
184
+ ### End of File Block Comment
185
+
186
+ For content that doesn't fit into line comments, an end-of-file (EOF) comment block can be denoted as follows:
187
+
188
+ ```shell
189
+ __END__
190
+ ```
191
+
192
+ This indicates to `AIA` that no more prompt text follows.
193
+
194
+ Example EOF block comment in a prompt file:
195
+
196
+ ```shell
197
+ Tell me some dad jokes.
198
+
199
+ __END__
200
+
201
+ 1. I'm reading a book on anti-gravity. It's impossible to put down.
202
+ 2. Did you hear about the restaurant on the moon? Great food, but no atmosphere.
203
+ 3. What do you call fake spaghetti? An impasta.
204
+ ```
205
+
206
+ ## Directives
207
+
208
+ A directive is a line-specific action within the context of a prompt. It begins with the characters `//`. Here's the basic syntax of a directive:
209
+
210
+ ```shell
211
+ //directive parameters
212
+ ```
213
+
214
+ There should be no space between the `//` and the directive name, which is followed by at least one space before its parameters.
215
+
216
+ ### The `config` Directive
217
+
218
+ Directives commonly adjust the configuration settings of a prompt. For example, to enter an interactive chat session without always using the `--chat` option, include a directive in the prompt file, as seen in `$AIA_PROMPTS_DIR/chat.txt`:
219
+
220
+ ```shell
221
+ //config chat? = true
222
+ //config terse? = true
223
+
224
+ [WHAT IS ON YOUR MIND]
225
+ ```
226
+
227
+ The first directive simulates the `--chat` command line option, while the second imitates `--terse`.
228
+
229
+ To start a chat session using this prompt, simply execute:
230
+
231
+ ```shell
232
+ aia chat
233
+ ```
234
+
235
+ You can modify any configuration items in a prompt, including the AI model, the response's output file, or the fine-tuned control parameters like temperature and `topp`. Its also possible to direct the prompt to a backend processor other than the default. (Current `AIA` supports two backend processors `mods` and `sgpt`. `mods` is the default because of its significant flexibility.)
236
+
237
+ Additional directive commands were introduced in `AIA` v0.4.1, but might be deprecated due to the integration of embedded shell commands and Ruby sequences.
238
+
239
+ ### Parameter Substitution in Directives
240
+
241
+ As discussed in Part 1, parameters in prompts are interchangeable. This is also true for directives:
242
+
243
+ ```shell
244
+ //config terse? = [TERSE_YES_OR_NO]
245
+ ```
246
+
247
+ While one could opt to use the `--terse` command line toggle directly, employing a directive allows the prompt to adapt between verbosity levels.
248
+
249
+ Parameter substitutions apply uniformly to directives, just like any other part of the prompt.
250
+
251
+ ## Shell Integration
252
+
253
+ The `--shell` option permits shell integration, facilitating access to system environment variables (envars) and the execution of embedded shell commands within prompts.
254
+
255
+ ### Accessing System Environment Variables
256
+
257
+ Incorporating envars within prompts is somewhat akin to parameter usage. With parameters, however, users are asked to provide the values for substitution. Conversely, when an envar is used, its value is automatically fetched from the shell and embedded.
258
+
259
+ Envars may be indicated by one of two patterns:
260
+
261
+ - `$UPPERCASE_WORD`
262
+ - `${UPPERCASE_WORD}`
263
+
264
+ For instance, consider the following prompts:
265
+
266
+ ```shell
267
+ As a $ROLE ...
268
+ ```
269
+
270
+ versus
271
+
272
+ ```shell
273
+ As a [ROLE] ...
274
+ ```
275
+
276
+ In the first example, the shell supplies the `$ROLE` value, whereas the second prompt implies interaction with the user to define `[ROLE]`.
277
+
278
+ In scenarios where multiple prompts utilize the same `ROLE`, it is practical to set an envar to circumvent the interactive step:
279
+
280
+ ```shell
281
+ export ROLE="expert Ruby on Rails software developer"
282
+ aia example1 --shell -o response1.md
283
+ aia example2 --shell -o response2.md
284
+ # ...
285
+ ```
286
+
287
+ #### Contextual System Environment Variables
288
+
289
+ With tools like `direnv`, you can set environment variables specific to your current directory tree context. On MacOS, `direnv` can be installed via `brew install direnv`. There value only exists so long as you are working with the directory tree covered by the `.envrc` file the `direnv` uses to define its envars.
290
+
291
+ Imagine working in two project directory trees with different roles. In a `src` directory, your role is that of a software developer, whereas in a `doc` directory, you perform as a documentation specialist.
292
+
293
+ For the `src` directory, your `.envrc` file could be:
294
+
295
+ ```shell
296
+ export ROLE="Crystal software developer"
297
+ ```
298
+
299
+ Meanwhile, within the `doc` directory, `.envrc` might contain:
300
+
301
+ ```shell
302
+ export ROLE="editorial assistant with experience writing documentation"
303
+ ```
304
+
305
+ Now, consider this prompt, suitable for use in both contexts:
306
+
307
+ ```shell
308
+ # ~/.prompts/review.txt
309
+
310
+ As a $ROLE, review the following file and suggest improvements.
311
+ ```
312
+
313
+ Depending on the active directory, invoking the prompt in `src` yields suggestions tailored for Crystal source code, whereas in `doc`, it provides advice based on markdown-formatted documentation.
314
+
315
+ ### Invoking Shell Commands
316
+
317
+ Additionally, the `--shell` option enables `AIA` to execute shell commands embedded in the prompt. The result of the shell command is then injected directly into the spot where the command is placed in the text file.
318
+
319
+ Here's the pattern for embedding a shell command:
320
+
321
+ ```shell
322
+ $(...)
323
+ ```
324
+
325
+ Whatever lies between the parentheses is executed as a shell command, ranging from the straightforward to the complex, depending on the desired outcome. Any output directed to `STDOUT` will be incorporated into the prompt text where specified.
326
+
327
+ For a practical example, consider this prompt which is intended for scrutinizing a system log file:
328
+
329
+ ```shell
330
+ # ~/.prompts/summarize_log.txt
331
+ # Description: Examine a system log file for issues
332
+
333
+ As an experienced system administrator and senior DevOps engineer on the $(uname -v) platform, please review the following log entries and summarize any potential issues, providing recommendations for mitigation: $(tail -n $LOG_ENTRIES $LOG_FILE)
334
+ ```
335
+
336
+
337
+
338
+ > A pre-compositional prompt serves as a foundational template. It's expanded into a fully-fledged prompt, ready to be handed off to a generative AI processor. The end goal is a response tailored to your specific requirements.
339
+
340
+
341
+ ## Harnessing Ruby's Capabilities
342
+
343
+ The `AIA` command-line option `--erb` ebables the execution of embedded Ruby code within a prompt text file.
344
+
345
+ Ruby ERB (Embedded Ruby) is a system designed for interweaving Ruby code with text documents. This is especially useful for content that requires dynamic generation such as text files that undergo computation or data incorporation.
346
+
347
+ ERB boasts numerous powerful features:
348
+
349
+ 1. **Ruby Code Embedding**: Insert and execute any valid Ruby code inside a text document. Whether it's performing calculations or invoking methods, ERB's capabilities are far-reaching.
350
+
351
+ 2. **Safe Evaluation**: ERB templates can be evaluated within a `binding` that exposes only select variables and methods. This precaution is crucial when dealing with untrusted template content.
352
+
353
+ 3. **Control Structures**: Adopt Ruby control structures such as loops and conditionals within ERB, allowing conditional content inclusion.
354
+
355
+ 4. **User-Friendly**: The ERB syntax is straightforward and blends seamlessly with usual text, providing a smooth experience for those familiar with HTML and similar languages.
356
+
357
+ 5. **Included in Ruby's Standard Library**: ERB comes bundled with Ruby, negating the need for extra installations where Ruby is present.
358
+
359
+ 6. **Industry Standard**: As the default engine for many Ruby frameworks, including Rails for views, ERB's reliability and support are well-established.
360
+
361
+ 7. **Error Reporting**: ERB pinpoints errors with detailed stack traces, pointing out the exact line in the template to facilitate debugging.
362
+
363
+ 8. **Commentary**: Integrate comments into an ERB template that remain hidden from the final output, parallel to Ruby comment syntax and the line comments used by `ai` which aids in documentation.
364
+
365
+ ### The Concept of Binding
366
+
367
+ In Ruby — and ERB by extension — the 'binding' refers to the execution context, the sphere where Ruby objects bind to values. It's the scope within which Ruby objects are accessible; objects outside the binding remain out of reach.
368
+
369
+ With the `--erb` option in `AIA`, the binding for Ruby code in a prompt text file is confined to the file itself. You can define anything from scalar values to arrays and hashes, as well as methods or any other Ruby object type you might need. There is great freedom, yet the binding keeps a firm boundary — if an object is undefined within the prompt text, it remains inaccessible.
370
+
371
+ For a detailed exploration of the ERB syntax, refer to [this comprehensive guide](https://www.puppet.com/docs/puppet/latest/lang_template_erb.html).
372
+
373
+ ### ERB Syntax at a Glance
374
+
375
+ Ruby code embedding with ERB offers two main patterns:
376
+
377
+ - `<% ruby code %>` for code execution only.
378
+ - `<%= ruby code %>` for code execution with output.
379
+
380
+ Both patterns support multi-line Ruby code; you're not constrained to a single line.
381
+
382
+ Using the first pattern, `<% ... %>`, you define Ruby objects within the binding — setting variable values, declaring methods, and so forth — without generating any output to the prompt text. After execution the ERB block is removed from the prompt text.
383
+
384
+ The second pattern, `<%= ... %>`, includes an equals sign '=' that signals the output of the ERB block to be inserted into the prompt text. Like the first, the ERB block is removed but its output remains as part of the prompt text.
385
+
386
+ ```ruby
387
+ <$ name = "Ruby" %>
388
+ Say hello to <%= name %> in three different languages.
389
+ ```
390
+
391
+ In the first line the Ruby variable `name` was added to the binding as a Sring type with the value of "Ruby" so that in the second line the value of that variable could be accessed as used within the prompt text.
392
+
393
+
394
+ ### Conditional Logic
395
+
396
+ ERB empowers you to create conditional prompts based on the available binding.
397
+
398
+ ```ruby
399
+ <% "Ruby" == name %>
400
+ Review these files: $(ls -1 *.rb) for duplicate code blocks.
401
+ M% else %>
402
+ Review the grammar and spelling in these files $(ls -1 *.md)
403
+ <% end %>
404
+ ```
405
+
406
+ ### Accessing Current Data
407
+
408
+ By nature, large language models (LLMs) have a historical cut-off for training data. Only recently, generative AI tools granting real-time data access have been introduced. With ERB, you can complement LLM data by integrating up-to-date information directly into your prompts.
409
+
410
+ ```ruby
411
+ <%
412
+ require 'alphavantagerb'
413
+ stock_info = Alphavantage::Stock.new(
414
+ symbol: 'AAPL',
415
+ key: "your api key").quote
416
+ current_price = stock_info.price
417
+ change = stock_info.change
418
+ change_percent = stock_info.change_percent
419
+ %>
420
+
421
+ The latest stock information for Apple Inc. (AAPL) is as follows:
422
+ - Current Price: <%= current_price %>
423
+ - Change: <%= change %>
424
+ - Change (%): <%= change_percent %>
425
+
426
+ Generate a brief analysis of the stock performance based on this information.
427
+ ```
428
+
429
+ This script illustrates how the ERB binding can extend to include external Ruby objects, though external libraries must be explicitly required within the ERB's binding.
430
+
431
+ ## Summary of AIA Command-Line Tool
432
+
433
+ The AIA tool is a command-line interface designed to enable users to interact with an AI assistant, specifically with an AI model backend. It allows users to submit prompts, load context for AI processing, and receive responses from the AI model. The CLI tool is versatile and offers a range of options and configurations.
434
+
435
+ Key features of the AIA tool based on the user manual:
436
+
437
+ - **Command Syntax**: `aia [options]* PROMPT_ID [CONTEXT_FILE]* [-- EXTERNAL_OPTIONS+]`
438
+ - **Core Function**: Sends prompts to and receives responses from an AI backend.
439
+ - **Prompt ID**: A required argument that identifies the prompt to be processed.
440
+ - **Context Files**: Optional files that provide additional context for prompt processing.
441
+ - **External Options**: Additional backend-specific options can be passed after " -- ".
442
+
443
+ **Options Available**:
444
+ - Chat sessions (`--chat`) and turning off standard output for backend-only interaction.
445
+ - Shell completion scripts for various shell types (`--completion`).
446
+ - Configuration dumping (`--dump`).
447
+ - Environment variable substitution (`--shell`) and embedded Ruby execution (`--erb`).
448
+ - Model name specification (`--model`), and text-to-speech output (`--speak`).
449
+ - Terse response directive (`--terse`), checking for updates (`--version`), and backend specification (`-b`).
450
+ - Config files loading (`-c`), debugging mode activation (`-d`), prompt file editing (`-e`).
451
+ - Fuzzy matching for prompts search (`-f`), help display (`-h`), logging (`-l`).
452
+ - Markdown formatting (`-m`), output file specification (`-o`), and prompt directory setting (`-p`).
453
+ - Role ID to configure the AI's approach (`-r`), verbose output (`-v`).
454
+
455
+ **Configuration Hierarchy**:
456
+ - Environment variables prefixed with "AIA_" can alter default settings.
457
+ - Command-line options have precedence over environment variables.
458
+ - Config file settings and prompt directives within files can override other configurations.
459
+
460
+ **OpenAI Account Requirement**:
461
+ - Users must have an OpenAI access token specified through environment variables (`OPENAI_ACCESS_TOKEN` or `OPENAI_API_KEY`).
462
+
463
+ **Usage and Integration**:
464
+ - The tool is designed to be flexible, with the ability to customize output behavior and integrate auto-completion scripts into the shell environment.
465
+ - Configuration formats like YAML and TOML can be outputted using `--dump`.
466
+
467
+ **Prompt Directives**:
468
+ - Lines beginning with "//" in a prompt text file serve as directives, influencing behavior and configurations.
469
+
470
+ **Additional Information and Third-Party Tools**:
471
+ - The manual references additional documentation for OpenAI token access, as well as third-party CLI tools like `mods` and `sgpt` that integrate with AI services.
472
+
473
+ Through this tool, users have the ability to create highly customized interactions with an AI backend, using a command-line environment for efficient and programmable access to AI processing capabilities.
474
+
data/justfile CHANGED
@@ -109,11 +109,26 @@ module_gem := "/Users/dewayne/sandbox/git_repos/gem.just"
109
109
  module_version := "/Users/dewayne/just_modules/version.just"
110
110
 
111
111
 
112
+ # Install Locally
113
+ install: update_toc_in_readmen create_man_page test
114
+ rake install
115
+
116
+
117
+ # Create the TOC
118
+ update_toc_in_readmen:
119
+ rake toc
120
+
121
+
112
122
  # Preview man page
113
123
  preview_man_page:
114
124
  kramdown-man {{RR}}/man/aia.1.md
115
125
 
116
126
 
127
+ # Run Unit Tests
128
+ test:
129
+ rake test
130
+
131
+
117
132
  # View man page
118
133
  view_man_page: create_man_page
119
134
  man {{RR}}/man/aia.1
data/lib/aia/cli.rb CHANGED
@@ -126,7 +126,7 @@ class AIA::Cli
126
126
  completion: [nil, "--completion"],
127
127
  #
128
128
  edit?: [false, "-e --edit"],
129
- env?: [false, "--env"],
129
+ shell?: [false, "--shell"],
130
130
  erb?: [false, "--erb"],
131
131
  debug?: [false, "-d --debug"],
132
132
  verbose?: [false, "-v --verbose"],
@@ -140,9 +140,9 @@ class AIA::Cli
140
140
  #
141
141
  role: ['', "-r --role"],
142
142
  #
143
- config_file:[nil, "-c --config"],
143
+ config_file:[nil, "-c --config_file"],
144
144
  prompts_dir:["~/.prompts", "-p --prompts"],
145
- output_file:["temp.md", "-o --output --no-output"],
145
+ out_file: [STDOUT, "-o --out_file --no-out_file"],
146
146
  log_file: ["~/.prompts/_prompts.log", "-l --log --no-log"],
147
147
  #
148
148
  backend: ['mods', "-b --be --backend --no-backend"],
@@ -36,10 +36,6 @@ class AIA::Directives
36
36
  end
37
37
 
38
38
 
39
- def shell(what) = puts `#{what}`
40
- def ruby(what) = eval what
41
-
42
-
43
39
  # Allows a prompt to change its configuration environment
44
40
  def config(what)
45
41
  parts = what.split(' ')
data/lib/aia/main.rb CHANGED
@@ -21,6 +21,12 @@ class AIA::Main
21
21
 
22
22
  AIA::Cli.new(args)
23
23
 
24
+ if AIA.config.debug?
25
+ debug_me('== CONFIG AFTER CLI =='){[
26
+ "AIA.config"
27
+ ]}
28
+ end
29
+
24
30
  @logger = AIA::Logging.new(AIA.config.log_file)
25
31
 
26
32
  @logger.info(AIA.config) if AIA.config.debug? || AIA.config.verbose?
@@ -62,7 +68,7 @@ class AIA::Main
62
68
  @engine.execute_my_directives
63
69
 
64
70
  if AIA.config.chat?
65
- AIA.config.output_file = STDOUT
71
+ AIA.config.out_file = STDOUT
66
72
  AIA.config.extra = "--quiet" if 'mods' == AIA.config.backend
67
73
  end
68
74
 
@@ -103,7 +109,7 @@ class AIA::Main
103
109
 
104
110
  result = backend.run
105
111
 
106
- AIA.config.output_file.write result
112
+ AIA.config.out_file.write result
107
113
 
108
114
  logger.prompt_result(@prompt, result)
109
115
 
data/lib/aia/prompt.rb CHANGED
@@ -12,9 +12,9 @@ class AIA::Prompt
12
12
  class Fake
13
13
  def id = '_fake_'
14
14
  def path = '_fake_'
15
+ def text = ''
15
16
  def keywords = []
16
17
  def directives = []
17
- def text = ''
18
18
  def to_s = ''
19
19
  end
20
20
 
@@ -42,7 +42,7 @@ class AIA::Prompt
42
42
 
43
43
  if build
44
44
  @prompt.text = render_erb(@prompt.text) if AIA.config.erb?
45
- @prompt.text = replace_env(@prompt.text) if AIA.config.env?
45
+ @prompt.text = replace_env(@prompt.text) if AIA.config.shell?
46
46
  process_prompt
47
47
  end
48
48
  end
@@ -231,7 +231,7 @@ class AIA::Prompt
231
231
  "--header-first",
232
232
  "--prompt='Search term: '",
233
233
  '--delimiter :',
234
- "--preview 'cat $PROMPTS_DIR/{1}.txt'",
234
+ "--preview 'cat #{AIA.config.prompts_dir}/{1}.txt'",
235
235
  "--preview-window=down:50%:wrap"
236
236
  ].join(' ')
237
237
 
@@ -26,6 +26,7 @@ class AIA::Mods < AIA::Tools
26
26
  http-proxy
27
27
  max-retries
28
28
  max-tokens
29
+ model
29
30
  no-cache
30
31
  no-limit
31
32
  quiet
data/lib/aia.rb CHANGED
@@ -1,7 +1,24 @@
1
1
  # lib/aia.rb
2
2
 
3
- require 'debug_me'
4
- include DebugMe
3
+ def tramp_require(what, &block)
4
+ loaded, require_result = false, nil
5
+
6
+ begin
7
+ require_result = require what
8
+ loaded = true
9
+ puts "Loaded"
10
+ rescue Exception => ex
11
+ # Do nothing
12
+ end
13
+
14
+ yield if loaded and block_given?
15
+
16
+ require_result
17
+ end
18
+
19
+ tramp_require('debug_me') {
20
+ include DebugMe
21
+ }
5
22
 
6
23
  require 'hashie'
7
24
  require 'pathname'
data/main.just CHANGED
@@ -16,11 +16,26 @@ module gem /Users/dewayne/sandbox/git_repos/gem.just
16
16
  module version /Users/dewayne/just_modules/version.just
17
17
 
18
18
 
19
+ # Install Locally
20
+ install: update_toc_in_readmen create_man_page test
21
+ rake install
22
+
23
+
24
+ # Create the TOC
25
+ update_toc_in_readmen:
26
+ rake toc
27
+
28
+
19
29
  # Preview man page
20
30
  preview_man_page:
21
31
  kramdown-man {{RR}}/man/aia.1.md
22
32
 
23
33
 
34
+ # Run Unit Tests
35
+ test:
36
+ rake test
37
+
38
+
24
39
  # View man page
25
40
  view_man_page: create_man_page
26
41
  man {{RR}}/man/aia.1
data/man/aia.1 CHANGED
@@ -23,7 +23,7 @@ External options are optional\. Anything that follow \[lq] \-\- \[lq] will be s
23
23
  .SH OPTIONS
24
24
  .TP
25
25
  \fB\-\-chat\fR
26
- begin a chat session with the backend after the initial prompt response; will set \-\-no\-output so that the backend response comes to STDOUT\.
26
+ begin a chat session with the backend after the initial prompt response; will set \-\-no\-out\[ru]file so that the backend response comes to STDOUT\.
27
27
  .TP
28
28
  \fB\-\-completion\fR \fISHELL\[ru]NAME\fP
29
29
  .TP
@@ -32,7 +32,7 @@ begin a chat session with the backend after the initial prompt response; will s
32
32
  \fB\-e\fR, \fB\-\-edit\fR
33
33
  Invokes an editor on the prompt file\. You can make changes to the prompt file, save it and the newly saved prompt will be processed by the backend\.
34
34
  .TP
35
- \fB\-\-env\fR
35
+ \fB\-\-shell\fR
36
36
  This option tells \fBaia\fR to replace references to system environment variables in the prompt with the value of the envar\. envars are like \[Do]HOME and \[Do]\[lC]HOME\[rC] in this example their occurance will be replaced by the value of ENV\[lB]\[oq]HOME\[cq]\[rB]\. Also the dynamic shell command in the pattern \[Do](shell command) will be executed and its output replaces its pattern\. It does not matter if your shell uses different patters than BASH since the replacement is being done within a Ruby context\.
37
37
  .TP
38
38
  \fB\-\-erb\fR
@@ -53,7 +53,7 @@ Print Version \- default is false
53
53
  \fB\-b\fR, \fB\-\-\[lB]no\[rB]\-backend\fR \fILLM TOOL\fP
54
54
  Specify the backend prompt resolver \- default is mods
55
55
  .TP
56
- \fB\-c\fR, \fB\-\-config\fR \fIPATH\[ru]TO\[ru]CONFIG\[ru]FILE\fP
56
+ \fB\-c\fR, \fB\-\-config\[ru]file\fR \fIPATH\[ru]TO\[ru]CONFIG\[ru]FILE\fP
57
57
  Load Config File \- default is nil
58
58
  .TP
59
59
  \fB\-d\fR, \fB\-\-debug\fR
@@ -74,7 +74,7 @@ Log FILEPATH \- default is \[Do]HOME\[sl]\.prompts\[sl]prompts\.log
74
74
  \fB\-m\fR, \fB\-\-\[lB]no\[rB]\-markdown\fR
75
75
  Format with Markdown \- default is true
76
76
  .TP
77
- \fB\-o\fR, \fB\-\-\[lB]no\[rB]\-output\fR \fIPATH\[ru]TO\[ru]OUTPUT\[ru]FILE\fP
77
+ \fB\-o\fR, \fB\-\-\[lB]no\[rB]\-out\[ru]file\fR \fIPATH\[ru]TO\[ru]OUTPUT\[ru]FILE\fP
78
78
  Out FILENAME \- default is \.\[sl]temp\.md
79
79
  .TP
80
80
  \fB\-p\fR, \fB\-\-prompts\fR \fIPATH\[ru]TO\[ru]DIRECTORY\fP
@@ -109,7 +109,7 @@ Currently there is not specific standard for name of the OpenAI key\. Some prog
109
109
  To acquire an OpenAI access key, first create an account on the OpenAI platform, where further documentation is available\.
110
110
  .SH USAGE NOTES
111
111
  .PP
112
- \fBaia\fR is designed for flexibility, allowing users to pass prompt ids and context files as arguments\. Some options change the behavior of the output, such as \fB\-\-output\fR for specifying a file or \fB\-\-no\-output\fR for disabling file output in favor of standard output (STDPIT)\.
112
+ \fBaia\fR is designed for flexibility, allowing users to pass prompt ids and context files as arguments\. Some options change the behavior of the output, such as \fB\-\-out\[ru]file\fR for specifying a file or \fB\-\-no\-out\[ru]file\fR for disabling file output in favor of standard output (STDPIT)\.
113
113
  .PP
114
114
  The \fB\-\-completion\fR option displays a script that enables prompt ID auto\-completion for bash, zsh, or fish shells\. It\[cq]s crucial to integrate the script into the shell\[cq]s runtime to take effect\.
115
115
  .PP
data/man/aia.1.md CHANGED
@@ -26,7 +26,7 @@ The aia command-line tool is an interface for interacting with an AI model backe
26
26
  ## OPTIONS
27
27
 
28
28
  `--chat`
29
- : begin a chat session with the backend after the initial prompt response; will set --no-output so that the backend response comes to STDOUT.
29
+ : begin a chat session with the backend after the initial prompt response; will set --no-out_file so that the backend response comes to STDOUT.
30
30
 
31
31
  `--completion` *SHELL_NAME*
32
32
  : Show completion script for bash|zsh|fish - default is nil
@@ -37,7 +37,7 @@ The aia command-line tool is an interface for interacting with an AI model backe
37
37
  `-e`, `--edit`
38
38
  : Invokes an editor on the prompt file. You can make changes to the prompt file, save it and the newly saved prompt will be processed by the backend.
39
39
 
40
- `--env`
40
+ `--shell`
41
41
  : This option tells `aia` to replace references to system environment variables in the prompt with the value of the envar. envars are like $HOME and ${HOME} in this example their occurance will be replaced by the value of ENV['HOME']. Also the dynamic shell command in the pattern $(shell command) will be executed and its output replaces its pattern. It does not matter if your shell uses different patters than BASH since the replacement is being done within a Ruby context.
42
42
 
43
43
  `--erb`
@@ -58,7 +58,7 @@ The aia command-line tool is an interface for interacting with an AI model backe
58
58
  `-b`, `--[no]-backend` *LLM TOOL*
59
59
  : Specify the backend prompt resolver - default is mods
60
60
 
61
- `-c`, `--config` *PATH_TO_CONFIG_FILE*
61
+ `-c`, `--config_file` *PATH_TO_CONFIG_FILE*
62
62
  : Load Config File - default is nil
63
63
 
64
64
  `-d`, `--debug`
@@ -79,7 +79,7 @@ The aia command-line tool is an interface for interacting with an AI model backe
79
79
  `-m`, `--[no]-markdown`
80
80
  : Format with Markdown - default is true
81
81
 
82
- `-o`, `--[no]-output` *PATH_TO_OUTPUT_FILE*
82
+ `-o`, `--[no]-out_file` *PATH_TO_OUTPUT_FILE*
83
83
  : Out FILENAME - default is ./temp.md
84
84
 
85
85
  `-p`, `--prompts` *PATH_TO_DIRECTORY*
@@ -115,7 +115,7 @@ To acquire an OpenAI access key, first create an account on the OpenAI platform,
115
115
 
116
116
  ## USAGE NOTES
117
117
 
118
- `aia` is designed for flexibility, allowing users to pass prompt ids and context files as arguments. Some options change the behavior of the output, such as `--output` for specifying a file or `--no-output` for disabling file output in favor of standard output (STDPIT).
118
+ `aia` is designed for flexibility, allowing users to pass prompt ids and context files as arguments. Some options change the behavior of the output, such as `--out_file` for specifying a file or `--no-out_file` for disabling file output in favor of standard output (STDPIT).
119
119
 
120
120
  The `--completion` option displays a script that enables prompt ID auto-completion for bash, zsh, or fish shells. It's crucial to integrate the script into the shell's runtime to take effect.
121
121
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-01 00:00:00.000000000 Z
11
+ date: 2024-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -177,6 +177,7 @@ executables:
177
177
  extensions: []
178
178
  extra_rdoc_files: []
179
179
  files:
180
+ - ".config/tocer/configuration.yml"
180
181
  - ".envrc"
181
182
  - ".semver"
182
183
  - CHANGELOG.md
@@ -185,6 +186,7 @@ files:
185
186
  - README.md
186
187
  - Rakefile
187
188
  - bin/aia
189
+ - doc/aia_and_pre_compositional_prompts.md
188
190
  - justfile
189
191
  - lib/aia.rb
190
192
  - lib/aia/aia_completion.bash
@@ -231,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
233
  - !ruby/object:Gem::Version
232
234
  version: '0'
233
235
  requirements: []
234
- rubygems_version: 3.5.3
236
+ rubygems_version: 3.5.4
235
237
  signing_key:
236
238
  specification_version: 4
237
239
  summary: AI Assistant (aia) a command-line (CLI) utility