aia 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/lib/aia/directive_processor.rb +36 -17
- data/lib/aia/session.rb +14 -18
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15a24480e7b5958570ae21ef3e3f958cdb991a1f03cb88ebe3e8ca52a6029f9a
|
4
|
+
data.tar.gz: dcef2697a2d2fdec85e371421a5c16a48c70d3688ea7bb6646f001df5e795d68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97f8c423247051e31eef8b6a66fdde22fe72438097da41bb30ec53ef56508266e07f5502fa85cf8cfb63ebad22e995d7c7b4cbe55745f20e87b2b535cbd0b55c
|
7
|
+
data.tar.gz: c48ebed9374edc9a8dcf86b2dd592031c1bef02b60f5d61e113a9c90bf31865030231ebc267a6308ca46d71f3e864d02e44bfc93f221112102309ddf2186d563
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.3
|
@@ -63,7 +63,7 @@ module AIA
|
|
63
63
|
if EXCLUDED_METHODS.include?(method_name)
|
64
64
|
return "Error: #{method_name} is not a valid directive: #{key}"
|
65
65
|
elsif respond_to?(method_name, true)
|
66
|
-
return send(method_name, args)
|
66
|
+
return send(method_name, args, context_manager)
|
67
67
|
else
|
68
68
|
return "Error: Unknown directive '#{key}'"
|
69
69
|
end
|
@@ -125,8 +125,9 @@ module AIA
|
|
125
125
|
end
|
126
126
|
|
127
127
|
desc "Inserts the contents of a file Example: //include path/to/file"
|
128
|
-
def include(args)
|
129
|
-
|
128
|
+
def include(args, context_manager=nil)
|
129
|
+
# echo takes care of envars and tilde expansion
|
130
|
+
file_path = `echo #{args.shift}`.strip
|
130
131
|
|
131
132
|
if @included_files.include?(file_path)
|
132
133
|
""
|
@@ -143,7 +144,7 @@ module AIA
|
|
143
144
|
alias_method :import, :include
|
144
145
|
|
145
146
|
desc "Without arguments it will print a list of all config items and their values _or_ //config item (for one item's value) _or_ //config item = value (to set a value of an item)"
|
146
|
-
def config(args = [])
|
147
|
+
def config(args = [], context_manager=nil)
|
147
148
|
args = Array(args)
|
148
149
|
|
149
150
|
if args.empty?
|
@@ -171,33 +172,42 @@ module AIA
|
|
171
172
|
alias_method :cfg, :config
|
172
173
|
|
173
174
|
desc "Shortcut for //config top_p _and_ //config top_p = value"
|
174
|
-
def top_p(
|
175
|
-
send(:config, args.prepend('top_p'))
|
175
|
+
def top_p(args, context_manager=nil)
|
176
|
+
send(:config, args.prepend('top_p'), context_manager)
|
176
177
|
end
|
177
178
|
alias_method :topp, :top_p
|
178
179
|
|
180
|
+
desc "Review the current context"
|
181
|
+
def review(args, context_manager=nil)
|
182
|
+
ap context_manager.get_context
|
183
|
+
''
|
184
|
+
end
|
185
|
+
alias_method :context, :review
|
186
|
+
|
179
187
|
desc "Shortcut for //config model _and_ //config model = value"
|
180
|
-
def model(
|
181
|
-
send(:config, args.prepend('model'))
|
188
|
+
def model(args, context_manager=nil)
|
189
|
+
send(:config, args.prepend('model'), context_manager)
|
182
190
|
end
|
183
191
|
|
184
192
|
desc "Shortcut for //config temperature _and_ //config temperature = value"
|
185
|
-
def temperature(
|
186
|
-
send(:config, args.prepend('temperature'))
|
193
|
+
def temperature(args, context_manager=nil)
|
194
|
+
send(:config, args.prepend('temperature'), context_manager)
|
187
195
|
end
|
188
196
|
alias_method :temp, :temperature
|
189
197
|
|
190
198
|
desc "Clears the conversation history (aka context) same as //config clear = true"
|
191
|
-
def clear(args, context_manager)
|
199
|
+
def clear(args, context_manager=nil)
|
192
200
|
if context_manager.nil?
|
193
201
|
return "Error: Context manager not available for //clear directive."
|
194
202
|
end
|
203
|
+
|
195
204
|
context_manager.clear_context
|
196
|
-
|
205
|
+
|
206
|
+
''
|
197
207
|
end
|
198
208
|
|
199
209
|
desc "Shortcut for a one line of ruby code; result is added to the context"
|
200
|
-
def ruby(
|
210
|
+
def ruby(args, context_manager=nil)
|
201
211
|
ruby_code = args.join(' ')
|
202
212
|
|
203
213
|
begin
|
@@ -211,25 +221,34 @@ module AIA
|
|
211
221
|
end
|
212
222
|
alias_method :rb, :ruby
|
213
223
|
|
224
|
+
|
225
|
+
desc "Executes one line of shell code; result is added to the context"
|
226
|
+
def shell(args, context_manager=nil)
|
227
|
+
shell_code = args.join(' ')
|
228
|
+
|
229
|
+
`#{shell_code}`
|
230
|
+
end
|
231
|
+
alias_method :sh, :shell
|
232
|
+
|
214
233
|
desc "Use the system's say command to speak text //say some text"
|
215
|
-
def say(
|
234
|
+
def say(args, context_manager=nil)
|
216
235
|
`say #{args.join(' ')}`
|
217
236
|
""
|
218
237
|
end
|
219
238
|
|
220
239
|
desc "Inserts an instruction to keep responses short and to the point."
|
221
|
-
def terse(
|
240
|
+
def terse(args, context_manager=nil)
|
222
241
|
AIA::Session::TERSE_PROMPT
|
223
242
|
end
|
224
243
|
|
225
244
|
desc "Display the ASCII art AIA robot."
|
226
|
-
def robot(
|
245
|
+
def robot(args, context_manager=nil)
|
227
246
|
AIA::Utility.robot
|
228
247
|
""
|
229
248
|
end
|
230
249
|
|
231
250
|
desc "Generates this help content"
|
232
|
-
def help(
|
251
|
+
def help(args=nil, context_manager=nil)
|
233
252
|
puts
|
234
253
|
puts "Available Directives"
|
235
254
|
puts "===================="
|
data/lib/aia/session.rb
CHANGED
@@ -158,55 +158,55 @@ module AIA
|
|
158
158
|
@ui_presenter.display_chat_header
|
159
159
|
|
160
160
|
Reline::HISTORY.clear # Keep Reline history for user input editing, separate from chat context
|
161
|
-
|
161
|
+
|
162
162
|
# Load context files if any and not skipping
|
163
163
|
if !skip_context_files && AIA.config.context_files && !AIA.config.context_files.empty?
|
164
164
|
context_content = AIA.config.context_files.map do |file|
|
165
165
|
File.read(file) rescue "Error reading file: #{file}"
|
166
166
|
end.join("\n\n")
|
167
|
-
|
167
|
+
|
168
168
|
if !context_content.empty?
|
169
169
|
# Add context files content to context
|
170
170
|
@context_manager.add_to_context(role: 'user', content: context_content)
|
171
|
-
|
171
|
+
|
172
172
|
# Process the context
|
173
173
|
operation_type = @chat_processor.determine_operation_type(AIA.config.model)
|
174
174
|
@ui_presenter.display_thinking_animation
|
175
175
|
response = @chat_processor.process_prompt(@context_manager.get_context, operation_type)
|
176
|
-
|
176
|
+
|
177
177
|
# Add AI response to context
|
178
178
|
@context_manager.add_to_context(role: 'assistant', content: response)
|
179
|
-
|
179
|
+
|
180
180
|
# Output the response
|
181
181
|
@chat_processor.output_response(response)
|
182
182
|
@chat_processor.speak(response)
|
183
183
|
@ui_presenter.display_separator
|
184
184
|
end
|
185
185
|
end
|
186
|
-
|
186
|
+
|
187
187
|
# Check for piped input (STDIN not a TTY and has data)
|
188
188
|
if !STDIN.tty?
|
189
189
|
# Save the original STDIN
|
190
190
|
orig_stdin = STDIN.dup
|
191
|
-
|
191
|
+
|
192
192
|
# Read the piped input
|
193
193
|
piped_input = STDIN.read.strip
|
194
|
-
|
194
|
+
|
195
195
|
# Reopen STDIN to the terminal
|
196
196
|
STDIN.reopen('/dev/tty')
|
197
|
-
|
197
|
+
|
198
198
|
if !piped_input.empty?
|
199
199
|
# Add piped input to context
|
200
200
|
@context_manager.add_to_context(role: 'user', content: piped_input)
|
201
|
-
|
201
|
+
|
202
202
|
# Process the piped input
|
203
203
|
operation_type = @chat_processor.determine_operation_type(AIA.config.model)
|
204
204
|
@ui_presenter.display_thinking_animation
|
205
205
|
response = @chat_processor.process_prompt(@context_manager.get_context, operation_type)
|
206
|
-
|
206
|
+
|
207
207
|
# Add AI response to context
|
208
208
|
@context_manager.add_to_context(role: 'assistant', content: response)
|
209
|
-
|
209
|
+
|
210
210
|
# Output the response
|
211
211
|
@chat_processor.output_response(response)
|
212
212
|
@chat_processor.speak(response)
|
@@ -217,7 +217,7 @@ module AIA
|
|
217
217
|
loop do
|
218
218
|
# Get user input
|
219
219
|
prompt = @ui_presenter.ask_question
|
220
|
-
|
220
|
+
|
221
221
|
|
222
222
|
|
223
223
|
break if prompt.nil? || prompt.strip.downcase == 'exit' || prompt.strip.empty?
|
@@ -232,7 +232,7 @@ module AIA
|
|
232
232
|
directive_output = @directive_processor.process(prompt, @context_manager) # Pass context_manager
|
233
233
|
|
234
234
|
# Add check for specific directives like //clear that might modify context
|
235
|
-
if prompt.strip.start_with?('//clear'
|
235
|
+
if prompt.strip.start_with?('//clear')
|
236
236
|
# Context is likely cleared within directive_processor.process now
|
237
237
|
# or add @context_manager.clear_context here if not handled internally
|
238
238
|
@ui_presenter.display_info("Chat context cleared.")
|
@@ -256,10 +256,6 @@ module AIA
|
|
256
256
|
# Use ContextManager to get the conversation
|
257
257
|
conversation = @context_manager.get_context # System prompt handled internally
|
258
258
|
|
259
|
-
# FIXME: remove this comment once verified
|
260
|
-
# is conversation the same thing as the context for a chat session? YES
|
261
|
-
# if so need to somehow delete it when the //clear directive is entered. - Addressed above/in DirectiveProcessor
|
262
|
-
|
263
259
|
operation_type = @chat_processor.determine_operation_type(AIA.config.model)
|
264
260
|
@ui_presenter.display_thinking_animation
|
265
261
|
response = @chat_processor.process_prompt(conversation, operation_type)
|