aia 0.5.9 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.semver +1 -1
- data/CHANGELOG.md +8 -0
- data/README.md +251 -142
- data/lib/aia/cli.rb +57 -2
- data/lib/aia/prompt.rb +16 -35
- data/lib/aia/tools/fzf.rb +105 -0
- data/man/aia.1 +5 -2
- data/man/aia.1.md +5 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cd315c42710fcff586cb6159b981fd3a1ba8c85cc950985dd46b93eb9b00ef1
|
4
|
+
data.tar.gz: c97d4f8db6bfc74f047ad439a6ddbddcdde72cd5dce614b1341c356a71bbad92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cb087fe893bae9bf366c8cee81d4c35f329198a3508c475cbfd077661afff794299791d41b5af6faed0580e2a22eae9559ea69d6edad2a61705b81e54d52dd1
|
7
|
+
data.tar.gz: d76aba8685317e19ca534202a6dcce5ac61255702abc9e5f8ffd751c2f9ff778499048ac45a5ff7a5a5ffd5222e3249e5cd51a15398f20430f010d6900a27c99
|
data/.semver
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.5.10] 2024-02-03
|
4
|
+
- Added --roles_dir to isolate roles from other prompts if desired
|
5
|
+
- Changed --prompts to --prompts_dir to be consistent
|
6
|
+
- Refactored common fzf usage into its own tool class
|
7
|
+
|
8
|
+
## [0.5.9] 2024-02-01
|
9
|
+
- Added a "I'm working" spinner thing when "--verbose" is used as an indication that the backend is in the process of composing its response to the prompt.
|
10
|
+
|
3
11
|
## [0.5.8] 2024-01-17
|
4
12
|
- Changed the behavior of the --dump option. It must now be followed by path/to/file.ext where ext is a supported config file format: yml, yaml, toml
|
5
13
|
|
data/README.md
CHANGED
@@ -5,23 +5,17 @@
|
|
5
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
7
|
**Most Recent Change**: Refer to the [Changelog](CHANGELOG.md)
|
8
|
-
v0.5.7
|
9
|
-
- Added ERB processing to config files that have the pattern any_file.ext.erb where ext is the real extension of the file.
|
10
8
|
|
11
|
-
v0.5.
|
12
|
-
-
|
13
|
-
-
|
14
|
-
|
15
|
-
|
16
|
-
v0.5.
|
17
|
-
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
v0.5.0 - Breaking changes:
|
22
|
-
- `--config` is now `--config_file`
|
23
|
-
- `--env` is now `--shell`
|
24
|
-
- `--output` is now `--out_file`
|
9
|
+
> v0.5.10
|
10
|
+
> - Added --roles_dir
|
11
|
+
> - Changed --prompts to --prompts_dir
|
12
|
+
> - Fixed Issue 33
|
13
|
+
>
|
14
|
+
> v0.5.9
|
15
|
+
> - When "--verbose" is used, an animation is shown while the backend is composing its response to the prompt.
|
16
|
+
>
|
17
|
+
> v0.5.7
|
18
|
+
> - Added ERB processing to config files that have the pattern any_file.ext.erb where ext is the real extension of the file.
|
25
19
|
|
26
20
|
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
27
21
|
|
@@ -42,10 +36,13 @@ v0.5.0 - Breaking changes:
|
|
42
36
|
- [Backend Directive Commands](#backend-directive-commands)
|
43
37
|
- [Using Directives in Chat Sessions](#using-directives-in-chat-sessions)
|
44
38
|
- [All About ROLES](#all-about-roles)
|
39
|
+
- [The --roles_dir (AIA_ROLES_DIR)](#the---roles_dir-aia_roles_dir)
|
40
|
+
- [The --role Option](#the---role-option)
|
45
41
|
- [Other Ways to Insert Roles into Prompts](#other-ways-to-insert-roles-into-prompts)
|
46
42
|
- [External CLI Tools Used](#external-cli-tools-used)
|
47
43
|
- [Shell Completion](#shell-completion)
|
48
44
|
- [My Most Powerful Prompt](#my-most-powerful-prompt)
|
45
|
+
- [My Configuration](#my-configuration)
|
49
46
|
- [Development](#development)
|
50
47
|
- [Contributing](#contributing)
|
51
48
|
- [License](#license)
|
@@ -66,7 +63,7 @@ Install the command-line utilities by executing:
|
|
66
63
|
|
67
64
|
You will also need to establish a directory in your file system where your prompt text files, last used parameters and usage log files are kept.
|
68
65
|
|
69
|
-
Setup a system environment variable named "AIA_PROMPTS_DIR" that points to your prompts directory. The default is in your HOME directory named ".
|
66
|
+
Setup a system environment variable (envar) named "AIA_PROMPTS_DIR" that points to your prompts directory. The default is in your HOME directory named ".prompts". The envar "AIA_ROLES_DIR" points to your role directory where you have prompts that define the different roles you want the LLM to assume when it is doing its work. The default roles directory is inside the prompts directory. Its name is "roles".
|
70
67
|
|
71
68
|
You may also want to install the completion script for your shell. To get a copy of the completion script do:
|
72
69
|
|
@@ -82,97 +79,126 @@ The usage report obtained using either `-h` or `--help` is implemented as a stan
|
|
82
79
|
```text
|
83
80
|
$ aia --help
|
84
81
|
|
85
|
-
aia(1)
|
82
|
+
aia(1) User Manuals aia(1)
|
86
83
|
|
87
84
|
NAME
|
88
85
|
aia - command-line interface for an AI assistant
|
89
86
|
|
90
87
|
SYNOPSIS
|
91
|
-
aia [options]* PROMPT_ID [CONTEXT_FILE]* [--
|
88
|
+
aia [options]* PROMPT_ID [CONTEXT_FILE]* [--
|
89
|
+
EXTERNAL_OPTIONS+]
|
92
90
|
|
93
91
|
DESCRIPTION
|
94
|
-
The aia command-line tool is an interface for interacting
|
95
|
-
providing a simple way to send
|
96
|
-
|
97
|
-
|
92
|
+
The aia command-line tool is an interface for interacting
|
93
|
+
with an AI model backend, providing a simple way to send
|
94
|
+
prompts and receive responses. The CLI supports various
|
95
|
+
options to customize the interaction, load a
|
96
|
+
configuration file, edit prompts, set debugging levels,
|
97
|
+
and more.
|
98
98
|
|
99
99
|
ARGUMENTS
|
100
100
|
PROMPT_ID
|
101
101
|
This is a required argument.
|
102
102
|
|
103
103
|
CONTEXT_FILES
|
104
|
-
This is an optional argument. One or more files
|
105
|
-
|
104
|
+
This is an optional argument. One or more files
|
105
|
+
can be added to the prompt as context for the
|
106
|
+
backend gen-AI tool to process.
|
106
107
|
|
107
108
|
EXTERNAL_OPTIONS
|
108
|
-
External options are optional. Anything that
|
109
|
-
|
110
|
-
|
111
|
-
|
109
|
+
External options are optional. Anything that
|
110
|
+
follow “ -- “ will be sent to the backend gen-AI
|
111
|
+
tool. For example “-- -C -m gpt4-128k” will send
|
112
|
+
the options “-C -m gpt4-128k” to the backend
|
113
|
+
gen-AI tool. aia will not validate these external
|
114
|
+
options before sending them to the backend gen-AI
|
115
|
+
tool.
|
112
116
|
|
113
117
|
OPTIONS
|
114
|
-
--chat begin a chat session with the backend after the
|
115
|
-
set --no-out_file
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
RETURN
|
121
|
-
|
122
|
-
|
123
|
-
|
118
|
+
--chat begin a chat session with the backend after the
|
119
|
+
initial prompt response; will set --no-out_file
|
120
|
+
so that the backend response comes to STDOUT.
|
121
|
+
After the initial prompt is processed, you will be
|
122
|
+
asked to provide a follow up. Just enter whatever
|
123
|
+
is appropriate terminating your input with a
|
124
|
+
RETURN. The backend will provide a response to
|
125
|
+
you follow up and ask you again if you have
|
126
|
+
another follow up. This back and forth chatting
|
127
|
+
will continue until you enter a RETURN without any
|
128
|
+
other content - an empty follow up prompt. You
|
129
|
+
may also enter a directive to be processed after
|
130
|
+
which another follow up is requested. If you have
|
131
|
+
the --shell and/or the --erb options set you may
|
132
|
+
use those tools within your follow up to provide
|
133
|
+
dynamic content.
|
124
134
|
|
125
135
|
--completion SHELL_NAME
|
126
136
|
|
127
137
|
--dump PATH/TO/FILE.ext
|
128
|
-
Dump the current configuration to a file in the
|
129
|
-
|
130
|
-
|
138
|
+
Dump the current configuration to a file in the
|
139
|
+
format denoted by the file’s extension. Currently
|
140
|
+
only .yml, .yaml and .toml are acceptable file
|
141
|
+
extensions. If the file exists, it will be
|
142
|
+
over-written without warning.
|
131
143
|
|
132
144
|
-e, --edit
|
133
|
-
Invokes an editor on the prompt file. You can
|
134
|
-
|
145
|
+
Invokes an editor on the prompt file. You can
|
146
|
+
make changes to the prompt file, save it and the
|
147
|
+
newly saved prompt will be processed by the
|
148
|
+
backend.
|
135
149
|
|
136
150
|
--shell
|
137
|
-
This option tells aia to replace references to
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
151
|
+
This option tells aia to replace references to
|
152
|
+
system environment variables in the prompt with
|
153
|
+
the value of the envar. envars are like $HOME and
|
154
|
+
${HOME} in this example their occurance will be
|
155
|
+
replaced by the value of ENV[‘HOME’]. Also the
|
156
|
+
dynamic shell command in the pattern $(shell
|
157
|
+
command) will be executed and its output replaces
|
158
|
+
its pattern. It does not matter if your shell
|
159
|
+
uses different patters than BASH since the
|
160
|
+
replacement is being done within a Ruby context.
|
161
|
+
|
162
|
+
--erb If dynamic prompt content using $(...) wasn’t
|
163
|
+
enough here is ERB. Embedded RUby. <%= ruby code
|
164
|
+
%> within a prompt will have its ruby code
|
165
|
+
executed and the results of that execution will be
|
166
|
+
inserted into the prompt. I’m sure we will find a
|
167
|
+
way to truly misuse this capability. Remember,
|
168
|
+
some say that the simple prompt is the best
|
169
|
+
prompt.
|
150
170
|
|
151
171
|
--model NAME
|
152
|
-
Name of the LLM model to use - default is
|
172
|
+
Name of the LLM model to use - default is
|
173
|
+
gpt-4-1106-preview
|
153
174
|
|
154
175
|
--render
|
155
|
-
Render markdown to the terminal using the external
|
176
|
+
Render markdown to the terminal using the external
|
177
|
+
tool “glow” - default: false
|
156
178
|
|
157
179
|
--speak
|
158
|
-
Simple implementation. Uses the “say” command to
|
159
|
-
--chat
|
180
|
+
Simple implementation. Uses the “say” command to
|
181
|
+
speak the response. Fun with --chat
|
160
182
|
|
161
183
|
--terse
|
162
|
-
Add a clause to the prompt text that instructs the
|
163
|
-
response.
|
184
|
+
Add a clause to the prompt text that instructs the
|
185
|
+
backend to be terse in its response.
|
164
186
|
|
165
187
|
--version
|
166
188
|
Print Version - default is false
|
167
189
|
|
168
190
|
-b, --[no]-backend LLM TOOL
|
169
|
-
Specify the backend prompt resolver - default is
|
191
|
+
Specify the backend prompt resolver - default is
|
192
|
+
mods
|
170
193
|
|
171
194
|
-c, --config_file PATH_TO_CONFIG_FILE
|
172
|
-
Load Config File. both YAML and TOML formats are
|
173
|
-
supported.
|
174
|
-
|
175
|
-
|
195
|
+
Load Config File. both YAML and TOML formats are
|
196
|
+
supported. Also ERB is supported. For example
|
197
|
+
~/aia_config.yml.erb will be processed through ERB
|
198
|
+
and then through YAML. The result will be written
|
199
|
+
out to ~/aia_config.yml so that you can manually
|
200
|
+
verify that you got what you wanted from the ERB
|
201
|
+
processing.
|
176
202
|
|
177
203
|
-d, --debug
|
178
204
|
Turn On Debugging - default is false
|
@@ -181,13 +207,15 @@ OPTIONS
|
|
181
207
|
Edit the Prompt File - default is false
|
182
208
|
|
183
209
|
-f, --fuzzy`
|
184
|
-
Use Fuzzy Matching when searching for a prompt -
|
210
|
+
Use Fuzzy Matching when searching for a prompt -
|
211
|
+
default is false
|
185
212
|
|
186
213
|
-h, --help
|
187
214
|
Show Usage - default is false
|
188
215
|
|
189
216
|
-l, --[no]-log_file PATH_TO_LOG_FILE
|
190
|
-
Log FILEPATH - default is
|
217
|
+
Log FILEPATH - default is
|
218
|
+
$HOME/.prompts/prompts.log
|
191
219
|
|
192
220
|
-m, --[no]-markdown
|
193
221
|
Format with Markdown - default is true
|
@@ -195,107 +223,143 @@ OPTIONS
|
|
195
223
|
-o, --[no]-out_file PATH_TO_OUTPUT_FILE
|
196
224
|
Out FILENAME - default is ./temp.md
|
197
225
|
|
198
|
-
-p, --
|
199
|
-
Directory containing the prompt files - default is
|
226
|
+
-p, --prompts_dir PATH_TO_DIRECTORY
|
227
|
+
Directory containing the prompt files - default is
|
228
|
+
~/.prompts
|
229
|
+
|
230
|
+
--roles_dir PATH_TO_DIRECTORY
|
231
|
+
Directory containing the personification prompt
|
232
|
+
files - default is ~/.prompts/roles
|
200
233
|
|
201
234
|
-r, --role ROLE_ID
|
202
|
-
A role ID is the same as a prompt ID. A “role” is
|
203
|
-
gets pre-pended to
|
204
|
-
|
235
|
+
A role ID is the same as a prompt ID. A “role” is
|
236
|
+
a specialized prompt that gets pre-pended to
|
237
|
+
another prompt. It’s purpose is to configure the
|
238
|
+
LLM into a certain orientation within which to
|
239
|
+
resolve its primary prompt.
|
205
240
|
|
206
241
|
-v, --verbose
|
207
242
|
Be Verbose - default is false
|
208
243
|
|
209
244
|
CONFIGURATION HIERARCHY
|
210
|
-
System Environment Variables (envars) that are all
|
211
|
-
be used to over-ride
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
245
|
+
System Environment Variables (envars) that are all
|
246
|
+
uppercase and begin with “AIA_” can be used to over-ride
|
247
|
+
the default configuration settings. For example setting
|
248
|
+
“export AIA_PROMPTS_DIR=~/Documents/prompts” will
|
249
|
+
over-ride the default configuration; however, a config
|
250
|
+
value provided by a command line options will over-ride
|
251
|
+
an envar setting.
|
252
|
+
|
253
|
+
Configuration values found in a config file will
|
254
|
+
over-ride all other values set for a config item.
|
255
|
+
|
256
|
+
”//config” directives found inside a prompt file
|
257
|
+
over-rides that config item regardless of where the value
|
258
|
+
was set.
|
259
|
+
|
260
|
+
For example “//config chat? = true” within a prompt will
|
261
|
+
setup the chat back and forth chat session for that
|
262
|
+
specific prompt regardless of the command line options or
|
263
|
+
the envar AIA_CHAT settings
|
225
264
|
|
226
265
|
OpenAI ACCOUNT IS REQUIRED
|
227
|
-
Additionally, the program requires an OpenAI access key,
|
228
|
-
one of the following
|
266
|
+
Additionally, the program requires an OpenAI access key,
|
267
|
+
which can be specified using one of the following
|
268
|
+
environment variables:
|
229
269
|
|
230
270
|
• OPENAI_ACCESS_TOKEN
|
231
271
|
|
232
272
|
• OPENAI_API_KEY
|
233
273
|
|
234
|
-
Currently there is not specific standard for name of the
|
235
|
-
use one name, while others use
|
236
|
-
|
237
|
-
|
274
|
+
Currently there is not specific standard for name of the
|
275
|
+
OpenAI key. Some programs use one name, while others use
|
276
|
+
a different name. Both of the envars listed above mean
|
277
|
+
the same thing. If you use more than one tool to access
|
278
|
+
OpenAI resources, you may have to set several envars to
|
279
|
+
the same key value.
|
238
280
|
|
239
|
-
To acquire an OpenAI access key, first create an account
|
240
|
-
further documentation is
|
281
|
+
To acquire an OpenAI access key, first create an account
|
282
|
+
on the OpenAI platform, where further documentation is
|
283
|
+
available.
|
241
284
|
|
242
285
|
USAGE NOTES
|
243
|
-
aia is designed for flexibility, allowing users to pass
|
244
|
-
as arguments. Some options
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
286
|
+
aia is designed for flexibility, allowing users to pass
|
287
|
+
prompt ids and context files as arguments. Some options
|
288
|
+
change the behavior of the output, such as --out_file for
|
289
|
+
specifying a file or --no-out_file for disabling file
|
290
|
+
output in favor of standard output (STDPIT).
|
291
|
+
|
292
|
+
The --completion option displays a script that enables
|
293
|
+
prompt ID auto-completion for bash, zsh, or fish shells.
|
294
|
+
It’s crucial to integrate the script into the shell’s
|
250
295
|
runtime to take effect.
|
251
296
|
|
252
|
-
The --dump path/to/file.ext option will write the current
|
253
|
-
the format requested by the
|
254
|
-
|
297
|
+
The --dump path/to/file.ext option will write the current
|
298
|
+
configuration to a file in the format requested by the
|
299
|
+
file’s extension. The following extensions are
|
300
|
+
supported: .yml, .yaml and .toml
|
255
301
|
|
256
302
|
PROMPT DIRECTIVES
|
257
|
-
Within a prompt text file any line that begins with “//”
|
258
|
-
|
259
|
-
|
303
|
+
Within a prompt text file any line that begins with “//”
|
304
|
+
is considered a prompt directive. There are numerious
|
305
|
+
prompt directives available. In the discussion above on
|
306
|
+
the configuration you learned about the “//config”
|
307
|
+
directive.
|
260
308
|
|
261
|
-
Detail discussion on individual prompt directives is TBD.
|
262
|
-
handled in the github wiki
|
309
|
+
Detail discussion on individual prompt directives is TBD.
|
310
|
+
Most likely it will be handled in the github wiki
|
311
|
+
<https://github.com/MadBomber/aia>
|
263
312
|
|
264
313
|
SEE ALSO
|
265
314
|
|
266
|
-
• OpenAI Platform Documentation
|
315
|
+
• OpenAI Platform Documentation
|
316
|
+
<https://platform.openai.com/docs/overview>
|
267
317
|
for more information on obtaining access tokens
|
268
318
|
<https://platform.openai.com/account/api-keys>
|
269
319
|
and working with OpenAI models.
|
270
320
|
|
271
321
|
• mods <https://github.com/charmbracelet/mods>
|
272
|
-
for more information on mods - AI for the
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
322
|
+
for more information on mods - AI for the
|
323
|
+
command line, built for pipelines. LLM based AI
|
324
|
+
is really good at interpreting the output of
|
325
|
+
commands and returning the results in CLI
|
326
|
+
friendly text formats like Markdown. Mods is a
|
327
|
+
simple tool that makes it super easy to use AI
|
328
|
+
on the command line and in your pipelines. Mods
|
329
|
+
works with OpenAI
|
277
330
|
<https://platform.openai.com/account/api-keys>
|
278
|
-
and LocalAI
|
331
|
+
and LocalAI
|
332
|
+
<https://github.com/go-skynet/LocalAI>
|
279
333
|
|
280
334
|
• sgpt <https://github.com/tbckr/sgpt>
|
281
|
-
(aka shell-gpt) is a powerful command-line
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
335
|
+
(aka shell-gpt) is a powerful command-line
|
336
|
+
interface (CLI) tool designed for seamless
|
337
|
+
interaction with OpenAI models directly from
|
338
|
+
your terminal. Effortlessly run queries,
|
339
|
+
generate shell commands or code, create images
|
340
|
+
from text, and more, using simple commands.
|
341
|
+
Streamline your workflow and enhance
|
342
|
+
productivity with this powerful and
|
343
|
+
user-friendly CLI tool.
|
286
344
|
|
287
345
|
• fzf <https://github.com/junegunn/fzf>
|
288
|
-
fzf is a general-purpose command-line fuzzy
|
289
|
-
Unix filter for
|
290
|
-
|
346
|
+
fzf is a general-purpose command-line fuzzy
|
347
|
+
finder. It’s an interactive Unix filter for
|
348
|
+
command-line that can be used with any list;
|
349
|
+
files, command history, processes, hostnames,
|
350
|
+
bookmarks, git commits, etc.
|
291
351
|
|
292
352
|
• ripgrep <https://github.com/BurntSushi/ripgrep>
|
293
|
-
Search tool like grep and The Silver Searcher.
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
353
|
+
Search tool like grep and The Silver Searcher.
|
354
|
+
It is a line-oriented search tool that
|
355
|
+
recursively searches a directory tree for a
|
356
|
+
regex pattern. By default, ripgrep will respect
|
357
|
+
gitignore rules and automatically skip hidden
|
358
|
+
files/directories and binary files. (To disable
|
359
|
+
all automatic filtering by default, use rg
|
360
|
+
-uuu.) ripgrep has first class support on
|
361
|
+
Windows, macOS and Linux, with binary downloads
|
362
|
+
available for every release.
|
299
363
|
|
300
364
|
• glow <https://github.com/charmbracelet/glow>
|
301
365
|
Render markdown on the CLI
|
@@ -303,10 +367,9 @@ SEE ALSO
|
|
303
367
|
AUTHOR
|
304
368
|
Dewayne VanHoozer <dvanhoozer@gmail.com>
|
305
369
|
|
306
|
-
AIA
|
370
|
+
AIA v0.5.10 aia(1)
|
307
371
|
```
|
308
372
|
|
309
|
-
|
310
373
|
## Configuration Using Envars
|
311
374
|
|
312
375
|
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.
|
@@ -444,7 +507,19 @@ The directive is executed and a new follow up prompt can be entered with a more
|
|
444
507
|
|
445
508
|
## All About ROLES
|
446
509
|
|
447
|
-
|
510
|
+
### The --roles_dir (AIA_ROLES_DIR)
|
511
|
+
|
512
|
+
There are two kinds of prompts
|
513
|
+
1. instructional - tells the LLM what to do
|
514
|
+
2. personification - tells the LLM who it should pretend to be when it does its transformational work.
|
515
|
+
|
516
|
+
That second kind of prompt is called a role. Sometimes the role is incorporated into the instruction. For example "As a magician make a rabbit appear out of a hat." To reuse the same role in multiple prompts `aia` encourages you to designate a special `roles_dir` into which you put prompts that are specific to personification - roles.
|
517
|
+
|
518
|
+
The default `roles_dir` is a sub-directory of the `prompts_dir` named roles. You can, however, put your `roles_dir` anywhere that makes sense to you.
|
519
|
+
|
520
|
+
### The --role Option
|
521
|
+
|
522
|
+
The `--role` option is used to identify a personification prompt within your roles 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.
|
448
523
|
|
449
524
|
For example consider:
|
450
525
|
|
@@ -452,17 +527,17 @@ For example consider:
|
|
452
527
|
aia -r ruby refactor my_class.rb
|
453
528
|
```
|
454
529
|
|
455
|
-
Within the
|
530
|
+
Within the roles directory the contents of the text file `ruby.txt` will be pre-pre-pended to the contents of the `refactor.txt` file from the prompts directory to produce a complete prompt. That complete prompt will have any parameters followed by directives processed before sending the combined prompt text to the backend.
|
456
531
|
|
457
532
|
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.
|
458
533
|
|
459
|
-
|
534
|
+
`aia` fully supports a directory tree within the `prompts_dir` as a way of organization or classification of your different prompt text files.
|
460
535
|
|
461
536
|
```shell
|
462
|
-
aia -r
|
537
|
+
aia -r sw_eng doc_the_methods my_class.rb
|
463
538
|
```
|
464
539
|
|
465
|
-
In this example the prompt text file `$
|
540
|
+
In this example the prompt text file `$AIA_ROLES_DIR/sw_eng.txt` is prepended to the prompt text file `$AIA_PROMPTS_DIR/doc_the_methods.txt`
|
466
541
|
|
467
542
|
|
468
543
|
### Other Ways to Insert Roles into Prompts
|
@@ -473,7 +548,7 @@ Since `aia` supports parameterized prompts you could make a keyword like "[ROLE]
|
|
473
548
|
As a [ROLE] tell me what you think about [SUBJECT]
|
474
549
|
```
|
475
550
|
|
476
|
-
When this prompt is processed, `aia` will ask you for a value for the keyword "ROLE" and the keyword "SUBJECT" to complete the prompt. Since `aia` maintains a history your previous answers, you could just choose something that you used in the past or answer with a completely new value.
|
551
|
+
When this prompt is processed, `aia` will ask you for a value for the keyword "ROLE" and the keyword "SUBJECT" to complete the prompt. Since `aia` maintains a history of your previous answers, you could just choose something that you used in the past or answer with a completely new value.
|
477
552
|
|
478
553
|
## External CLI Tools Used
|
479
554
|
|
@@ -538,6 +613,40 @@ aia ad_hoc financial_statement.txt
|
|
538
613
|
|
539
614
|
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!
|
540
615
|
|
616
|
+
## My Configuration
|
617
|
+
|
618
|
+
I use the `bash` shell. In my `.bashrc` file I source another file named `.bashrc__aia` which looks like this:
|
619
|
+
|
620
|
+
```shell
|
621
|
+
# ~/.bashic_aia
|
622
|
+
# AI Assistant
|
623
|
+
|
624
|
+
# These are the defaults:
|
625
|
+
export AIA_PROMPTS_DIR=~/.prompts
|
626
|
+
export AIA_OUT_FILE=./temp.md
|
627
|
+
export AIA_LOG_FILE=$AIA_PROMPTS_DIR/_prompts.log
|
628
|
+
export AIA_BACKEND=mods
|
629
|
+
export AIA_MODEL=gpt-4-1106-preview
|
630
|
+
|
631
|
+
# Not a default. Invokes spinner.
|
632
|
+
export AIA_VERBOSE=true
|
633
|
+
|
634
|
+
alias chat='aia chat --terse'
|
635
|
+
|
636
|
+
# rest of the file is the completion function
|
637
|
+
```
|
638
|
+
|
639
|
+
Here is what my `chat` prompt file looks like:
|
640
|
+
|
641
|
+
```shell
|
642
|
+
# ~/.prompts/chat.txt
|
643
|
+
# Desc: Start a chat session
|
644
|
+
|
645
|
+
//config chat? = true
|
646
|
+
|
647
|
+
[WHAT]
|
648
|
+
```
|
649
|
+
|
541
650
|
## Development
|
542
651
|
|
543
652
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/aia/cli.rb
CHANGED
@@ -154,7 +154,8 @@ class AIA::Cli
|
|
154
154
|
role: ['', "-r --role"],
|
155
155
|
#
|
156
156
|
config_file:[nil, "-c --config_file"],
|
157
|
-
prompts_dir:["~/.prompts", "-p --
|
157
|
+
prompts_dir:["~/.prompts", "-p --prompts_dir"],
|
158
|
+
roles_dir: ["~/.prompts/roles", "--roles_dir"],
|
158
159
|
out_file: [STDOUT, "-o --out_file --no-out_file"],
|
159
160
|
log_file: ["~/.prompts/_prompts.log", "-l --log_file --no-log_file"],
|
160
161
|
#
|
@@ -230,10 +231,14 @@ class AIA::Cli
|
|
230
231
|
|
231
232
|
EOS
|
232
233
|
|
233
|
-
|
234
|
+
show_error_usage
|
234
235
|
|
235
236
|
exit
|
236
237
|
end
|
238
|
+
|
239
|
+
# After all other arguments
|
240
|
+
# are processed, check for role parameter.
|
241
|
+
check_for_role_parameter
|
237
242
|
end
|
238
243
|
|
239
244
|
|
@@ -272,6 +277,56 @@ class AIA::Cli
|
|
272
277
|
end
|
273
278
|
end
|
274
279
|
|
280
|
+
|
281
|
+
def check_for_role_parameter
|
282
|
+
role = AIA.config.role
|
283
|
+
return if role.empty?
|
284
|
+
|
285
|
+
role_path = string_to_pathname(AIA.config.roles_dir) + "#{role}.txt"
|
286
|
+
|
287
|
+
unless role_path.exist?
|
288
|
+
puts "Role prompt '#{role}' not found. Invoking fzf to choose a role..."
|
289
|
+
invoke_fzf_to_choose_role
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
|
294
|
+
def invoke_fzf_to_choose_role
|
295
|
+
roles_path = string_to_pathname AIA.config.roles_dir
|
296
|
+
|
297
|
+
available_roles = roles_path
|
298
|
+
.children
|
299
|
+
.select { |f| '.txt' == f.extname}
|
300
|
+
.map{|role| role.basename.to_s.gsub('.txt','')}
|
301
|
+
|
302
|
+
fzf = AIA::Fzf.new(
|
303
|
+
list: available_roles,
|
304
|
+
directory: roles_path,
|
305
|
+
prompt: 'Select Role:',
|
306
|
+
extension: '.txt'
|
307
|
+
)
|
308
|
+
|
309
|
+
chosen_role = fzf.run
|
310
|
+
|
311
|
+
if chosen_role.nil?
|
312
|
+
abort("No role selected. Exiting...")
|
313
|
+
else
|
314
|
+
AIA.config.role = chosen_role
|
315
|
+
puts "Role changed to '#{chosen_role}'."
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
|
320
|
+
def show_error_usage
|
321
|
+
puts <<~ERROR_USAGE
|
322
|
+
|
323
|
+
Usage: aia [options] PROMPT_ID [CONTEXT_FILE(s)] [-- EXTERNAL_OPTIONS]"
|
324
|
+
Try 'aia --help' for more information."
|
325
|
+
|
326
|
+
ERROR_USAGE
|
327
|
+
end
|
328
|
+
|
329
|
+
|
275
330
|
# aia usage is maintained in a man page
|
276
331
|
def show_usage
|
277
332
|
@options[:help?][0] = false
|
data/lib/aia/prompt.rb
CHANGED
@@ -32,9 +32,7 @@ class AIA::Prompt
|
|
32
32
|
if AIA.config.role.empty?
|
33
33
|
@role = nil
|
34
34
|
else
|
35
|
-
AIA.config.
|
36
|
-
get_prompt
|
37
|
-
@role = @prompt.dup
|
35
|
+
@role = (AIA.config.roles_dir + "#{AIA.config.role}.txt").read
|
38
36
|
end
|
39
37
|
|
40
38
|
get_prompt
|
@@ -42,7 +40,7 @@ class AIA::Prompt
|
|
42
40
|
@prompt_text_before_role = @prompt.text.dup
|
43
41
|
|
44
42
|
unless @role.nil?
|
45
|
-
@prompt.text.prepend @role
|
43
|
+
@prompt.text.prepend @role
|
46
44
|
end
|
47
45
|
|
48
46
|
if build
|
@@ -200,37 +198,18 @@ class AIA::Prompt
|
|
200
198
|
|
201
199
|
def handle_multiple_prompts(found_these, while_looking_for_this)
|
202
200
|
raise ArgumentError, "Argument is not an Array" unless found_these.is_a?(Array)
|
203
|
-
|
204
|
-
#
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
# Create a temporary file to hold the list of strings
|
218
|
-
temp_file = Tempfile.new('fzf-input')
|
219
|
-
|
220
|
-
begin
|
221
|
-
# Write all strings to the temp file
|
222
|
-
temp_file.puts(found_these)
|
223
|
-
temp_file.close
|
224
|
-
|
225
|
-
# Execute fzf command-line utility to allow selection
|
226
|
-
selected = `cat #{temp_file.path} | fzf #{fzf_options}`.strip
|
227
|
-
|
228
|
-
# Check if fzf actually returned a string; if not, return nil
|
229
|
-
result = selected.empty? ? nil : selected
|
230
|
-
ensure
|
231
|
-
# Ensure that the tempfile is closed and unlinked
|
232
|
-
temp_file.unlink
|
233
|
-
end
|
201
|
+
|
202
|
+
# Create an instance of AIA::Fzf with appropriate parameters
|
203
|
+
fzf_instance = AIA::Fzf.new(
|
204
|
+
list: found_these,
|
205
|
+
directory: AIA.config.prompts_dir, # Assuming this is the correct directory
|
206
|
+
query: while_looking_for_this,
|
207
|
+
subject: 'Prompt IDs',
|
208
|
+
prompt: 'Select one: '
|
209
|
+
)
|
210
|
+
|
211
|
+
# Run the fzf instance and get the selected result
|
212
|
+
result = fzf_instance.run
|
234
213
|
|
235
214
|
exit unless result
|
236
215
|
|
@@ -238,6 +217,8 @@ class AIA::Prompt
|
|
238
217
|
end
|
239
218
|
|
240
219
|
|
220
|
+
|
221
|
+
|
241
222
|
def create_prompt(prompt_id)
|
242
223
|
@prompt = PromptManager::Prompt.create(id: prompt_id)
|
243
224
|
# TODO: consider a configurable prompt template
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# lib/aia/tools/fzf.rb
|
2
|
+
# fzf is a general-purpose command-line fuzzy finder
|
3
|
+
|
4
|
+
require 'shellwords'
|
5
|
+
require 'tempfile'
|
6
|
+
|
7
|
+
class AIA::Fzf < AIA::Tools
|
8
|
+
|
9
|
+
meta(
|
10
|
+
name: 'fzf',
|
11
|
+
role: :search_tool,
|
12
|
+
desc: "A command-line fuzzy finder",
|
13
|
+
url: "https://github.com/junegunn/fzf",
|
14
|
+
install: "brew install fzf",
|
15
|
+
)
|
16
|
+
|
17
|
+
DEFAULT_PARAMETERS = %w[
|
18
|
+
--tabstop=2
|
19
|
+
--header-first
|
20
|
+
--prompt='Search term: '
|
21
|
+
--delimiter :
|
22
|
+
--preview-window=down:50%:wrap
|
23
|
+
]
|
24
|
+
|
25
|
+
attr_reader :list, :directory, :query, :subject, :prompt, :extension, :command
|
26
|
+
|
27
|
+
def initialize(
|
28
|
+
list:, # Array of Strings (basenames of files w/o extension)
|
29
|
+
directory:, # Parent directory of the list items
|
30
|
+
query: '', # String, the thing be searched for
|
31
|
+
subject: 'Prompt IDs', # or 'Role Names'
|
32
|
+
prompt: 'Select one:',
|
33
|
+
extension: '.txt'
|
34
|
+
)
|
35
|
+
|
36
|
+
@list = list
|
37
|
+
@directory = directory
|
38
|
+
@query = query
|
39
|
+
@subject = subject
|
40
|
+
@prompt = prompt
|
41
|
+
@extension = extension
|
42
|
+
|
43
|
+
build_command
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def build_command
|
48
|
+
fzf_options = DEFAULT_PARAMETERS.dup
|
49
|
+
fzf_options << "--header='#{subject} which contain: #{query}\\nPress ESC to cancel.'"
|
50
|
+
fzf_options << "--preview='cat #{directory}/{1}#{extension}'"
|
51
|
+
fzf_options << "--prompt=#{Shellwords.escape(prompt)}"
|
52
|
+
|
53
|
+
fzf_command = "#{meta.name} #{fzf_options.join(' ')}"
|
54
|
+
|
55
|
+
@command = "cat #{tempfile_path} | #{fzf_command}"
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def run
|
60
|
+
puts "Executing: #{@command}"
|
61
|
+
selected = `#{@command}`
|
62
|
+
selected.strip.empty? ? nil : selected.strip
|
63
|
+
ensure
|
64
|
+
unlink_tempfile
|
65
|
+
end
|
66
|
+
|
67
|
+
##############################################
|
68
|
+
private
|
69
|
+
|
70
|
+
def tempfile_path
|
71
|
+
@tempfile ||= Tempfile.new('fzf-input').tap do |file|
|
72
|
+
list.each { |item| file.puts item }
|
73
|
+
file.close
|
74
|
+
end
|
75
|
+
@tempfile.path
|
76
|
+
end
|
77
|
+
|
78
|
+
def unlink_tempfile
|
79
|
+
@tempfile&.unlink
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
__END__
|
85
|
+
|
86
|
+
$ fzf --help
|
87
|
+
|
88
|
+
USAGE
|
89
|
+
fzf [OPTIONS]
|
90
|
+
|
91
|
+
OPTIONS
|
92
|
+
-x, --extended Extended-search mode
|
93
|
+
-e, --exact Enable Exact-match
|
94
|
+
--algo=TYPE Fuzzy matching algorithm: [v1|v2] (default: v2)
|
95
|
+
+i Case-insensitive match (default: smart-case match)
|
96
|
+
+s Synchronous search for multi-staged filtering
|
97
|
+
--multi Enable multi-select with tab/shift-tab
|
98
|
+
|
99
|
+
... (Other options)
|
100
|
+
|
101
|
+
EXAMPLES
|
102
|
+
find * -type f | fzf > selected
|
103
|
+
fzf < /path/to/file_list
|
104
|
+
|
105
|
+
For full documentation, please visit https://github.com/junegunn/fzf.
|
data/man/aia.1
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
.\" Generated by kramdown-man 1.0.1
|
2
2
|
.\" https://github.com/postmodern/kramdown-man#readme
|
3
|
-
.TH aia 1 "
|
3
|
+
.TH aia 1 "v0.5.10" AIA "User Manuals"
|
4
4
|
.SH NAME
|
5
5
|
.PP
|
6
6
|
aia \- command\-line interface for an AI assistant
|
@@ -81,9 +81,12 @@ Format with Markdown \- default is true
|
|
81
81
|
\fB\-o\fR, \fB\-\-\[lB]no\[rB]\-out\[ru]file\fR \fIPATH\[ru]TO\[ru]OUTPUT\[ru]FILE\fP
|
82
82
|
Out FILENAME \- default is \.\[sl]temp\.md
|
83
83
|
.TP
|
84
|
-
\fB\-p\fR, \fB\-\-prompts\fR \fIPATH\[ru]TO\[ru]DIRECTORY\fP
|
84
|
+
\fB\-p\fR, \fB\-\-prompts\[ru]dir\fR \fIPATH\[ru]TO\[ru]DIRECTORY\fP
|
85
85
|
Directory containing the prompt files \- default is \[ti]\[sl]\.prompts
|
86
86
|
.TP
|
87
|
+
\fB\-\-roles\[ru]dir\fR \fIPATH\[ru]TO\[ru]DIRECTORY\fP
|
88
|
+
Directory containing the personification prompt files \- default is \[ti]\[sl]\.prompts\[sl]roles
|
89
|
+
.TP
|
87
90
|
\fB\-r\fR, \fB\-\-role\fR \fIROLE\[ru]ID\fP
|
88
91
|
A role ID is the same as a prompt ID\. A \[lq]role\[rq] is a specialized prompt that gets pre\-pended to another prompt\. It\[cq]s purpose is to configure the LLM into a certain orientation within which to resolve its primary prompt\.
|
89
92
|
.TP
|
data/man/aia.1.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# aia 1 "
|
1
|
+
# aia 1 "v0.5.10" AIA "User Manuals"
|
2
2
|
|
3
3
|
## NAME
|
4
4
|
|
@@ -85,9 +85,12 @@ The aia command-line tool is an interface for interacting with an AI model backe
|
|
85
85
|
`-o`, `--[no]-out_file` *PATH_TO_OUTPUT_FILE*
|
86
86
|
: Out FILENAME - default is ./temp.md
|
87
87
|
|
88
|
-
`-p`, `--
|
88
|
+
`-p`, `--prompts_dir` *PATH_TO_DIRECTORY*
|
89
89
|
: Directory containing the prompt files - default is ~/.prompts
|
90
90
|
|
91
|
+
`--roles_dir` *PATH_TO_DIRECTORY*
|
92
|
+
: Directory containing the personification prompt files - default is ~/.prompts/roles
|
93
|
+
|
91
94
|
`-r`, `--role` *ROLE_ID*
|
92
95
|
: A role ID is the same as a prompt ID. A "role" is a specialized prompt that gets pre-pended to another prompt. It's purpose is to configure the LLM into a certain orientation within which to resolve its primary prompt.
|
93
96
|
|
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.5.
|
4
|
+
version: 0.5.10
|
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-02-
|
11
|
+
date: 2024-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -251,6 +251,7 @@ files:
|
|
251
251
|
- lib/aia/tools.rb
|
252
252
|
- lib/aia/tools/backend_common.rb
|
253
253
|
- lib/aia/tools/editor.rb
|
254
|
+
- lib/aia/tools/fzf.rb
|
254
255
|
- lib/aia/tools/glow.rb
|
255
256
|
- lib/aia/tools/mods.rb
|
256
257
|
- lib/aia/tools/sgpt.rb
|