aia 0.9.11 → 0.9.12

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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/CHANGELOG.md +66 -2
  4. data/README.md +133 -4
  5. data/docs/advanced-prompting.md +721 -0
  6. data/docs/cli-reference.md +582 -0
  7. data/docs/configuration.md +347 -0
  8. data/docs/contributing.md +332 -0
  9. data/docs/directives-reference.md +490 -0
  10. data/docs/examples/index.md +277 -0
  11. data/docs/examples/mcp/index.md +479 -0
  12. data/docs/examples/prompts/analysis/index.md +78 -0
  13. data/docs/examples/prompts/automation/index.md +108 -0
  14. data/docs/examples/prompts/development/index.md +125 -0
  15. data/docs/examples/prompts/index.md +333 -0
  16. data/docs/examples/prompts/learning/index.md +127 -0
  17. data/docs/examples/prompts/writing/index.md +62 -0
  18. data/docs/examples/tools/index.md +292 -0
  19. data/docs/faq.md +414 -0
  20. data/docs/guides/available-models.md +366 -0
  21. data/docs/guides/basic-usage.md +477 -0
  22. data/docs/guides/chat.md +474 -0
  23. data/docs/guides/executable-prompts.md +417 -0
  24. data/docs/guides/first-prompt.md +454 -0
  25. data/docs/guides/getting-started.md +455 -0
  26. data/docs/guides/image-generation.md +507 -0
  27. data/docs/guides/index.md +46 -0
  28. data/docs/guides/models.md +507 -0
  29. data/docs/guides/tools.md +856 -0
  30. data/docs/index.md +173 -0
  31. data/docs/installation.md +238 -0
  32. data/docs/mcp-integration.md +612 -0
  33. data/docs/prompt_management.md +579 -0
  34. data/docs/security.md +629 -0
  35. data/docs/tools-and-mcp-examples.md +1186 -0
  36. data/docs/workflows-and-pipelines.md +563 -0
  37. data/examples/tools/mcp/github_mcp_server.json +11 -0
  38. data/examples/tools/mcp/imcp.json +7 -0
  39. data/lib/aia/chat_processor_service.rb +19 -3
  40. data/lib/aia/config/base.rb +224 -0
  41. data/lib/aia/config/cli_parser.rb +409 -0
  42. data/lib/aia/config/defaults.rb +88 -0
  43. data/lib/aia/config/file_loader.rb +131 -0
  44. data/lib/aia/config/validator.rb +184 -0
  45. data/lib/aia/config.rb +10 -860
  46. data/lib/aia/directive_processor.rb +27 -372
  47. data/lib/aia/directives/configuration.rb +114 -0
  48. data/lib/aia/directives/execution.rb +37 -0
  49. data/lib/aia/directives/models.rb +178 -0
  50. data/lib/aia/directives/registry.rb +120 -0
  51. data/lib/aia/directives/utility.rb +70 -0
  52. data/lib/aia/directives/web_and_file.rb +71 -0
  53. data/lib/aia/prompt_handler.rb +23 -3
  54. data/lib/aia/ruby_llm_adapter.rb +307 -128
  55. data/lib/aia/session.rb +27 -14
  56. data/lib/aia/utility.rb +12 -8
  57. data/lib/aia.rb +11 -2
  58. data/lib/extensions/ruby_llm/.irbrc +56 -0
  59. data/mkdocs.yml +165 -0
  60. metadata +77 -20
  61. /data/{images → docs/assets/images}/aia.png +0 -0
@@ -0,0 +1,507 @@
1
+ # Working with Models
2
+
3
+ AIA supports multiple AI models through the RubyLLM gem, allowing you to choose the best model for each task and even use multiple models simultaneously.
4
+
5
+ ## Available Models
6
+
7
+ ### List All Models
8
+ ```bash
9
+ # Show all available models
10
+ aia --available_models
11
+
12
+ # Filter by provider
13
+ aia --available_models openai
14
+ aia --available_models anthropic
15
+ aia --available_models google
16
+
17
+ # Filter by capability
18
+ aia --available_models vision
19
+ aia --available_models function_calling
20
+ aia --available_models text_to_image
21
+
22
+ # Complex filtering
23
+ aia --available_models openai,gpt,4
24
+ ```
25
+
26
+ ### Model Information
27
+ Each model listing includes:
28
+ - **Model ID**: Exact name to use with `--model`
29
+ - **Provider**: Company providing the model
30
+ - **Context Window**: Maximum input/output length
31
+ - **Input Cost**: Price per million input tokens
32
+ - **Modalities**: Supported input/output types
33
+ - **Capabilities**: Special features available
34
+
35
+ ## Model Selection
36
+
37
+ ### Single Model Usage
38
+ ```bash
39
+ # Use specific model
40
+ aia --model gpt-4 my_prompt
41
+ aia --model claude-3-sonnet code_review.py
42
+ aia --model gemini-pro analyze_data.csv
43
+
44
+ # Short model names (when unambiguous)
45
+ aia --model gpt-4 my_prompt
46
+ aia --model claude my_prompt
47
+ aia --model gemini my_prompt
48
+ ```
49
+
50
+ ### Model Categories by Use Case
51
+
52
+ #### Text Generation
53
+ **Creative Writing**: High creativity, good with narratives
54
+ - `gpt-4`: Excellent creative writing, good instruction following
55
+ - `claude-3-sonnet`: Great for longer creative pieces
56
+ - `gemini-pro`: Good balance of creativity and structure
57
+
58
+ **Technical Writing**: Accuracy and precision focus
59
+ - `gpt-4`: Strong technical accuracy
60
+ - `claude-3-sonnet`: Excellent for documentation
61
+ - `gpt-3.5-turbo`: Fast, cost-effective for simple technical tasks
62
+
63
+ #### Code Analysis
64
+ **Code Review**: Understanding existing code
65
+ - `gpt-4`: Excellent code comprehension
66
+ - `claude-3-sonnet`: Great at explaining complex code
67
+ - `codellama-34b`: Specialized for code understanding
68
+
69
+ **Code Generation**: Writing new code
70
+ - `gpt-4`: High-quality code generation
71
+ - `claude-3-sonnet`: Good at following coding standards
72
+ - `codellama-7b`: Fast code completion
73
+
74
+ #### Data Analysis
75
+ **Statistical Analysis**: Working with numbers and data
76
+ - `claude-3-sonnet`: Excellent analytical reasoning
77
+ - `gpt-4`: Strong mathematical capabilities
78
+ - `gemini-pro`: Good with structured data
79
+
80
+ **Research**: Processing large amounts of information
81
+ - `claude-3-sonnet`: Large context window, good summarization
82
+ - `gpt-4`: Strong reasoning and synthesis
83
+ - `claude-3-opus`: Highest quality analysis (more expensive)
84
+
85
+ ## Multi-Model Operations
86
+
87
+ ### Parallel Processing
88
+ Run the same prompt with multiple models:
89
+ ```bash
90
+ # Compare outputs from different models
91
+ aia --model "gpt-4,claude-3-sonnet,gemini-pro" my_prompt
92
+
93
+ # Each model provides separate response
94
+ ```
95
+
96
+ ### Consensus Mode
97
+ Get unified response from multiple models:
98
+ ```bash
99
+ # Enable consensus mode
100
+ aia --model "gpt-4,claude-3-sonnet" --consensus my_prompt
101
+
102
+ # Works in chat mode too
103
+ aia --chat --model "gpt-4o-mini,gpt-3.5-turbo" --consensus
104
+
105
+ # Models collaborate to provide single, refined response
106
+ ```
107
+
108
+ **Consensus Output Format:**
109
+ ```
110
+ from: gpt-4o-mini (consensus)
111
+ Based on the insights from multiple AI models, here is a comprehensive answer that
112
+ incorporates the best perspectives and resolves any contradictions...
113
+ ```
114
+
115
+ ### Individual Response Mode
116
+
117
+ By default, each model provides its own separate response:
118
+
119
+ ```bash
120
+ # Default behavior - show individual responses
121
+ aia --model "gpt-4o-mini,gpt-3.5-turbo,gpt-5-mini" my_prompt
122
+
123
+ # Explicitly disable consensus
124
+ aia --model "gpt-4o-mini,gpt-3.5-turbo" --no-consensus my_prompt
125
+ ```
126
+
127
+ **Individual Responses Output Format:**
128
+ ```
129
+ from: gpt-4o-mini
130
+ Response from the first model...
131
+
132
+ from: gpt-3.5-turbo
133
+ Response from the second model...
134
+
135
+ from: gpt-5-mini
136
+ Response from the third model...
137
+ ```
138
+
139
+ ### Model Configuration Status
140
+
141
+ View your current multi-model configuration using the `//model` directive:
142
+
143
+ ```bash
144
+ # In any prompt file or in chat session
145
+ //model
146
+ ```
147
+
148
+ **Example Output:**
149
+ ```
150
+ Multi-Model Configuration:
151
+ ==========================
152
+ Model count: 3
153
+ Primary model: gpt-4o-mini (used for consensus when --consensus flag is enabled)
154
+ Consensus mode: false
155
+
156
+ Model Details:
157
+ --------------------------------------------------
158
+ 1. gpt-4o-mini (primary)
159
+ 2. gpt-3.5-turbo
160
+ 3. gpt-5-mini
161
+ ```
162
+
163
+ **Multi-Model Features:**
164
+ - **Primary Model**: The first model in the list serves as the consensus orchestrator
165
+ - **Concurrent Processing**: All models run simultaneously for better performance
166
+ - **Flexible Output**: Choose between individual responses or synthesized consensus
167
+ - **Error Handling**: Invalid models are reported but don't prevent valid models from working
168
+ - **Batch Mode Support**: Multi-model responses are properly formatted in output files
169
+
170
+ ### Model Comparison in Prompts
171
+ ```markdown
172
+ Compare responses from multiple models:
173
+ //compare "Explain quantum computing" --models gpt-4,claude-3-sonnet,gemini-pro
174
+
175
+ Which explanation is most accessible?
176
+ ```
177
+
178
+ ## Model Configuration
179
+
180
+ ### Model-Specific Settings
181
+ Different models may work best with different parameters:
182
+
183
+ #### GPT Models
184
+ ```yaml
185
+ # ~/.aia/models/gpt-4.yml
186
+ temperature: 0.7
187
+ max_tokens: 4000
188
+ top_p: 1.0
189
+ frequency_penalty: 0.0
190
+ presence_penalty: 0.0
191
+ ```
192
+
193
+ #### Claude Models
194
+ ```yaml
195
+ # ~/.aia/models/claude-3-sonnet.yml
196
+ temperature: 0.8
197
+ max_tokens: 8000
198
+ top_p: 0.9
199
+ ```
200
+
201
+ #### Gemini Models
202
+ ```yaml
203
+ # ~/.aia/models/gemini-pro.yml
204
+ temperature: 0.6
205
+ max_tokens: 2000
206
+ top_p: 0.95
207
+ ```
208
+
209
+ ### Dynamic Model Selection
210
+ Choose models based on task characteristics:
211
+
212
+ ```ruby
213
+ # In prompt with Ruby directive
214
+ //ruby
215
+ task_type = '<%= task_type %>'
216
+ model = case task_type
217
+ when 'creative' then 'gpt-4'
218
+ when 'analytical' then 'claude-3-sonnet'
219
+ when 'code' then 'codellama-34b'
220
+ else 'gpt-3.5-turbo'
221
+ end
222
+ puts "//config model #{model}"
223
+ ```
224
+
225
+ ## Model Performance Optimization
226
+
227
+ ### Speed vs Quality Tradeoffs
228
+
229
+ #### Fast Models (Lower Cost, Quicker Response)
230
+ ```bash
231
+ # Quick tasks, simple questions
232
+ aia --model gpt-3.5-turbo simple_question
233
+
234
+ # Code completion, basic analysis
235
+ aia --model claude-3-haiku code_completion
236
+
237
+ # Bulk processing
238
+ for file in *.txt; do
239
+ aia --model gpt-3.5-turbo --out_file "${file%.txt}_processed.md" process_file "$file"
240
+ done
241
+ ```
242
+
243
+ #### Quality Models (Higher Cost, Better Results)
244
+ ```bash
245
+ # Complex analysis, important decisions
246
+ aia --model gpt-4 strategic_analysis.md
247
+
248
+ # Creative writing, nuanced tasks
249
+ aia --model claude-3-opus --temperature 1.0 creative_writing
250
+
251
+ # Critical code review
252
+ aia --model gpt-4 --temperature 0.2 security_review.py
253
+ ```
254
+
255
+ ### Context Window Management
256
+
257
+ #### Large Context Models
258
+ For processing large documents:
259
+ ```bash
260
+ # Claude has the largest context window
261
+ aia --model claude-3-sonnet large_document.pdf
262
+
263
+ # GPT-4 Turbo for large contexts
264
+ aia --model gpt-4-turbo comprehensive_analysis.md
265
+ ```
266
+
267
+ #### Context-Aware Processing
268
+ ```bash
269
+ # Check document size and choose appropriate model
270
+ //ruby
271
+ file_size = File.size('<%= file %>')
272
+ model = file_size > 100000 ? 'claude-3-sonnet' : 'gpt-4'
273
+ puts "//config model #{model}"
274
+
275
+ # Process with selected model
276
+ ```
277
+
278
+ ## Model Capabilities
279
+
280
+ ### Vision Models
281
+ For image analysis and processing:
282
+ ```bash
283
+ # Analyze images
284
+ aia --model gpt-4-vision image_analysis.jpg
285
+
286
+ # Process screenshots
287
+ aia --model gpt-4-vision --temperature 0.3 screenshot_analysis.png
288
+
289
+ # Extract text from images
290
+ aia --model gpt-4-vision extract_text_prompt image_with_text.jpg
291
+ ```
292
+
293
+ ### Function Calling Models
294
+ For tool integration:
295
+ ```bash
296
+ # Models that support function calling
297
+ aia --model gpt-4 --tools ./tools/ analysis_with_tools
298
+
299
+ # Best function calling models
300
+ aia --model gpt-3.5-turbo --tools ./tools/ tool_heavy_task
301
+ ```
302
+
303
+ ### Code Models
304
+ Specialized for programming tasks:
305
+ ```bash
306
+ # Code-specific models
307
+ aia --model codellama-34b code_generation_task
308
+
309
+ # Programming assistance
310
+ aia --model codellama-7b --temperature 0.1 debug_assistance
311
+ ```
312
+
313
+ ## Cost Management
314
+
315
+ ### Model Pricing Considerations
316
+
317
+ #### Monitor Usage
318
+ ```bash
319
+ # Enable verbose mode to see token usage
320
+ aia --verbose --model gpt-4 expensive_task
321
+
322
+ # Use debug mode for detailed cost tracking
323
+ aia --debug --model claude-3-opus cost_analysis
324
+ ```
325
+
326
+ #### Cost-Effective Strategies
327
+ ```bash
328
+ # Use cheaper models for initial drafts
329
+ aia --model gpt-3.5-turbo initial_draft
330
+
331
+ # Refine with better models
332
+ aia --model gpt-4 --include initial_draft.md refine_output
333
+
334
+ # Batch processing with efficient models
335
+ aia --model claude-3-haiku --pipeline "process,summarize" batch_files/
336
+ ```
337
+
338
+ ### Budget-Conscious Model Selection
339
+ ```yaml
340
+ # Cost-effective configuration
341
+ budget_models:
342
+ fast_tasks: gpt-3.5-turbo
343
+ analysis: claude-3-haiku
344
+ creative: gpt-3.5-turbo
345
+
346
+ premium_models:
347
+ critical_analysis: gpt-4
348
+ creative_writing: claude-3-sonnet
349
+ complex_reasoning: claude-3-opus
350
+ ```
351
+
352
+ ## Model-Specific Tips
353
+
354
+ ### GPT Models
355
+ - **GPT-4**: Best for complex reasoning, creative tasks
356
+ - **GPT-3.5 Turbo**: Fast, cost-effective, good general model
357
+ - **GPT-4 Vision**: Excellent for image analysis
358
+ - **Best for**: Code generation, creative writing, general tasks
359
+
360
+ ### Claude Models
361
+ - **Claude-3 Opus**: Highest quality, most expensive
362
+ - **Claude-3 Sonnet**: Great balance of quality and cost
363
+ - **Claude-3 Haiku**: Fastest, most cost-effective
364
+ - **Best for**: Long documents, analytical tasks, following instructions
365
+
366
+ ### Gemini Models
367
+ - **Gemini Pro**: Google's flagship model
368
+ - **Gemini Pro Vision**: Multimodal capabilities
369
+ - **Best for**: Structured data, mathematical reasoning
370
+
371
+ ### Specialized Models
372
+ - **CodeLlama**: Open-source code generation
373
+ - **Llama 2**: Open-source general purpose
374
+ - **Mixtral**: High-performance open model
375
+
376
+ ## Troubleshooting Models
377
+
378
+ ### Common Issues
379
+
380
+ #### Model Not Available
381
+ ```bash
382
+ # Check if model exists
383
+ aia --available_models | grep model_name
384
+
385
+ # Try alternative model names
386
+ aia --available_models anthropic
387
+ ```
388
+
389
+ #### Authentication Errors
390
+ ```bash
391
+ # Check API keys
392
+ echo $OPENAI_API_KEY
393
+ echo $ANTHROPIC_API_KEY
394
+
395
+ # Test with working model
396
+ aia --model gpt-3.5-turbo test_prompt
397
+ ```
398
+
399
+ #### Context Length Exceeded
400
+ ```bash
401
+ # Use model with larger context
402
+ aia --model claude-3-sonnet large_document.pdf
403
+
404
+ # Split large inputs
405
+ split -l 1000 large_file.txt chunk_
406
+ for chunk in chunk_*; do
407
+ aia --model gpt-4 process_chunk "$chunk"
408
+ done
409
+ ```
410
+
411
+ #### Rate Limiting
412
+ ```bash
413
+ # Add delays between requests
414
+ sleep 1 && aia --model gpt-4 request1
415
+ sleep 1 && aia --model gpt-4 request2
416
+
417
+ # Use different model to avoid limits
418
+ aia --model claude-3-sonnet alternative_processing
419
+ ```
420
+
421
+ ## Advanced Model Usage
422
+
423
+ ### Model Switching Workflows
424
+ ```bash
425
+ # Start with fast model for initial processing
426
+ aia --model gpt-3.5-turbo --out_file draft.md initial_analysis data.csv
427
+
428
+ # Switch to quality model for refinement
429
+ aia --model gpt-4 --include draft.md --out_file final.md refine_analysis
430
+
431
+ # Use specialized model for specific tasks
432
+ aia --model gpt-4-vision --include final.md image_analysis charts/
433
+ ```
434
+
435
+ ### Conditional Model Selection
436
+ ```ruby
437
+ # Dynamic model selection based on task complexity
438
+ //ruby
439
+ content_length = File.read('<%= input_file %>').length
440
+ complexity = content_length > 10000 ? 'high' : 'low'
441
+
442
+ model = case complexity
443
+ when 'high' then 'claude-3-sonnet'
444
+ when 'low' then 'gpt-3.5-turbo'
445
+ end
446
+
447
+ puts "//config model #{model}"
448
+ puts "Selected #{model} for #{complexity} complexity task"
449
+ ```
450
+
451
+ ### Model Ensemble Techniques
452
+ ```bash
453
+ # Use different models for different aspects
454
+ aia --model gpt-4 --out_file technical_analysis.md technical_review code.py
455
+ aia --model claude-3-sonnet --out_file style_analysis.md style_review code.py
456
+ aia --model gpt-3.5-turbo --include technical_analysis.md --include style_analysis.md synthesize_reviews
457
+ ```
458
+
459
+ ## Integration with Other Features
460
+
461
+ ### Chat Mode Model Management
462
+ ```bash
463
+ # Start chat with specific model
464
+ aia --chat --model gpt-4
465
+
466
+ # Switch models during chat
467
+ You: /model claude-3-sonnet
468
+ AI: Switched to claude-3-sonnet
469
+
470
+ # Compare models in chat
471
+ You: //compare "Explain this concept" --models gpt-4,claude-3-sonnet
472
+ ```
473
+
474
+ ### Pipeline Model Configuration
475
+ ```bash
476
+ # Different models for different pipeline stages
477
+ aia --config_file pipeline_config.yml --pipeline "extract,analyze,report"
478
+
479
+ # pipeline_config.yml
480
+ extract:
481
+ model: gpt-3.5-turbo
482
+ analyze:
483
+ model: claude-3-sonnet
484
+ report:
485
+ model: gpt-4
486
+ ```
487
+
488
+ ### Tool Integration
489
+ ```bash
490
+ # Use models optimized for function calling with tools
491
+ aia --model gpt-3.5-turbo --tools ./analysis_tools/ data_processing
492
+
493
+ # Vision models with image processing tools
494
+ aia --model gpt-4-vision --tools ./image_tools/ visual_analysis
495
+ ```
496
+
497
+ ## Related Documentation
498
+
499
+ - [Available Models](available-models.md) - Complete model list
500
+ - [Configuration](../configuration.md) - Model configuration options
501
+ - [CLI Reference](../cli-reference.md) - Command-line model options
502
+ - [Chat Mode](chat.md) - Interactive model usage
503
+ - [Advanced Prompting](../advanced-prompting.md) - Model-specific prompting techniques
504
+
505
+ ---
506
+
507
+ Choosing the right model for each task is crucial for optimal results. Experiment with different models to find what works best for your specific use cases!