aia 1.1.0 → 2.0.0.0.pre.alpha
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/.envrc +5 -1
- data/.loki +231 -0
- data/.quality/flay_baseline.txt +1 -0
- data/.quality/flog_baseline.txt +29 -0
- data/.quality/reek_baseline.txt +80 -0
- data/.rubocop.yml +116 -0
- data/.version +1 -1
- data/CHANGELOG.md +266 -42
- data/IMPLEMENTATION_PLAN.md +506 -0
- data/README.md +266 -238
- data/Rakefile +118 -5
- data/architecture_review.md +314 -0
- data/bin/aia +16 -0
- data/docs/AGENTS.md +40 -0
- data/docs/advanced-prompting.md +67 -3
- data/docs/cli-reference.md +312 -56
- data/docs/configuration.md +130 -19
- data/docs/contributing.md +56 -2
- data/docs/directives-reference.md +593 -78
- data/docs/faq.md +85 -3
- data/docs/guides/available-models.md +1 -1
- data/docs/guides/basic-usage.md +6 -6
- data/docs/guides/chat.md +40 -16
- data/docs/guides/crew.md +239 -0
- data/docs/guides/executable-prompts.md +1 -1
- data/docs/guides/index.md +1 -0
- data/docs/guides/models.md +15 -0
- data/docs/index.md +29 -2
- data/docs/installation.md +44 -17
- data/docs/mcp-integration.md +40 -0
- data/docs/prompt_management.md +85 -86
- data/docs/security.md +47 -0
- data/docs/special_projects_guide.md +386 -0
- data/docs/tools-and-mcp-examples.md +23 -0
- data/docs/workflows-and-pipelines.md +84 -7
- data/examples/.gitignore +1 -0
- data/examples/00_setup_aia.sh +27 -44
- data/examples/11_multi_model.sh +4 -14
- data/examples/12_token_usage.sh +3 -12
- data/examples/18_tools.sh +10 -2
- data/examples/22_chat_mode.sh +0 -10
- data/examples/23_verify.sh +139 -0
- data/examples/24_decompose.sh +139 -0
- data/examples/25_spawn.sh +139 -0
- data/examples/26_debate.sh +97 -0
- data/examples/27_mention_routing.sh +157 -0
- data/examples/28_model_switching.sh +106 -0
- data/examples/29_agent_harness.sh +177 -0
- data/examples/README.md +65 -0
- data/examples/advanced_multi_robot_capabilities_without_examples.md +106 -0
- data/examples/aia_config.yml +1 -1
- data/examples/aia_config_orchestrator.yml +45 -0
- data/examples/common.sh +19 -0
- data/examples/context/tech_stack.md +2 -2
- data/examples/prompts_dir/project_summary +2 -2
- data/examples/prompts_dir/roles/orchestrator.md +21 -0
- data/examples/requirements/sinatra_taskflow_app.md +139 -0
- data/examples/rules/01_classify_ruby.rb +16 -0
- data/examples/rules/02_prefer_claude_for_code.rb +19 -0
- data/examples/rules/03_gate_prompt_length.rb +19 -0
- data/examples/rules/04_tool_selection.rb +41 -0
- data/examples/rules/README.md +30 -0
- data/examples/run_all.sh +48 -15
- data/examples/tools/word_count_tool.rb +1 -1
- data/lib/AGENTS.md +57 -0
- data/lib/aia/chat_loop.rb +306 -159
- data/lib/aia/config/cli_parser.rb +174 -111
- data/lib/aia/config/defaults.yml +62 -33
- data/lib/aia/config/mcp_parser.rb +39 -46
- data/lib/aia/config/model_spec.rb +34 -2
- data/lib/aia/config/validator.rb +121 -138
- data/lib/aia/config.rb +110 -145
- data/lib/aia/content_extractor.rb +153 -0
- data/lib/aia/cost_calculator.rb +38 -0
- data/lib/aia/crew.rb +164 -0
- data/lib/aia/debate_handler.rb +166 -0
- data/lib/aia/delegate_handler.rb +112 -0
- data/lib/aia/directive.rb +33 -18
- data/lib/aia/directive_processor.rb +16 -7
- data/lib/aia/directives/configuration_directives.rb +160 -20
- data/lib/aia/directives/context_directives.rb +38 -26
- data/lib/aia/directives/execution_directives.rb +136 -4
- data/lib/aia/directives/model_directives.rb +76 -34
- data/lib/aia/directives/trakflow_directives.rb +44 -0
- data/lib/aia/directives/utility_directives.rb +203 -6
- data/lib/aia/directives/web_and_file_directives.rb +96 -60
- data/lib/aia/errors.rb +15 -0
- data/lib/aia/fact_asserter.rb +27 -0
- data/lib/aia/fzf.rb +9 -31
- data/lib/aia/handler_context.rb +17 -0
- data/lib/aia/handler_protocol.rb +19 -0
- data/lib/aia/history_transfer.rb +55 -0
- data/lib/aia/input_collector.rb +3 -3
- data/lib/aia/layered_orchestrator.rb +448 -0
- data/lib/aia/logger.rb +24 -4
- data/lib/aia/mcp_config_normalizer.rb +35 -0
- data/lib/aia/mcp_connection_manager.rb +305 -0
- data/lib/aia/mcp_discovery.rb +44 -0
- data/lib/aia/mcp_grouper.rb +33 -0
- data/lib/aia/mcp_utility.rb +57 -0
- data/lib/aia/mention_router.rb +260 -0
- data/lib/aia/model_alias_registry.rb +97 -0
- data/lib/aia/model_switch_handler.rb +100 -0
- data/lib/aia/network_builder.rb +155 -0
- data/lib/aia/network_memory_manager.rb +55 -0
- data/lib/aia/patches/ruby_llm_streaming_error.rb +43 -0
- data/lib/aia/patches/ruby_llm_tool_error.rb +96 -0
- data/lib/aia/pipeline_orchestrator.rb +262 -0
- data/lib/aia/plugin_loader.rb +170 -0
- data/lib/aia/plugin_monitor.rb +208 -0
- data/lib/aia/prompt_decomposer.rb +157 -0
- data/lib/aia/prompt_handler.rb +19 -39
- data/lib/aia/robot_builder.rb +51 -0
- data/lib/aia/robot_factory.rb +334 -0
- data/lib/aia/robot_namer.rb +116 -0
- data/lib/aia/session.rb +83 -17
- data/lib/aia/session_tracker.rb +209 -0
- data/lib/aia/similarity_scorer.rb +39 -0
- data/lib/aia/skill_utils.rb +105 -1
- data/lib/aia/spawn_handler.rb +129 -0
- data/lib/aia/spawn_spec_parser.rb +65 -0
- data/lib/aia/special_mode_handler.rb +302 -0
- data/lib/aia/startup_coordinator.rb +150 -0
- data/lib/aia/streaming_runner.rb +169 -0
- data/lib/aia/system_prompt_assembler.rb +88 -0
- data/lib/aia/task_coordinator.rb +202 -0
- data/lib/aia/task_decomposer.rb +57 -0
- data/lib/aia/task_executor.rb +51 -0
- data/lib/aia/tfidf_math.rb +27 -0
- data/lib/aia/tool_filter/tfidf.rb +116 -0
- data/lib/aia/tool_filter/wordnet_expander.rb +127 -0
- data/lib/aia/tool_filter.rb +82 -0
- data/lib/aia/tool_filter_registry.rb +30 -0
- data/lib/aia/tool_filter_strategy.rb +143 -0
- data/lib/aia/tool_loader.rb +210 -0
- data/lib/aia/tool_utility.rb +30 -0
- data/lib/aia/tools/delegate_to_foreman_tool.rb +70 -0
- data/lib/aia/tools/recruit_robot_tool.rb +60 -0
- data/lib/aia/tools/reskill_robot_tool.rb +44 -0
- data/lib/aia/tools/task_board_tool.rb +114 -0
- data/lib/aia/trakflow_bridge.rb +173 -0
- data/lib/aia/turn_state.rb +94 -0
- data/lib/aia/ui_presenter.rb +166 -198
- data/lib/aia/utility.rb +134 -87
- data/lib/aia/{history_manager.rb → variable_input_collector.rb} +8 -9
- data/lib/aia/verification_network.rb +58 -0
- data/lib/aia.rb +108 -63
- data/mkdocs.yml +1 -0
- metadata +179 -56
- data/justfile +0 -215
- data/lib/aia/adapter/chat_execution.rb +0 -242
- data/lib/aia/adapter/error_handler.rb +0 -68
- data/lib/aia/adapter/gem_activator.rb +0 -57
- data/lib/aia/adapter/mcp_connector.rb +0 -274
- data/lib/aia/adapter/modality_handlers.rb +0 -167
- data/lib/aia/adapter/model_registry.rb +0 -81
- data/lib/aia/adapter/multi_model_chat.rb +0 -218
- data/lib/aia/adapter/provider_configurator.rb +0 -59
- data/lib/aia/adapter/tool_filter.rb +0 -85
- data/lib/aia/adapter/tool_loader.rb +0 -90
- data/lib/aia/chat_processor_service.rb +0 -164
- data/lib/aia/prompt_pipeline.rb +0 -183
- data/lib/aia/ruby_llm_adapter.rb +0 -95
- data/lib/extensions/openstruct_merge.rb +0 -48
- data/lib/extensions/ruby_llm/.irbrc +0 -56
- data/lib/extensions/ruby_llm/modalities.rb +0 -36
- data/lib/extensions/ruby_llm/provider_fix.rb +0 -79
- data/lib/refinements/string.rb +0 -16
- data/main.just +0 -76
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [Tools and MCP Examples](#tools-and-mcp-examples)
|
|
6
|
+
- [Real-World Tool Examples](#real-world-tool-examples)
|
|
7
|
+
- [File Processing Tools](#file-processing-tools)
|
|
8
|
+
- [Advanced Log Analyzer](#advanced-log-analyzer)
|
|
9
|
+
- [Configuration File Manager](#configuration-file-manager)
|
|
10
|
+
- [Development Tools](#development-tools)
|
|
11
|
+
- [Code Quality Analyzer](#code-quality-analyzer)
|
|
12
|
+
- [MCP Integration Examples](#mcp-integration-examples)
|
|
13
|
+
- [GitHub Repository Analyzer MCP](#github-repository-analyzer-mcp)
|
|
14
|
+
- [Database Schema Analyzer MCP](#database-schema-analyzer-mcp)
|
|
15
|
+
- [Integration Workflows](#integration-workflows)
|
|
16
|
+
- [Full-Stack Application Analysis](#full-stack-application-analysis)
|
|
17
|
+
- [DevOps Pipeline Assessment](#devops-pipeline-assessment)
|
|
18
|
+
- [Advanced Integration Patterns](#advanced-integration-patterns)
|
|
19
|
+
- [Multi-Environment Consistency Checker](#multi-environment-consistency-checker)
|
|
20
|
+
- [Related Documentation](#related-documentation)
|
|
21
|
+
|
|
22
|
+
<!-- Tocer[finish]: Auto-generated, don't remove. -->
|
|
23
|
+
|
|
1
24
|
# Tools and MCP Examples
|
|
2
25
|
|
|
3
26
|
This comprehensive collection showcases real-world examples of RubyLLM tools and MCP client integrations, demonstrating practical applications and advanced techniques.
|
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [Workflows and Pipelines](#workflows-and-pipelines)
|
|
6
|
+
- [Understanding Workflows](#understanding-workflows)
|
|
7
|
+
- [Basic Concepts](#basic-concepts)
|
|
8
|
+
- [Simple Workflows](#simple-workflows)
|
|
9
|
+
- [Sequential Processing](#sequential-processing)
|
|
10
|
+
- [Basic Pipeline](#basic-pipeline)
|
|
11
|
+
- [Pipeline Definition](#pipeline-definition)
|
|
12
|
+
- [Command Line Pipelines](#command-line-pipelines)
|
|
13
|
+
- [Directive-Based Pipelines](#directive-based-pipelines)
|
|
14
|
+
- [Dynamic Pipeline Generation](#dynamic-pipeline-generation)
|
|
15
|
+
- [Advanced Workflow Patterns](#advanced-workflow-patterns)
|
|
16
|
+
- [Conditional Workflows](#conditional-workflows)
|
|
17
|
+
- [Parallel Processing Workflows](#parallel-processing-workflows)
|
|
18
|
+
- [Error Recovery Workflows](#error-recovery-workflows)
|
|
19
|
+
- [State Management in Workflows](#state-management-in-workflows)
|
|
20
|
+
- [Context Persistence](#context-persistence)
|
|
21
|
+
- [Data Passing Between Stages](#data-passing-between-stages)
|
|
22
|
+
- [Current Stage: <%= current_stage.capitalize %>](#current-stage--current_stagecapitalize-)
|
|
23
|
+
- [Analysis Task](#analysis-task)
|
|
24
|
+
- [Prepare data for next stage (this would be set by the AI response processing)](#prepare-data-for-next-stage-this-would-be-set-by-the-ai-response-processing)
|
|
25
|
+
- [This would typically be saved after AI processing](#this-would-typically-be-saved-after-ai-processing)
|
|
26
|
+
- [master_controller.md](#master_controllermd)
|
|
27
|
+
- [Master Workflow Controller](#master-workflow-controller)
|
|
28
|
+
- [workflow_monitor.md](#workflow_monitormd)
|
|
29
|
+
- [Setup workflow logging](#setup-workflow-logging)
|
|
30
|
+
- [Log workflow start](#log-workflow-start)
|
|
31
|
+
- [model_optimized_workflow.md](#model_optimized_workflowmd)
|
|
32
|
+
- [cached_workflow.md](#cached_workflowmd)
|
|
33
|
+
- [Create cache key from inputs and configuration](#create-cache-key-from-inputs-and-configuration)
|
|
34
|
+
- [software_dev_pipeline.md](#software_dev_pipelinemd)
|
|
35
|
+
- [Software Development Pipeline](#software-development-pipeline)
|
|
36
|
+
- [Pipeline Stages:](#pipeline-stages)
|
|
37
|
+
- [content_creation_pipeline.md](#content_creation_pipelinemd)
|
|
38
|
+
- [Content Creation Pipeline](#content-creation-pipeline)
|
|
39
|
+
- [Research Phase](#research-phase)
|
|
40
|
+
- [data_science_workflow.md](#data_science_workflowmd)
|
|
41
|
+
- [Checkpoints in Interactive Workflows](#checkpoints-in-interactive-workflows)
|
|
42
|
+
- [Workflow Best Practices](#workflow-best-practices)
|
|
43
|
+
- [Design Principles](#design-principles)
|
|
44
|
+
- [Performance Considerations](#performance-considerations)
|
|
45
|
+
- [Maintenance and Debugging](#maintenance-and-debugging)
|
|
46
|
+
- [Troubleshooting Workflows](#troubleshooting-workflows)
|
|
47
|
+
- [Common Issues](#common-issues)
|
|
48
|
+
- [Workflow Interruption](#workflow-interruption)
|
|
49
|
+
- [Context Size Issues](#context-size-issues)
|
|
50
|
+
- [Model Rate Limiting](#model-rate-limiting)
|
|
51
|
+
- [Related Documentation](#related-documentation)
|
|
52
|
+
|
|
53
|
+
<!-- Tocer[finish]: Auto-generated, don't remove. -->
|
|
54
|
+
|
|
1
55
|
# Workflows and Pipelines
|
|
2
56
|
|
|
3
57
|
AIA's workflow system allows you to chain prompts together, creating sophisticated multi-stage processes for complex tasks. This enables automated processing pipelines that can handle everything from simple two-step workflows to complex enterprise-level automation.
|
|
@@ -8,9 +62,21 @@ AIA's workflow system allows you to chain prompts together, creating sophisticat
|
|
|
8
62
|
|
|
9
63
|
**Workflow**: A sequence of prompts executed in order, where each prompt can pass context to the next.
|
|
10
64
|
|
|
11
|
-
**
|
|
65
|
+
**Next Prompt**: The immediate next prompt to execute after the current one completes. Specified as a `next` key in the YAML front matter of a `.md` prompt file:
|
|
66
|
+
|
|
67
|
+
```yaml
|
|
68
|
+
---
|
|
69
|
+
next: summary
|
|
70
|
+
---
|
|
71
|
+
```
|
|
12
72
|
|
|
13
|
-
**
|
|
73
|
+
**Pipeline**: A predefined sequence of prompt IDs specified as a `pipeline` key in YAML front matter, or via `--pipeline` on the command line. These keys are placed at the top of the `.md` prompt file and are processed during prompt loading, not as chat-time directives:
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
---
|
|
77
|
+
pipeline: analyze_data,generate_insights,write_report
|
|
78
|
+
---
|
|
79
|
+
```
|
|
14
80
|
|
|
15
81
|
**Context Passing**: Information and results flow from one prompt to the next in the sequence.
|
|
16
82
|
|
|
@@ -19,7 +85,9 @@ AIA's workflow system allows you to chain prompts together, creating sophisticat
|
|
|
19
85
|
### Sequential Processing
|
|
20
86
|
```markdown
|
|
21
87
|
# first_prompt.md
|
|
22
|
-
|
|
88
|
+
---
|
|
89
|
+
next: second_prompt
|
|
90
|
+
---
|
|
23
91
|
/config model gpt-4
|
|
24
92
|
|
|
25
93
|
Analyze the following data and prepare it for detailed analysis:
|
|
@@ -62,9 +130,14 @@ aia --model gpt-4 --pipeline "review,optimize,test" code.py
|
|
|
62
130
|
```
|
|
63
131
|
|
|
64
132
|
### Directive-Based Pipelines
|
|
133
|
+
|
|
134
|
+
The `pipeline` key is placed in YAML front matter at the top of the prompt file and is processed during prompt loading:
|
|
135
|
+
|
|
65
136
|
```markdown
|
|
66
137
|
# pipeline_starter.md
|
|
67
|
-
|
|
138
|
+
---
|
|
139
|
+
pipeline: analyze_data,generate_insights,create_visualization,write_report
|
|
140
|
+
---
|
|
68
141
|
/config model claude-3-sonnet
|
|
69
142
|
|
|
70
143
|
# Data Analysis Pipeline
|
|
@@ -216,7 +289,7 @@ state['current_stage'] = stage_name
|
|
|
216
289
|
state['data'][stage_name] = {
|
|
217
290
|
'started_at' => Time.now.iso8601,
|
|
218
291
|
'input_file' => '<%= input_file %>',
|
|
219
|
-
'model' => AIA.config.
|
|
292
|
+
'model' => AIA.config.models.first&.name
|
|
220
293
|
}
|
|
221
294
|
|
|
222
295
|
# Save state
|
|
@@ -325,7 +398,7 @@ workflow_id = ENV['WORKFLOW_ID'] || SecureRandom.uuid
|
|
|
325
398
|
# Log workflow start
|
|
326
399
|
logger.info("Workflow #{workflow_id} started")
|
|
327
400
|
logger.info("Stage: <%= stage_name %>")
|
|
328
|
-
logger.info("Model: #{AIA.config.
|
|
401
|
+
logger.info("Model: #{AIA.config.models.first&.name}")
|
|
329
402
|
logger.info("Input: <%= input_description %>")
|
|
330
403
|
|
|
331
404
|
start_time = Time.now
|
|
@@ -373,7 +446,7 @@ require 'digest'
|
|
|
373
446
|
cache_inputs = {
|
|
374
447
|
'stage' => '<%= stage_name %>',
|
|
375
448
|
'input_file' => '<%= input_file %>',
|
|
376
|
-
'model' => AIA.config.
|
|
449
|
+
'model' => AIA.config.models.first&.name,
|
|
377
450
|
'temperature' => AIA.config.temperature
|
|
378
451
|
}
|
|
379
452
|
|
|
@@ -481,6 +554,10 @@ Pipeline optimized for <%= complexity %> analysis with <%= selected_pipeline.len
|
|
|
481
554
|
/config temperature 0.3
|
|
482
555
|
```
|
|
483
556
|
|
|
557
|
+
### Checkpoints in Interactive Workflows
|
|
558
|
+
|
|
559
|
+
In interactive chat-based workflows, use `/checkpoint` to save the current conversation state at a meaningful point, and `/restore` to return to that saved state if a later branch produces unsatisfactory results. This is especially useful when running multi-stage workflows that involve experimental or speculative steps.
|
|
560
|
+
|
|
484
561
|
## Workflow Best Practices
|
|
485
562
|
|
|
486
563
|
### Design Principles
|
data/examples/.gitignore
CHANGED
data/examples/00_setup_aia.sh
CHANGED
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
#
|
|
7
7
|
# What it does:
|
|
8
8
|
# 1. Verifies aia is installed
|
|
9
|
-
# 2. Verifies
|
|
10
|
-
# 3.
|
|
11
|
-
# 4.
|
|
12
|
-
# 5. Writes examples/aia_config.yml for use with -c flag
|
|
9
|
+
# 2. Verifies OPENAI_API_KEY is set
|
|
10
|
+
# 3. Verifies examples/prompts_dir exists
|
|
11
|
+
# 4. Writes examples/aia_config.yml for use with -c flag
|
|
13
12
|
#
|
|
14
13
|
# Each demo script sources common.sh which clears AIA_* env vars
|
|
15
14
|
# and sets CONFIG=aia_config.yml for clean, isolated runs.
|
|
@@ -24,9 +23,16 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
24
23
|
PROMPTS_DIR="${SCRIPT_DIR}/prompts_dir"
|
|
25
24
|
CONFIG_FILE="${SCRIPT_DIR}/aia_config.yml"
|
|
26
25
|
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
|
|
26
|
+
# When running from inside the development repo, prefer the local bin/aia
|
|
27
|
+
# over any system-installed gem so setup reflects the version being demoed.
|
|
28
|
+
REPO_BIN="$(cd "${SCRIPT_DIR}/.." && pwd)/bin"
|
|
29
|
+
if [ -f "${REPO_BIN}/aia" ]; then
|
|
30
|
+
export PATH="${REPO_BIN}:${PATH}"
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# The model to use for demos. gpt-4.1 is OpenAI's flagship model with
|
|
34
|
+
# strong instruction-following and tool-calling support.
|
|
35
|
+
DEMO_MODEL="gpt-4.1"
|
|
30
36
|
|
|
31
37
|
echo "=== AIA Examples Setup ==="
|
|
32
38
|
echo
|
|
@@ -34,51 +40,28 @@ echo
|
|
|
34
40
|
# --- Step 1: Check that aia is installed ---
|
|
35
41
|
|
|
36
42
|
if ! command -v aia &> /dev/null; then
|
|
37
|
-
echo "ERROR: 'aia' is not
|
|
38
|
-
echo "
|
|
43
|
+
echo "ERROR: 'aia' is not found."
|
|
44
|
+
echo " From the repo: just install (installs local build)"
|
|
45
|
+
echo " From RubyGems: gem install aia"
|
|
39
46
|
exit 1
|
|
40
47
|
fi
|
|
41
48
|
|
|
42
49
|
AIA_VERSION=$(aia --version 2>/dev/null || echo "unknown")
|
|
43
50
|
echo "[ok] aia is installed (v${AIA_VERSION})"
|
|
44
51
|
|
|
45
|
-
# --- Step 2: Check that
|
|
46
|
-
|
|
47
|
-
if ! command -v ollama &> /dev/null; then
|
|
48
|
-
echo "ERROR: 'ollama' is not installed."
|
|
49
|
-
echo " Install from: https://ollama.com"
|
|
50
|
-
echo " macOS: brew install ollama"
|
|
51
|
-
exit 1
|
|
52
|
-
fi
|
|
53
|
-
|
|
54
|
-
echo "[ok] ollama is installed"
|
|
55
|
-
|
|
56
|
-
# Check if ollama is serving
|
|
57
|
-
OLLAMA_BASE="${OLLAMA_API_BASE:-http://localhost:11434}"
|
|
52
|
+
# --- Step 2: Check that OPENAI_API_KEY is set ---
|
|
58
53
|
|
|
59
|
-
if
|
|
60
|
-
echo "
|
|
61
|
-
echo "
|
|
62
|
-
echo "
|
|
54
|
+
if [ -z "${OPENAI_API_KEY:-}" ]; then
|
|
55
|
+
echo "ERROR: OPENAI_API_KEY is not set."
|
|
56
|
+
echo " Export your key before running demos:"
|
|
57
|
+
echo " export OPENAI_API_KEY=sk-..."
|
|
58
|
+
echo " Get a key at: https://platform.openai.com/api-keys"
|
|
63
59
|
exit 1
|
|
64
60
|
fi
|
|
65
61
|
|
|
66
|
-
echo "[ok]
|
|
67
|
-
|
|
68
|
-
# --- Step 3: Pull the demo model ---
|
|
69
|
-
|
|
70
|
-
echo
|
|
71
|
-
echo "Checking for model: ${DEMO_MODEL} ..."
|
|
72
|
-
|
|
73
|
-
if ollama list 2>/dev/null | grep -q "^${DEMO_MODEL}"; then
|
|
74
|
-
echo "[ok] ${DEMO_MODEL} is already available"
|
|
75
|
-
else
|
|
76
|
-
echo "Pulling ${DEMO_MODEL} (this may take a few minutes on first run) ..."
|
|
77
|
-
ollama pull "${DEMO_MODEL}"
|
|
78
|
-
echo "[ok] ${DEMO_MODEL} pulled successfully"
|
|
79
|
-
fi
|
|
62
|
+
echo "[ok] OPENAI_API_KEY is set"
|
|
80
63
|
|
|
81
|
-
# --- Step
|
|
64
|
+
# --- Step 3: Verify prompts directory ---
|
|
82
65
|
|
|
83
66
|
echo
|
|
84
67
|
if [ -d "${PROMPTS_DIR}" ]; then
|
|
@@ -88,7 +71,7 @@ else
|
|
|
88
71
|
echo "[ok] created prompts_dir at ${PROMPTS_DIR}"
|
|
89
72
|
fi
|
|
90
73
|
|
|
91
|
-
# --- Step
|
|
74
|
+
# --- Step 4: Write the config file ---
|
|
92
75
|
|
|
93
76
|
cat > "${CONFIG_FILE}" <<EOF
|
|
94
77
|
# AIA configuration for example demos
|
|
@@ -106,7 +89,7 @@ prompts:
|
|
|
106
89
|
dir: ./prompts_dir
|
|
107
90
|
|
|
108
91
|
models:
|
|
109
|
-
- name:
|
|
92
|
+
- name: ${DEMO_MODEL}
|
|
110
93
|
|
|
111
94
|
output:
|
|
112
95
|
file: ~
|
|
@@ -124,5 +107,5 @@ echo "=== Setup Complete ==="
|
|
|
124
107
|
echo
|
|
125
108
|
echo "All demo scripts use:"
|
|
126
109
|
echo " aia -c aia_config.yml ..."
|
|
127
|
-
echo " Model:
|
|
110
|
+
echo " Model: ${DEMO_MODEL}"
|
|
128
111
|
echo " Prompts dir: ${PROMPTS_DIR}"
|
data/examples/11_multi_model.sh
CHANGED
|
@@ -12,18 +12,16 @@
|
|
|
12
12
|
# synthesizes a unified response from all answers.
|
|
13
13
|
#
|
|
14
14
|
# Multiple models are specified as a comma-separated list with -m.
|
|
15
|
-
# This demo uses two
|
|
16
|
-
# available, pull a second one first:
|
|
17
|
-
# ollama pull phi4-mini
|
|
15
|
+
# This demo uses two OpenAI models (gpt-4.1 and gpt-4.1-mini).
|
|
18
16
|
#
|
|
19
|
-
# Prerequisites: Run 00_setup_aia.sh first
|
|
17
|
+
# Prerequisites: Run 00_setup_aia.sh first (OPENAI_API_KEY must be set).
|
|
20
18
|
# Usage: cd examples && bash 11_multi_model.sh
|
|
21
19
|
|
|
22
20
|
set -euo pipefail
|
|
23
21
|
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
|
|
24
22
|
|
|
25
|
-
MODEL_A="
|
|
26
|
-
MODEL_B="
|
|
23
|
+
MODEL_A="gpt-4.1"
|
|
24
|
+
MODEL_B="gpt-4.1-mini"
|
|
27
25
|
|
|
28
26
|
echo "=== Demo 11: Multiple Models ==="
|
|
29
27
|
echo
|
|
@@ -40,14 +38,6 @@ cat prompts_dir/explain_recursion.md
|
|
|
40
38
|
echo "==="
|
|
41
39
|
echo
|
|
42
40
|
|
|
43
|
-
# --- Check that the second model is available ---
|
|
44
|
-
|
|
45
|
-
if ! ollama list 2>/dev/null | grep -q "^phi4-mini"; then
|
|
46
|
-
echo "Model phi4-mini is not available. Pulling it now ..."
|
|
47
|
-
ollama pull phi4-mini
|
|
48
|
-
echo
|
|
49
|
-
fi
|
|
50
|
-
|
|
51
41
|
# --- Part 1: Comparison mode ---
|
|
52
42
|
|
|
53
43
|
echo "--- Part 1: Comparison mode (default) ---"
|
data/examples/12_token_usage.sh
CHANGED
|
@@ -5,15 +5,14 @@
|
|
|
5
5
|
# after each response. When used with multiple models this lets
|
|
6
6
|
# you compare how verbose each model is.
|
|
7
7
|
#
|
|
8
|
-
# Prerequisites: Run 00_setup_aia.sh first
|
|
9
|
-
# ollama pull phi4-mini
|
|
8
|
+
# Prerequisites: Run 00_setup_aia.sh first (OPENAI_API_KEY must be set).
|
|
10
9
|
# Usage: cd examples && bash 12_token_usage.sh
|
|
11
10
|
|
|
12
11
|
set -euo pipefail
|
|
13
12
|
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
|
|
14
13
|
|
|
15
|
-
MODEL_A="
|
|
16
|
-
MODEL_B="
|
|
14
|
+
MODEL_A="gpt-4.1"
|
|
15
|
+
MODEL_B="gpt-4.1-mini"
|
|
17
16
|
|
|
18
17
|
echo "=== Demo 12: Token Usage ==="
|
|
19
18
|
echo
|
|
@@ -28,14 +27,6 @@ cat prompts_dir/sort_compare.md
|
|
|
28
27
|
echo "==="
|
|
29
28
|
echo
|
|
30
29
|
|
|
31
|
-
# --- Check that the second model is available ---
|
|
32
|
-
|
|
33
|
-
if ! ollama list 2>/dev/null | grep -q "^phi4-mini"; then
|
|
34
|
-
echo "Model phi4-mini is not available. Pulling it now ..."
|
|
35
|
-
ollama pull phi4-mini
|
|
36
|
-
echo
|
|
37
|
-
fi
|
|
38
|
-
|
|
39
30
|
# --- Part 1: Single model with --tokens ---
|
|
40
31
|
|
|
41
32
|
echo "--- Part 1: Single model with --tokens ---"
|
data/examples/18_tools.sh
CHANGED
|
@@ -44,10 +44,18 @@ echo "==="
|
|
|
44
44
|
cat prompts_dir/use_tools.md
|
|
45
45
|
echo "==="
|
|
46
46
|
echo
|
|
47
|
-
echo "
|
|
47
|
+
echo "shared_tools ships with 35+ tools. Passing all of them in one API"
|
|
48
|
+
echo "call causes gpt-4.1 to skip tool use entirely. We use --allowed-tools"
|
|
49
|
+
echo "to expose only the three tools this prompt actually needs."
|
|
50
|
+
echo
|
|
51
|
+
echo "Running: aia -c ${CONFIG} --no-output --rq shared_tools \\"
|
|
52
|
+
echo " --allowed-tools current_date_time_tool,system_info_tool,dns_tool \\"
|
|
53
|
+
echo " use_tools"
|
|
48
54
|
echo
|
|
49
55
|
echo "The model will call tools to get live data, then summarize"
|
|
50
56
|
echo "the results."
|
|
51
57
|
echo
|
|
52
58
|
|
|
53
|
-
aia -c "${CONFIG}" --no-output --rq shared_tools
|
|
59
|
+
aia -c "${CONFIG}" --no-output --rq shared_tools \
|
|
60
|
+
--allowed-tools current_date_time_tool,system_info_tool,dns_tool \
|
|
61
|
+
use_tools
|
data/examples/22_chat_mode.sh
CHANGED
|
@@ -32,16 +32,6 @@ if ! command -v expect &>/dev/null; then
|
|
|
32
32
|
exit 1
|
|
33
33
|
fi
|
|
34
34
|
|
|
35
|
-
# Drain leaked escape sequences from the terminal input buffer.
|
|
36
|
-
# Reline queries cursor position (\e[6n) inside the pty; the
|
|
37
|
-
# terminal's responses (\e[row;colR) can leak into bash's stdin
|
|
38
|
-
# after expect exits.
|
|
39
|
-
drain_terminal() {
|
|
40
|
-
sleep 0.2
|
|
41
|
-
stty sane 2>/dev/null || true
|
|
42
|
-
while IFS= read -r -t 0.2 -n 100 _ 2>/dev/null; do :; done
|
|
43
|
-
}
|
|
44
|
-
|
|
45
35
|
echo "=== Demo 22: Chat Mode ==="
|
|
46
36
|
echo
|
|
47
37
|
echo "The --chat flag opens an interactive conversation after all"
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# examples/23_verify.sh
|
|
3
|
+
#
|
|
4
|
+
# Demonstrates /verify mode: VerificationNetwork.
|
|
5
|
+
#
|
|
6
|
+
# Two robots independently answer the same question with
|
|
7
|
+
# slightly different system prompts, then a third "reconciler"
|
|
8
|
+
# robot compares both answers, identifies agreements and
|
|
9
|
+
# disagreements, and produces a final verified answer.
|
|
10
|
+
#
|
|
11
|
+
# All three robots use the same model -- no second model needed.
|
|
12
|
+
#
|
|
13
|
+
# How it works in chat:
|
|
14
|
+
# 1. Type /verify → AIA sets verification mode for next prompt
|
|
15
|
+
# 2. Type your question → two verifiers + reconciler run
|
|
16
|
+
#
|
|
17
|
+
# Prerequisites: Run 00_setup_aia.sh first
|
|
18
|
+
# Usage: cd examples && bash 23_verify.sh
|
|
19
|
+
|
|
20
|
+
set -euo pipefail
|
|
21
|
+
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
|
|
22
|
+
|
|
23
|
+
if ! command -v expect &>/dev/null; then
|
|
24
|
+
echo "ERROR: expect is not installed."
|
|
25
|
+
echo " Install with: brew install expect"
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
echo "=== Demo 23: Verify Mode (VerificationNetwork) ==="
|
|
30
|
+
echo
|
|
31
|
+
echo "The /verify directive runs two independent robots on the same"
|
|
32
|
+
echo "question, then a third reconciler robot compares the answers"
|
|
33
|
+
echo "and produces a final verified response."
|
|
34
|
+
echo
|
|
35
|
+
echo "Directive mechanics: /verify sets the mode for the NEXT prompt."
|
|
36
|
+
echo "Type /verify, then type your question on the next line."
|
|
37
|
+
echo
|
|
38
|
+
|
|
39
|
+
# --- Part 1: Verify a factual question ---
|
|
40
|
+
|
|
41
|
+
echo "--- Part 1: Verify a factual claim ---"
|
|
42
|
+
echo
|
|
43
|
+
echo "We'll type /verify, then ask about the causes of the 2008"
|
|
44
|
+
echo "financial crisis. Two verifiers answer independently; the"
|
|
45
|
+
echo "reconciler synthesizes a final, checked response."
|
|
46
|
+
echo
|
|
47
|
+
echo "Running: aia -c ${CONFIG} --chat"
|
|
48
|
+
echo
|
|
49
|
+
|
|
50
|
+
expect <<'EXPECT_SCRIPT'
|
|
51
|
+
set timeout 300
|
|
52
|
+
log_user 1
|
|
53
|
+
|
|
54
|
+
spawn aia -c aia_config.yml --chat
|
|
55
|
+
|
|
56
|
+
expect {
|
|
57
|
+
"#=> " {}
|
|
58
|
+
timeout { puts "\n*** Timed out waiting for chat prompt ***"; exit 1 }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
send "/verify\r"
|
|
62
|
+
|
|
63
|
+
expect {
|
|
64
|
+
"#=> " {}
|
|
65
|
+
timeout { puts "\n*** Timed out waiting for directive confirmation ***"; exit 1 }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
send "What were the three main causes of the 2008 global financial crisis?\r"
|
|
69
|
+
|
|
70
|
+
expect {
|
|
71
|
+
"#=> " {}
|
|
72
|
+
timeout { puts "\n*** Timed out waiting for verification results ***"; exit 1 }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
send "exit\r"
|
|
76
|
+
expect eof
|
|
77
|
+
EXPECT_SCRIPT
|
|
78
|
+
|
|
79
|
+
drain_terminal
|
|
80
|
+
echo
|
|
81
|
+
echo
|
|
82
|
+
|
|
83
|
+
# --- Part 2: Verify a technical question ---
|
|
84
|
+
|
|
85
|
+
echo "--- Part 2: Verify a technical explanation ---"
|
|
86
|
+
echo
|
|
87
|
+
echo "Verification is especially useful for technical topics where"
|
|
88
|
+
echo "subtle errors can slip through. Two independent passes catch"
|
|
89
|
+
echo "more mistakes than one."
|
|
90
|
+
echo
|
|
91
|
+
echo "Running: aia -c ${CONFIG} --chat"
|
|
92
|
+
echo
|
|
93
|
+
|
|
94
|
+
expect <<'EXPECT_SCRIPT'
|
|
95
|
+
set timeout 300
|
|
96
|
+
log_user 1
|
|
97
|
+
|
|
98
|
+
spawn aia -c aia_config.yml --chat
|
|
99
|
+
|
|
100
|
+
expect {
|
|
101
|
+
"#=> " {}
|
|
102
|
+
timeout { puts "\n*** Timed out waiting for chat prompt ***"; exit 1 }
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
send "/verify\r"
|
|
106
|
+
|
|
107
|
+
expect {
|
|
108
|
+
"#=> " {}
|
|
109
|
+
timeout { puts "\n*** Timed out waiting for directive confirmation ***"; exit 1 }
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
send "Explain how TCP's three-way handshake works and why it guarantees reliable connection establishment.\r"
|
|
113
|
+
|
|
114
|
+
expect {
|
|
115
|
+
"#=> " {}
|
|
116
|
+
timeout { puts "\n*** Timed out waiting for verification results ***"; exit 1 }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
send "exit\r"
|
|
120
|
+
expect eof
|
|
121
|
+
EXPECT_SCRIPT
|
|
122
|
+
|
|
123
|
+
drain_terminal
|
|
124
|
+
echo
|
|
125
|
+
echo
|
|
126
|
+
|
|
127
|
+
# --- Part 3: Your turn ---
|
|
128
|
+
|
|
129
|
+
echo "--- Part 3: Your turn ---"
|
|
130
|
+
echo
|
|
131
|
+
echo "Try /verify on any factual or technical question where you"
|
|
132
|
+
echo "want cross-checked confidence rather than a single answer."
|
|
133
|
+
echo
|
|
134
|
+
|
|
135
|
+
if [[ "${BATCH_MODE:-}" == "true" ]]; then
|
|
136
|
+
echo "(Skipping interactive session in batch mode)"
|
|
137
|
+
else
|
|
138
|
+
aia -c "${CONFIG}" --chat
|
|
139
|
+
fi
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# examples/24_decompose.sh
|
|
3
|
+
#
|
|
4
|
+
# Demonstrates /decompose mode: PromptDecomposer.
|
|
5
|
+
#
|
|
6
|
+
# A coordinator robot analyzes whether a complex prompt can be
|
|
7
|
+
# split into 2-5 independent sub-tasks. If decomposable, specialist
|
|
8
|
+
# robots solve each in parallel and results are synthesized into
|
|
9
|
+
# a unified answer. Falls back to normal mode if the prompt is not
|
|
10
|
+
# decomposable.
|
|
11
|
+
#
|
|
12
|
+
# How it works in chat:
|
|
13
|
+
# 1. Type /decompose → AIA sets decomposition mode for next prompt
|
|
14
|
+
# 2. Type your complex question → coordinator splits, runs, synthesizes
|
|
15
|
+
#
|
|
16
|
+
# Prerequisites: Run 00_setup_aia.sh first
|
|
17
|
+
# Usage: cd examples && bash 24_decompose.sh
|
|
18
|
+
|
|
19
|
+
set -euo pipefail
|
|
20
|
+
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
|
|
21
|
+
|
|
22
|
+
if ! command -v expect &>/dev/null; then
|
|
23
|
+
echo "ERROR: expect is not installed."
|
|
24
|
+
echo " Install with: brew install expect"
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
echo "=== Demo 24: Decompose Mode (PromptDecomposer) ==="
|
|
29
|
+
echo
|
|
30
|
+
echo "The /decompose directive breaks a complex prompt into"
|
|
31
|
+
echo "independent sub-tasks that run in parallel, then synthesizes"
|
|
32
|
+
echo "their results into a single coherent response."
|
|
33
|
+
echo
|
|
34
|
+
echo "Directive mechanics: /decompose sets the mode for the NEXT prompt."
|
|
35
|
+
echo "Type /decompose, then type your complex multi-part question."
|
|
36
|
+
echo
|
|
37
|
+
|
|
38
|
+
# --- Part 1: Decomposable multi-part question ---
|
|
39
|
+
|
|
40
|
+
echo "--- Part 1: A complex decomposable question ---"
|
|
41
|
+
echo
|
|
42
|
+
echo "This question has several independent parts: explaining a"
|
|
43
|
+
echo "concept, listing use cases, and making a recommendation."
|
|
44
|
+
echo "The decomposer should split these and run them in parallel."
|
|
45
|
+
echo
|
|
46
|
+
echo "Running: aia -c ${CONFIG} --chat"
|
|
47
|
+
echo
|
|
48
|
+
|
|
49
|
+
expect <<'EXPECT_SCRIPT'
|
|
50
|
+
set timeout 300
|
|
51
|
+
log_user 1
|
|
52
|
+
|
|
53
|
+
spawn aia -c aia_config.yml --chat
|
|
54
|
+
|
|
55
|
+
expect {
|
|
56
|
+
"#=> " {}
|
|
57
|
+
timeout { puts "\n*** Timed out waiting for chat prompt ***"; exit 1 }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
send "/decompose\r"
|
|
61
|
+
|
|
62
|
+
expect {
|
|
63
|
+
"#=> " {}
|
|
64
|
+
timeout { puts "\n*** Timed out waiting for directive confirmation ***"; exit 1 }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
send "Explain the difference between TCP and UDP, list the top 3 use cases for each protocol, and recommend which to use for a real-time multiplayer game and explain why.\r"
|
|
68
|
+
|
|
69
|
+
expect {
|
|
70
|
+
"#=> " {}
|
|
71
|
+
timeout { puts "\n*** Timed out waiting for decomposition results ***"; exit 1 }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
send "exit\r"
|
|
75
|
+
expect eof
|
|
76
|
+
EXPECT_SCRIPT
|
|
77
|
+
|
|
78
|
+
drain_terminal
|
|
79
|
+
echo
|
|
80
|
+
echo
|
|
81
|
+
|
|
82
|
+
# --- Part 2: Non-decomposable question (fallback) ---
|
|
83
|
+
|
|
84
|
+
echo "--- Part 2: A simple question (fallback to normal mode) ---"
|
|
85
|
+
echo
|
|
86
|
+
echo "If the prompt cannot be meaningfully split, the decomposer"
|
|
87
|
+
echo "falls back to normal mode and answers directly. This shows"
|
|
88
|
+
echo "that /decompose is safe to use on any prompt."
|
|
89
|
+
echo
|
|
90
|
+
echo "Running: aia -c ${CONFIG} --chat"
|
|
91
|
+
echo
|
|
92
|
+
|
|
93
|
+
expect <<'EXPECT_SCRIPT'
|
|
94
|
+
set timeout 180
|
|
95
|
+
log_user 1
|
|
96
|
+
|
|
97
|
+
spawn aia -c aia_config.yml --chat
|
|
98
|
+
|
|
99
|
+
expect {
|
|
100
|
+
"#=> " {}
|
|
101
|
+
timeout { puts "\n*** Timed out waiting for chat prompt ***"; exit 1 }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
send "/decompose\r"
|
|
105
|
+
|
|
106
|
+
expect {
|
|
107
|
+
"#=> " {}
|
|
108
|
+
timeout { puts "\n*** Timed out waiting for directive confirmation ***"; exit 1 }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
send "What is the capital of France?\r"
|
|
112
|
+
|
|
113
|
+
expect {
|
|
114
|
+
"#=> " {}
|
|
115
|
+
timeout { puts "\n*** Timed out waiting for response ***"; exit 1 }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
send "exit\r"
|
|
119
|
+
expect eof
|
|
120
|
+
EXPECT_SCRIPT
|
|
121
|
+
|
|
122
|
+
drain_terminal
|
|
123
|
+
echo
|
|
124
|
+
echo
|
|
125
|
+
|
|
126
|
+
# --- Part 3: Your turn ---
|
|
127
|
+
|
|
128
|
+
echo "--- Part 3: Your turn ---"
|
|
129
|
+
echo
|
|
130
|
+
echo "Try /decompose on any complex, multi-part question or request."
|
|
131
|
+
echo "The decomposer works best on prompts that have 2-5 clearly"
|
|
132
|
+
echo "independent components."
|
|
133
|
+
echo
|
|
134
|
+
|
|
135
|
+
if [[ "${BATCH_MODE:-}" == "true" ]]; then
|
|
136
|
+
echo "(Skipping interactive session in batch mode)"
|
|
137
|
+
else
|
|
138
|
+
aia -c "${CONFIG}" --chat
|
|
139
|
+
fi
|