aia 2.0.0.0.pre.alpha → 2.0.0
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/CHANGELOG.md +151 -228
- data/README.md +42 -19
- data/bin/aia +8 -3
- data/lib/aia/aia_completion.bash +2 -3
- data/lib/aia/aia_completion.fish +6 -5
- data/lib/aia/aia_completion.zsh +2 -3
- data/lib/aia/chat_loop.rb +24 -66
- data/lib/aia/config/cli_parser.rb +164 -123
- data/lib/aia/config/defaults.yml +12 -39
- data/lib/aia/config/mcp_parser.rb +42 -40
- data/lib/aia/config/model_spec.rb +8 -14
- data/lib/aia/config/validator.rb +144 -156
- data/lib/aia/config/value_caster.rb +76 -0
- data/lib/aia/config.rb +72 -54
- data/lib/aia/content_extractor.rb +2 -0
- data/lib/aia/cost_calculator.rb +1 -0
- data/lib/aia/crew.rb +29 -19
- data/lib/aia/debate_handler.rb +45 -20
- data/lib/aia/delegate_handler.rb +7 -3
- data/lib/aia/directive.rb +10 -8
- data/lib/aia/directives/configuration_directives.rb +164 -109
- data/lib/aia/directives/context_directives.rb +55 -40
- data/lib/aia/directives/execution_directives.rb +25 -25
- data/lib/aia/directives/model_directives.rb +112 -195
- data/lib/aia/directives/trakflow_directives.rb +27 -9
- data/lib/aia/directives/utility_directives.rb +86 -87
- data/lib/aia/directives/web_and_file_directives.rb +83 -63
- data/lib/aia/fact_asserter.rb +3 -3
- data/lib/aia/history_transfer.rb +64 -24
- data/lib/aia/layered_orchestrator.rb +66 -43
- data/lib/aia/logger.rb +27 -62
- data/lib/aia/mcp_config_normalizer.rb +27 -14
- data/lib/aia/mcp_connection_manager.rb +193 -186
- data/lib/aia/mcp_discovery.rb +43 -15
- data/lib/aia/mcp_grouper.rb +2 -1
- data/lib/aia/mcp_server_config.rb +48 -0
- data/lib/aia/mcp_utility.rb +28 -20
- data/lib/aia/mention_router.rb +22 -52
- data/lib/aia/modality_query.rb +36 -0
- data/lib/aia/model_alias_registry.rb +11 -11
- data/lib/aia/model_registry.rb +75 -0
- data/lib/aia/network_builder.rb +17 -11
- data/lib/aia/network_memory_manager.rb +6 -6
- data/lib/aia/patches/ruby_llm_streaming_error.rb +21 -4
- data/lib/aia/patches/ruby_llm_tool_param_compat.rb +18 -0
- data/lib/aia/pipeline_orchestrator.rb +88 -45
- data/lib/aia/plugin_monitor.rb +9 -6
- data/lib/aia/prompt_decomposer.rb +6 -4
- data/lib/aia/prompt_handler.rb +90 -69
- data/lib/aia/provider_registry.rb +105 -0
- data/lib/aia/robot_builder.rb +1 -1
- data/lib/aia/robot_factory.rb +77 -69
- data/lib/aia/robot_namer.rb +2 -8
- data/lib/aia/robot_sync.rb +79 -0
- data/lib/aia/role_catalog.rb +89 -0
- data/lib/aia/session.rb +32 -14
- data/lib/aia/session_tracker.rb +39 -41
- data/lib/aia/similarity_scorer.rb +5 -3
- data/lib/aia/skill_utils.rb +60 -19
- data/lib/aia/spawn_handler.rb +16 -4
- data/lib/aia/spawn_spec_parser.rb +6 -7
- data/lib/aia/special_mode_handler.rb +80 -57
- data/lib/aia/speech.rb +103 -0
- data/lib/aia/startup_coordinator.rb +17 -91
- data/lib/aia/streaming_runner.rb +16 -5
- data/lib/aia/system_prompt_assembler.rb +20 -15
- data/lib/aia/task_board.rb +60 -0
- data/lib/aia/task_coordinator.rb +10 -5
- data/lib/aia/timing.rb +15 -0
- data/lib/aia/tool_approver.rb +205 -0
- data/lib/aia/tool_filter.rb +1 -9
- data/lib/aia/tool_filter_strategy.rb +39 -25
- data/lib/aia/tool_introspection.rb +25 -0
- data/lib/aia/tool_loader.rb +71 -31
- data/lib/aia/tool_utility.rb +6 -5
- data/lib/aia/tools/delegate_to_foreman_tool.rb +6 -4
- data/lib/aia/tools/recruit_robot_tool.rb +12 -12
- data/lib/aia/tools/reskill_robot_tool.rb +7 -7
- data/lib/aia/tools/task_board_tool.rb +17 -16
- data/lib/aia/trakflow_bridge.rb +19 -11
- data/lib/aia/turn_state.rb +32 -8
- data/lib/aia/ui_presenter.rb +83 -59
- data/lib/aia/utility.rb +8 -24
- data/lib/aia/variable_input_collector.rb +1 -3
- data/lib/aia/verification_network.rb +10 -12
- data/lib/aia.rb +49 -8
- metadata +27 -162
- data/.better-commits.json +0 -150
- data/.config/tocer/configuration.yml +0 -6
- data/.envrc +0 -15
- data/.loki +0 -231
- data/.quality/flay_baseline.txt +0 -1
- data/.quality/flog_baseline.txt +0 -29
- data/.quality/reek_baseline.txt +0 -80
- data/.rubocop.yml +0 -116
- data/COMMITS.md +0 -196
- data/IMPLEMENTATION_PLAN.md +0 -506
- data/Rakefile +0 -160
- data/architecture_review.md +0 -314
- data/docs/AGENTS.md +0 -40
- data/docs/advanced-prompting.md +0 -814
- data/docs/assets/images/aia.png +0 -0
- data/docs/cli-reference.md +0 -1241
- data/docs/configuration.md +0 -747
- data/docs/contributing.md +0 -386
- data/docs/directives-reference.md +0 -1145
- data/docs/examples/index.md +0 -277
- data/docs/examples/mcp/index.md +0 -475
- data/docs/examples/prompts/analysis/index.md +0 -78
- data/docs/examples/prompts/automation/index.md +0 -109
- data/docs/examples/prompts/development/index.md +0 -125
- data/docs/examples/prompts/index.md +0 -333
- data/docs/examples/prompts/learning/index.md +0 -127
- data/docs/examples/prompts/writing/index.md +0 -62
- data/docs/examples/tools/index.md +0 -282
- data/docs/faq.md +0 -578
- data/docs/guides/available-models.md +0 -366
- data/docs/guides/basic-usage.md +0 -478
- data/docs/guides/chat.md +0 -680
- data/docs/guides/crew.md +0 -239
- data/docs/guides/executable-prompts.md +0 -331
- data/docs/guides/first-prompt.md +0 -454
- data/docs/guides/getting-started.md +0 -455
- data/docs/guides/image-generation.md +0 -507
- data/docs/guides/index.md +0 -48
- data/docs/guides/local-models.md +0 -306
- data/docs/guides/migrate-prompts.md +0 -335
- data/docs/guides/models.md +0 -1017
- data/docs/guides/shared-tools.md +0 -254
- data/docs/guides/tools.md +0 -831
- data/docs/index.md +0 -259
- data/docs/installation.md +0 -274
- data/docs/mcp-integration.md +0 -603
- data/docs/prompt_management.md +0 -665
- data/docs/security.md +0 -674
- data/docs/special_projects_guide.md +0 -386
- data/docs/tools-and-mcp-examples.md +0 -1211
- data/docs/workflows-and-pipelines.md +0 -636
- data/examples/.gitignore +0 -2
- data/examples/00_setup_aia.sh +0 -111
- data/examples/01_basic_usage.sh +0 -23
- data/examples/02_frontmatter.sh +0 -33
- data/examples/03_shell_integration.sh +0 -55
- data/examples/04_erb_templating.sh +0 -56
- data/examples/05_shell_then_erb.sh +0 -38
- data/examples/06_prompt_chaining.sh +0 -59
- data/examples/07_pipeline.sh +0 -46
- data/examples/08_context_files.sh +0 -43
- data/examples/09_roles.sh +0 -67
- data/examples/10_stdin_piping.sh +0 -49
- data/examples/11_multi_model.sh +0 -65
- data/examples/12_token_usage.sh +0 -52
- data/examples/13_cost_tracking.sh +0 -68
- data/examples/14_output_file.sh +0 -91
- data/examples/15_parameters.sh +0 -68
- data/examples/16_directives.sh +0 -113
- data/examples/17_require_and_conditionals.sh +0 -68
- data/examples/18_tools.sh +0 -61
- data/examples/19_local_tools.sh +0 -34
- data/examples/20_mcp_servers.sh +0 -102
- data/examples/21_executable_prompts.sh +0 -78
- data/examples/22_chat_mode.sh +0 -217
- data/examples/23_verify.sh +0 -139
- data/examples/24_decompose.sh +0 -139
- data/examples/25_spawn.sh +0 -139
- data/examples/26_debate.sh +0 -97
- data/examples/27_mention_routing.sh +0 -157
- data/examples/28_model_switching.sh +0 -106
- data/examples/29_agent_harness.sh +0 -177
- data/examples/README.md +0 -321
- data/examples/advanced_multi_robot_capabilities_without_examples.md +0 -106
- data/examples/aia_config.yml +0 -22
- data/examples/aia_config_orchestrator.yml +0 -45
- data/examples/aia_config_with_mcp.yml +0 -21
- data/examples/common.sh +0 -39
- data/examples/context/project_goals.md +0 -6
- data/examples/context/tech_stack.md +0 -7
- data/examples/directives/timestamp_directive.rb +0 -22
- data/examples/mcp/filesystem.json +0 -9
- data/examples/prompts_dir/analyze.md +0 -2
- data/examples/prompts_dir/brainstorm.md +0 -2
- data/examples/prompts_dir/conditional.md +0 -17
- data/examples/prompts_dir/creative.md +0 -4
- data/examples/prompts_dir/erbinfo.md +0 -5
- data/examples/prompts_dir/erbinfo_raw.md +0 -8
- data/examples/prompts_dir/evaluate.md +0 -2
- data/examples/prompts_dir/explain_joke.md +0 -1
- data/examples/prompts_dir/explain_recursion.md +0 -1
- data/examples/prompts_dir/fun_fact +0 -3
- data/examples/prompts_dir/greeting.md +0 -8
- data/examples/prompts_dir/greeting_required.md +0 -7
- data/examples/prompts_dir/hello.md +0 -1
- data/examples/prompts_dir/includes/ruby_facts.md +0 -4
- data/examples/prompts_dir/limerick.md +0 -1
- data/examples/prompts_dir/list_with_mcp.md +0 -3
- data/examples/prompts_dir/pick_best.md +0 -2
- data/examples/prompts_dir/project_summary +0 -12
- data/examples/prompts_dir/quiz_with_include.md +0 -6
- data/examples/prompts_dir/require_demo.md +0 -5
- data/examples/prompts_dir/roles/formal.md +0 -3
- data/examples/prompts_dir/roles/orchestrator.md +0 -21
- data/examples/prompts_dir/roles/pirate.md +0 -3
- data/examples/prompts_dir/shell_then_erb.md +0 -6
- data/examples/prompts_dir/sort_compare.md +0 -2
- data/examples/prompts_dir/summarize_context.md +0 -2
- data/examples/prompts_dir/sysinfo.md +0 -5
- data/examples/prompts_dir/sysinfo_raw.md +0 -8
- data/examples/prompts_dir/tagline.md +0 -1
- data/examples/prompts_dir/tell_joke.md +0 -1
- data/examples/prompts_dir/tell_joke_with_next.md +0 -4
- data/examples/prompts_dir/use_local_tool.md +0 -8
- data/examples/prompts_dir/use_tools.md +0 -8
- data/examples/prompts_dir/weather.md +0 -2
- data/examples/prompts_dir/whats_new.md +0 -2
- data/examples/prompts_dir/with_timestamp.md +0 -5
- data/examples/requirements/sinatra_taskflow_app.md +0 -139
- data/examples/rules/01_classify_ruby.rb +0 -16
- data/examples/rules/02_prefer_claude_for_code.rb +0 -19
- data/examples/rules/03_gate_prompt_length.rb +0 -19
- data/examples/rules/04_tool_selection.rb +0 -41
- data/examples/rules/README.md +0 -30
- data/examples/run_all.sh +0 -294
- data/examples/tools/word_count_tool.rb +0 -30
- data/lib/AGENTS.md +0 -57
- data/lib/aia/model_switch_handler.rb +0 -100
- data/mcp_servers/README.md +0 -110
- data/mcp_servers/apple-mcp.json +0 -8
- data/mcp_servers/filesystem.json +0 -9
- data/mcp_servers/mcp_server_chart.json +0 -11
- data/mcp_servers/playwright_one.json +0 -8
- data/mcp_servers/playwright_server_definition.json +0 -9
- data/mcp_servers/playwright_two.json +0 -8
- data/mcp_servers/tavily_mcp_server.json +0 -8
- data/mkdocs.yml +0 -169
data/lib/aia/robot_factory.rb
CHANGED
|
@@ -14,6 +14,7 @@ require_relative 'network_builder'
|
|
|
14
14
|
require_relative 'history_transfer'
|
|
15
15
|
|
|
16
16
|
module AIA
|
|
17
|
+
# :reek:TooManyMethods -- factory facade: every robot/network build variant plus its run-config helpers lives behind one entry point
|
|
17
18
|
class RobotFactory
|
|
18
19
|
# The max_tokens default from defaults.yml — optimised for cloud APIs that treat
|
|
19
20
|
# it as an output-only cap. Local providers (Ollama, LM Studio) bound input+output
|
|
@@ -73,24 +74,6 @@ module AIA
|
|
|
73
74
|
new_robot
|
|
74
75
|
end
|
|
75
76
|
|
|
76
|
-
# --- Forwarding wrappers for backward compatibility ---
|
|
77
|
-
|
|
78
|
-
def clear_tool_cache!
|
|
79
|
-
ToolLoader.clear_cache!
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def filtered_tools(config)
|
|
83
|
-
ToolLoader.filtered_tools(config)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def resolve_system_prompt(config, model_spec = nil)
|
|
87
|
-
SystemPromptAssembler.resolve_system_prompt(config, model_spec)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def build_identity_prompt(robot_name, spec, roster)
|
|
91
|
-
SystemPromptAssembler.build_identity_prompt(robot_name, spec, roster)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
77
|
# Build a concurrent MCP network where independent server groups
|
|
95
78
|
# run in parallel with a synthesizer to merge results.
|
|
96
79
|
#
|
|
@@ -114,9 +97,10 @@ module AIA
|
|
|
114
97
|
|
|
115
98
|
# Reuse the build-time tool cache when present, else load tools fresh.
|
|
116
99
|
def apply_tool_cache(config)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
config.
|
|
100
|
+
cached = ToolLoader.cached_tools
|
|
101
|
+
if cached
|
|
102
|
+
config.loaded_tools = cached
|
|
103
|
+
config.tool_names = cached.map { |t| ToolIntrospection.tool_name(t) }.join(', ')
|
|
120
104
|
else
|
|
121
105
|
ToolLoader.load_tools(config)
|
|
122
106
|
end
|
|
@@ -142,13 +126,28 @@ module AIA
|
|
|
142
126
|
# the RubyLLM/OpenAI provider boundary for models that need
|
|
143
127
|
# max_completion_tokens
|
|
144
128
|
def build_run_config(config)
|
|
129
|
+
params = llm_params(config)
|
|
130
|
+
params.merge!(ToolApprover.options(config))
|
|
131
|
+
|
|
132
|
+
RobotLab::RunConfig.new(**params)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# The LLM tuning parameters (temperature, max_tokens, top_p, penalties)
|
|
136
|
+
# for the current config, with unsupported or default-only values left out.
|
|
137
|
+
# Shared by build_run_config and RobotSync, which retunes a running robot.
|
|
138
|
+
#
|
|
139
|
+
# @param config [AIA::Config]
|
|
140
|
+
# @return [Hash{Symbol => Numeric}]
|
|
141
|
+
# :reek:TooManyStatements -- one guarded param per LLM tuning knob, with provider-specific max_tokens handling
|
|
142
|
+
def llm_params(config)
|
|
145
143
|
model_spec = config.models.first
|
|
144
|
+
llm = config.llm
|
|
146
145
|
params = {}
|
|
147
146
|
|
|
148
|
-
temp =
|
|
147
|
+
temp = llm.temperature
|
|
149
148
|
params[:temperature] = temp if temp && model_supports_temperature?(model_spec)
|
|
150
149
|
|
|
151
|
-
max =
|
|
150
|
+
max = llm.max_tokens
|
|
152
151
|
# Local providers (Ollama, LM Studio) have a small total context window
|
|
153
152
|
# (input + output combined, typically 32768 tokens for qwen3-class models).
|
|
154
153
|
# Sending the cloud default of 32767 as num_predict leaves almost no room
|
|
@@ -158,16 +157,16 @@ module AIA
|
|
|
158
157
|
local = model_spec&.local_provider?
|
|
159
158
|
params[:max_tokens] = max if max && !(local && max == DEFAULT_LOCAL_MAX_TOKENS)
|
|
160
159
|
|
|
161
|
-
tp =
|
|
160
|
+
tp = llm.top_p
|
|
162
161
|
params[:top_p] = tp if tp
|
|
163
162
|
|
|
164
|
-
fp =
|
|
163
|
+
fp = llm.frequency_penalty
|
|
165
164
|
params[:frequency_penalty] = fp if fp && fp != 0.0
|
|
166
165
|
|
|
167
|
-
pp =
|
|
166
|
+
pp = llm.presence_penalty
|
|
168
167
|
params[:presence_penalty] = pp if pp && pp != 0.0
|
|
169
168
|
|
|
170
|
-
|
|
169
|
+
params
|
|
171
170
|
end
|
|
172
171
|
|
|
173
172
|
# Returns false for models that explicitly declare temperature: false in the
|
|
@@ -180,17 +179,26 @@ module AIA
|
|
|
180
179
|
true
|
|
181
180
|
end
|
|
182
181
|
|
|
183
|
-
#
|
|
184
|
-
#
|
|
185
|
-
|
|
182
|
+
# The MCP servers to hand a robot as RobotLab.build(mcp:).
|
|
183
|
+
#
|
|
184
|
+
# Once MCPConnectionManager.start has run, these are the live
|
|
185
|
+
# RubyLLM::MCP instances it connected, shared by every robot so each
|
|
186
|
+
# server is started once; servers that failed to connect are left out.
|
|
187
|
+
# Before that (or without a manager) they are normalized config Hashes,
|
|
188
|
+
# which robot_lab connects lazily on the robot's first run.
|
|
189
|
+
#
|
|
190
|
+
# @param config [AIA::Config]
|
|
191
|
+
# @param group [Array<Hash>, nil] a subset of server configs (concurrent MCP
|
|
192
|
+
# networks); defaults to MCPDiscovery's selection (--mcp-use/--mcp-skip)
|
|
193
|
+
# @return [Array<RubyLLM::MCP, Hash>]
|
|
194
|
+
def mcp_servers(config, group = nil)
|
|
186
195
|
return [] if config.flags.no_mcp
|
|
187
|
-
Array(config.mcp_servers).map { |s| MCPConfigNormalizer.normalize(s) }
|
|
188
|
-
end
|
|
189
196
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
configs = group || MCPDiscovery.new.discover(config)
|
|
198
|
+
manager = AIA.mcp_manager
|
|
199
|
+
return manager.servers_for(configs) if manager&.connected?
|
|
200
|
+
|
|
201
|
+
configs.map { |s| MCPConfigNormalizer.normalize(s) }
|
|
194
202
|
end
|
|
195
203
|
|
|
196
204
|
# Initialize shared memory for a network with session context.
|
|
@@ -226,24 +234,39 @@ module AIA
|
|
|
226
234
|
|
|
227
235
|
# Build a RobotLab::Robot for a model spec, applying provider resolution.
|
|
228
236
|
# Centralizes the "set provider if the spec has one, then build" tail that
|
|
229
|
-
# every robot/network builder needs, so
|
|
230
|
-
#
|
|
237
|
+
# every robot/network builder needs, so provider routing can't be
|
|
238
|
+
# forgotten at a new build site.
|
|
231
239
|
#
|
|
232
240
|
# @param spec [AIA::Config::ModelSpec] the model spec (supplies model: and provider)
|
|
233
241
|
# @param opts [Hash] forwarded to RobotLab.build (name:, system_prompt:,
|
|
234
|
-
# local_tools:,
|
|
242
|
+
# local_tools:, mcp:, config:, on_content:, ...). Do NOT pass model:.
|
|
235
243
|
# @return [RobotLab::Robot]
|
|
236
244
|
def build_robot(spec, **opts)
|
|
237
245
|
opts[:provider] = resolve_provider(spec) if spec.provider
|
|
238
246
|
RobotLab.build(model: spec.name, **opts)
|
|
239
247
|
end
|
|
240
248
|
|
|
241
|
-
#
|
|
249
|
+
# Resolve a spec's provider to a RubyLLM provider slug. Slugs pass
|
|
250
|
+
# through unchanged — RubyLLM's registry is the single source of truth —
|
|
251
|
+
# but the method stays as the seam where optional provider gems get
|
|
252
|
+
# loaded on demand and where a future alias mapping would live.
|
|
242
253
|
def resolve_provider(model_spec)
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
254
|
+
provider = model_spec.provider
|
|
255
|
+
ensure_provider_loaded(provider)
|
|
256
|
+
provider
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# Make sure a provider slug is registered with RubyLLM, loading its
|
|
260
|
+
# conventional gem on demand. An unknown provider only warns here —
|
|
261
|
+
# RubyLLM raises its own clear error later when the slug is truly
|
|
262
|
+
# unresolvable.
|
|
263
|
+
def ensure_provider_loaded(provider)
|
|
264
|
+
return if provider.nil? || ProviderRegistry.available?(provider)
|
|
265
|
+
|
|
266
|
+
AIA.debug_warn(
|
|
267
|
+
"provider '#{provider}' is not registered with RubyLLM and no " \
|
|
268
|
+
"ruby_llm/providers/#{provider} library could be loaded"
|
|
269
|
+
)
|
|
247
270
|
end
|
|
248
271
|
|
|
249
272
|
private
|
|
@@ -252,7 +275,6 @@ module AIA
|
|
|
252
275
|
def configure_robot_lab(config)
|
|
253
276
|
# Configure loggers before any API calls
|
|
254
277
|
AIA::LoggerManager.configure_llm_logger
|
|
255
|
-
AIA::LoggerManager.configure_mcp_logger
|
|
256
278
|
|
|
257
279
|
# Route RobotLab's internal logging through AIA's MCP logger
|
|
258
280
|
# so entries go to the configured log files instead of STDOUT.
|
|
@@ -272,6 +294,9 @@ module AIA
|
|
|
272
294
|
# Configure local provider API endpoints from environment variables
|
|
273
295
|
configure_local_providers(config)
|
|
274
296
|
|
|
297
|
+
# Use AIA's models.json, refreshing it every registry.refresh days
|
|
298
|
+
ModelRegistry.prepare(config)
|
|
299
|
+
|
|
275
300
|
# Wire audio model settings into RubyLLM config
|
|
276
301
|
configure_audio(config)
|
|
277
302
|
end
|
|
@@ -287,31 +312,14 @@ module AIA
|
|
|
287
312
|
RubyLLM.configure { |c| c.default_transcription_model = transcription_model }
|
|
288
313
|
end
|
|
289
314
|
|
|
290
|
-
#
|
|
291
|
-
#
|
|
315
|
+
# Make every provider named by the configured models available, then
|
|
316
|
+
# apply generic env-var endpoint overrides: <SLUG>_API_BASE sets
|
|
317
|
+
# RubyLLM.config.<slug>_api_base for every registered provider that
|
|
318
|
+
# defines the option. Providers ship their own endpoint defaults, so
|
|
319
|
+
# nothing is set unless the user overrides it.
|
|
292
320
|
def configure_local_providers(config)
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
RubyLLM.configure do |c|
|
|
296
|
-
# Always configure Ollama's base so switching to an `ollama/` model
|
|
297
|
-
# mid-session works even when the session started on a cloud model.
|
|
298
|
-
# It only affects the Ollama provider, so it's harmless when unused.
|
|
299
|
-
# RubyLLM's Ollama provider subclasses OpenAI and appends
|
|
300
|
-
# `chat/completions`, so the base must include the `/v1` suffix.
|
|
301
|
-
c.ollama_api_base = ENV.fetch('OLLAMA_API_BASE', 'http://localhost:11434/v1')
|
|
302
|
-
|
|
303
|
-
# LM Studio exposes an OpenAI-compatible API and reuses the OpenAI
|
|
304
|
-
# provider, so only override the OpenAI base when an `lms/` model is
|
|
305
|
-
# actually in use — otherwise it would hijack real OpenAI requests.
|
|
306
|
-
# The OpenAI provider POSTs the relative `chat/completions`, so (like
|
|
307
|
-
# the real `https://api.openai.com/v1` default and the Ollama base) the
|
|
308
|
-
# LM Studio base must include the `/v1` suffix — otherwise requests hit
|
|
309
|
-
# `:1234/chat/completions`, LM Studio 404s, and ruby_llm's streaming
|
|
310
|
-
# error handler masks it as `delete_prefix for nil`.
|
|
311
|
-
if providers_used.include?('lms')
|
|
312
|
-
c.openai_api_base = ENV.fetch('LMS_API_BASE', 'http://localhost:1234/v1')
|
|
313
|
-
end
|
|
314
|
-
end
|
|
321
|
+
config.models.map(&:provider).compact.uniq.each { |provider| ensure_provider_loaded(provider) }
|
|
322
|
+
ProviderRegistry.apply_env_endpoints
|
|
315
323
|
end
|
|
316
324
|
|
|
317
325
|
# Decide between consensus and parallel multi-model.
|
data/lib/aia/robot_namer.rb
CHANGED
|
@@ -103,14 +103,8 @@ module AIA
|
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
def unique_name(base)
|
|
106
|
-
@used_names[base]
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if @used_names[base] == 1
|
|
110
|
-
base
|
|
111
|
-
else
|
|
112
|
-
"#{base}#{@used_names[base]}"
|
|
113
|
-
end
|
|
106
|
+
count = @used_names[base] = (@used_names[base] || 0) + 1
|
|
107
|
+
count == 1 ? base : "#{base}#{count}"
|
|
114
108
|
end
|
|
115
109
|
end
|
|
116
110
|
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# lib/aia/robot_sync.rb
|
|
4
|
+
#
|
|
5
|
+
# The robot (or crew) is built once from the configuration at startup, but a
|
|
6
|
+
# prompt's front matter (model:, temperature:, top_p:, config: llm: ...) and
|
|
7
|
+
# chat directives (/temperature, /top_p, /config llm.*) change the
|
|
8
|
+
# configuration later. RobotSync runs before each prompt and chat turn and
|
|
9
|
+
# brings the running client in line with the configuration:
|
|
10
|
+
#
|
|
11
|
+
# * the model list changed -> rebuild the client (as /model does), carrying
|
|
12
|
+
# the conversation over per model_switch_history
|
|
13
|
+
# * only LLM settings changed -> retune every robot in place, keeping history
|
|
14
|
+
#
|
|
15
|
+
# A client replaced elsewhere (e.g. by /model) becomes the new baseline.
|
|
16
|
+
|
|
17
|
+
module AIA
|
|
18
|
+
class RobotSync
|
|
19
|
+
# @param config [AIA::Config] the live configuration
|
|
20
|
+
# @param client [RobotLab::Robot, RobotLab::Network, nil] the client as built
|
|
21
|
+
# @param factory [#rebuild, #llm_params] builds and parameterizes clients
|
|
22
|
+
def initialize(config, client, factory: RobotFactory)
|
|
23
|
+
@config = config
|
|
24
|
+
@factory = factory
|
|
25
|
+
record(client)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @param client [RobotLab::Robot, RobotLab::Network] the current client
|
|
29
|
+
# @return [RobotLab::Robot, RobotLab::Network] the client to use from now on
|
|
30
|
+
def call(client)
|
|
31
|
+
return record(client) unless client.equal?(@client)
|
|
32
|
+
|
|
33
|
+
if model_signature != @models
|
|
34
|
+
rebuild
|
|
35
|
+
elsif @factory.llm_params(@config) != @params
|
|
36
|
+
retune(client)
|
|
37
|
+
else
|
|
38
|
+
client
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# The models (name, role) the client should be running.
|
|
43
|
+
def model_signature
|
|
44
|
+
Array(@config.models).map { [it.name, it.role] }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Robot#update keywords for +params+ (from RobotFactory.llm_params).
|
|
48
|
+
# top_p and the penalties go to the provider as request options; they are
|
|
49
|
+
# always sent (possibly empty) so a value that was cleared is dropped.
|
|
50
|
+
def self.update_options(params)
|
|
51
|
+
options = {}
|
|
52
|
+
options[:temperature] = params[:temperature] if params.key?(:temperature)
|
|
53
|
+
options[:max_output_tokens] = params[:max_tokens] if params.key?(:max_tokens)
|
|
54
|
+
options[:provider_options] = params.slice(:top_p, :frequency_penalty, :presence_penalty)
|
|
55
|
+
options
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
def rebuild
|
|
61
|
+
client = @factory.rebuild(@config, history_mode: HistoryTransfer.mode_for(@config))
|
|
62
|
+
AIA.client = client
|
|
63
|
+
record(client)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def retune(client)
|
|
67
|
+
options = self.class.update_options(@factory.llm_params(@config))
|
|
68
|
+
HistoryTransfer.recipients(client).each { |robot| robot.update(**options) if robot.respond_to?(:update) }
|
|
69
|
+
record(client)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def record(client)
|
|
73
|
+
@client = client
|
|
74
|
+
@models = model_signature
|
|
75
|
+
@params = @factory.llm_params(@config)
|
|
76
|
+
client
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# lib/aia/role_catalog.rb
|
|
4
|
+
#
|
|
5
|
+
# Finding, checking and listing role files. Every function takes the prompts
|
|
6
|
+
# directory and roles prefix explicitly, so callers pass the configured
|
|
7
|
+
# values (--prompts-dir, the config file, AIA_PROMPTS__DIR) rather than
|
|
8
|
+
# guessing them.
|
|
9
|
+
|
|
10
|
+
require_relative 'skill_utils'
|
|
11
|
+
require_relative 'errors'
|
|
12
|
+
|
|
13
|
+
module AIA
|
|
14
|
+
# :reek:DataClump -- pure functions over (dir, prefix, extname) on purpose: callers pass the configured values explicitly (see above)
|
|
15
|
+
module RoleCatalog
|
|
16
|
+
module_function
|
|
17
|
+
|
|
18
|
+
# A role ID with the roles prefix added ("editor" -> "roles/editor").
|
|
19
|
+
# Path-based IDs and IDs that already carry the prefix are unchanged.
|
|
20
|
+
def qualified_id(role_id, prefix)
|
|
21
|
+
id = role_id.to_s
|
|
22
|
+
return id if SkillUtils.path_based_id?(id) || prefix.to_s.empty? || id.start_with?("#{prefix}/")
|
|
23
|
+
|
|
24
|
+
"#{prefix}/#{id}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# The file a role ID names.
|
|
28
|
+
def role_file(role_id, dir:, prefix:, extname: '.md')
|
|
29
|
+
SkillUtils.prompt_file_path(qualified_id(role_id, prefix), dir: dir, extname: extname)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Role IDs (without the prefix) under <dir>/<prefix>. Files and folders
|
|
33
|
+
# starting with "_" are private and not listed.
|
|
34
|
+
def names(dir, prefix, extname: '.md')
|
|
35
|
+
roles_dir = File.join(dir.to_s, prefix.to_s)
|
|
36
|
+
return [] unless Dir.exist?(roles_dir)
|
|
37
|
+
|
|
38
|
+
Dir.glob("**/*#{extname}", base: roles_dir)
|
|
39
|
+
.map { it.delete_suffix(extname) }
|
|
40
|
+
.reject { |f| f.split('/').any? { it.start_with?('_') } }
|
|
41
|
+
.sort
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Raise AIA::ConfigurationError unless the role's file exists.
|
|
45
|
+
def validate!(role_id, dir:, prefix:, extname: '.md')
|
|
46
|
+
file = role_file(role_id, dir: dir, prefix: prefix, extname: extname)
|
|
47
|
+
return if File.exist?(file)
|
|
48
|
+
|
|
49
|
+
message = if SkillUtils.path_based_id?(role_id)
|
|
50
|
+
"Role file not found: #{file}"
|
|
51
|
+
else
|
|
52
|
+
not_found_message(file, dir, prefix, extname)
|
|
53
|
+
end
|
|
54
|
+
raise AIA::ConfigurationError, message
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def not_found_message(file, dir, prefix, extname = '.md')
|
|
58
|
+
available = names(dir, prefix, extname: extname)
|
|
59
|
+
message = "Role file not found: #{file}\n\n"
|
|
60
|
+
|
|
61
|
+
if available.empty?
|
|
62
|
+
message + "No roles directory found at #{File.join(dir.to_s, prefix.to_s)}\n" \
|
|
63
|
+
"Create the directory and add role files to use this feature."
|
|
64
|
+
else
|
|
65
|
+
message + "Available roles:\n" + available.map { " - #{it}" }.join("\n") +
|
|
66
|
+
"\n\nCreate the role file or use an existing role."
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# The --list-roles report: a heading and front-matter table per role.
|
|
71
|
+
def listing(dir, prefix, extname: '.md')
|
|
72
|
+
roles_dir = File.join(dir.to_s, prefix.to_s)
|
|
73
|
+
unless Dir.exist?(roles_dir)
|
|
74
|
+
return "No roles directory found at #{roles_dir}\nCreate this directory and add role files to use roles."
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
roles = names(dir, prefix, extname: extname)
|
|
78
|
+
return "No role files found in #{roles_dir}\nCreate #{extname} files in this directory to define roles." if roles.empty?
|
|
79
|
+
|
|
80
|
+
roles.flat_map { listing_entry(roles_dir, it, extname) }.join("\n")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def listing_entry(roles_dir, role_id, extname)
|
|
84
|
+
front_matter = SkillUtils.parse_front_matter(File.join(roles_dir, "#{role_id}#{extname}"))
|
|
85
|
+
rows = front_matter.map { |key, value| "| #{key} | #{value.to_s.gsub('|', '\\|')} |" }
|
|
86
|
+
["## #{role_id}", '', '| Key | Value |', '|-----|-------|', *rows, '']
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
data/lib/aia/session.rb
CHANGED
|
@@ -11,6 +11,10 @@ require "reline"
|
|
|
11
11
|
require "pm"
|
|
12
12
|
require "json"
|
|
13
13
|
require "fileutils"
|
|
14
|
+
# amazing_print 3.0's ActiveSupport extension assumes a fully loaded
|
|
15
|
+
# ActiveSupport (Object#try, LogSubscriber) and raises at require time otherwise
|
|
16
|
+
require "active_support"
|
|
17
|
+
require "active_support/core_ext/object/try"
|
|
14
18
|
require "amazing_print"
|
|
15
19
|
require_relative "directive_processor"
|
|
16
20
|
require_relative "variable_input_collector"
|
|
@@ -23,6 +27,7 @@ require_relative "tool_filter_registry"
|
|
|
23
27
|
require_relative "chat_loop"
|
|
24
28
|
|
|
25
29
|
module AIA
|
|
30
|
+
# :reek:TooManyInstanceVariables -- session hub wires presenter, trackers, handlers, and robot; each collaborator is a named field
|
|
26
31
|
class Session
|
|
27
32
|
include ContentExtractor
|
|
28
33
|
|
|
@@ -35,16 +40,30 @@ module AIA
|
|
|
35
40
|
|
|
36
41
|
# Starts the session, processing all prompts in the pipeline and then
|
|
37
42
|
# optionally starting an interactive chat session.
|
|
43
|
+
# :reek:TooManyStatements -- session boot script: build robot, startup coordination, optional immediate chat, pipeline run, chat handoff
|
|
38
44
|
def start
|
|
45
|
+
cfg = AIA.config
|
|
46
|
+
|
|
47
|
+
# --require libraries first, so mcp_servers: entries can name the
|
|
48
|
+
# RubyLLM::MCP subclasses they define (e.g. SharedTools::MCP::Memory).
|
|
49
|
+
ToolLoader.require_libs(cfg)
|
|
50
|
+
|
|
51
|
+
# Connect MCP servers next: every robot built from here on is handed
|
|
52
|
+
# the same live server instances (see RobotFactory.mcp_servers).
|
|
53
|
+
@mcp_manager = MCPConnectionManager.start(cfg)
|
|
54
|
+
|
|
55
|
+
coordinator = StartupCoordinator.new(robot: nil, ui_presenter: @ui_presenter, mcp_manager: @mcp_manager)
|
|
56
|
+
coordinator.prepare_task_board
|
|
57
|
+
|
|
39
58
|
# Build robot or network
|
|
40
|
-
@robot = RobotFactory.build(
|
|
59
|
+
@robot = RobotFactory.build(cfg)
|
|
41
60
|
AIA.client = @robot
|
|
61
|
+
@robot_sync = RobotSync.new(cfg, @robot)
|
|
42
62
|
|
|
43
|
-
# Run
|
|
44
|
-
coordinator =
|
|
45
|
-
coordinator.run(
|
|
46
|
-
@filters
|
|
47
|
-
@mcp_manager = coordinator.mcp_manager
|
|
63
|
+
# Run the remaining startup coordination: tool filters, bus
|
|
64
|
+
coordinator.robot = @robot
|
|
65
|
+
coordinator.run(cfg)
|
|
66
|
+
@filters = coordinator.filters
|
|
48
67
|
|
|
49
68
|
# Store session tracker globally for KBS access
|
|
50
69
|
AIA.session_tracker = @session_tracker
|
|
@@ -62,8 +81,9 @@ module AIA
|
|
|
62
81
|
prompt_handler: @prompt_handler,
|
|
63
82
|
input_collector: @input_collector,
|
|
64
83
|
ui_presenter: @ui_presenter,
|
|
65
|
-
session_tracker: @session_tracker
|
|
66
|
-
|
|
84
|
+
session_tracker: @session_tracker,
|
|
85
|
+
robot_sync: @robot_sync
|
|
86
|
+
).process(cfg)
|
|
67
87
|
|
|
68
88
|
# Start chat mode after all prompts are processed
|
|
69
89
|
return unless AIA.chat?
|
|
@@ -91,9 +111,6 @@ module AIA
|
|
|
91
111
|
@input_collector = InputCollector.new
|
|
92
112
|
|
|
93
113
|
@session_tracker = SessionTracker.new
|
|
94
|
-
@alias_registry = ModelAliasRegistry.new(
|
|
95
|
-
AIA.config.respond_to?(:model_aliases) ? (AIA.config.model_aliases || {}) : {}
|
|
96
|
-
)
|
|
97
114
|
@chat_loop = nil # created after robot is built
|
|
98
115
|
|
|
99
116
|
rotate_history_log_if_needed
|
|
@@ -121,11 +138,12 @@ module AIA
|
|
|
121
138
|
end
|
|
122
139
|
|
|
123
140
|
def build_chat_loop
|
|
141
|
+
# A pipeline step may have rebuilt the client (front-matter model:)
|
|
124
142
|
ChatLoop.new(
|
|
125
|
-
@robot, @ui_presenter, @directive_processor,
|
|
143
|
+
AIA.client || @robot, @ui_presenter, @directive_processor,
|
|
126
144
|
session_tracker: @session_tracker,
|
|
127
|
-
|
|
128
|
-
|
|
145
|
+
filters: @filters,
|
|
146
|
+
robot_sync: @robot_sync
|
|
129
147
|
)
|
|
130
148
|
end
|
|
131
149
|
|
data/lib/aia/session_tracker.rb
CHANGED
|
@@ -97,61 +97,26 @@ module AIA
|
|
|
97
97
|
|
|
98
98
|
# Expand a network SimpleFlow::Result into one turn entry per robot.
|
|
99
99
|
# Computes TF-IDF similarity of each response against the first.
|
|
100
|
-
#
|
|
100
|
+
# :reek:TooManyStatements -- collect entries and texts in one pass, then score and accumulate; splitting hides the pairing
|
|
101
101
|
def record_network_turn(input:, flow_result:, decisions: nil, elapsed: nil)
|
|
102
102
|
@turn_count += 1
|
|
103
103
|
now = Time.now
|
|
104
104
|
|
|
105
105
|
# Collect robot data in order for similarity scoring
|
|
106
|
-
robot_entries
|
|
106
|
+
robot_entries = []
|
|
107
107
|
response_texts = []
|
|
108
108
|
|
|
109
|
-
# rubocop:disable Metrics/BlockLength
|
|
110
109
|
flow_result.context.each do |task_name, robot_result|
|
|
111
110
|
next if task_name == :run_params
|
|
112
111
|
next unless robot_result.respond_to?(:raw)
|
|
113
112
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
tokens = input_tokens + output_tokens
|
|
118
|
-
|
|
119
|
-
model_id = extract_model_id_from_raw(raw)
|
|
120
|
-
model_id ||= robot_result.respond_to?(:robot_name) ? robot_result.robot_name : task_name.to_s
|
|
121
|
-
|
|
122
|
-
cost = tokens.positive? ? compute_cost_for_model(model_id, input_tokens, output_tokens) : 0.0
|
|
123
|
-
robot_elapsed = robot_result.respond_to?(:duration) ? (robot_result.duration || 0) : 0
|
|
124
|
-
|
|
125
|
-
text = if robot_result.respond_to?(:reply)
|
|
126
|
-
robot_result.reply.to_s
|
|
127
|
-
elsif robot_result.respond_to?(:content)
|
|
128
|
-
robot_result.content.to_s
|
|
129
|
-
else
|
|
130
|
-
""
|
|
131
|
-
end
|
|
132
|
-
# rubocop:enable Metrics/BlockLength
|
|
133
|
-
response_texts << text
|
|
134
|
-
|
|
135
|
-
robot_entries << {
|
|
136
|
-
model: model_id,
|
|
137
|
-
input_length: input.to_s.length,
|
|
138
|
-
input_tokens: input_tokens,
|
|
139
|
-
output_tokens: output_tokens,
|
|
140
|
-
tokens: tokens,
|
|
141
|
-
cost: cost,
|
|
142
|
-
elapsed: robot_elapsed,
|
|
143
|
-
decisions: decisions&.to_h,
|
|
144
|
-
timestamp: now
|
|
145
|
-
}
|
|
113
|
+
response_texts << extract_response_text(robot_result)
|
|
114
|
+
robot_entries << network_robot_entry(task_name, robot_result,
|
|
115
|
+
input: input, decisions: decisions, now: now)
|
|
146
116
|
end
|
|
147
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
148
117
|
|
|
149
118
|
# Compute similarity scores (first model is reference)
|
|
150
|
-
scores =
|
|
151
|
-
SimilarityScorer.score(response_texts)
|
|
152
|
-
else
|
|
153
|
-
Array.new(robot_entries.size)
|
|
154
|
-
end
|
|
119
|
+
scores = robot_entries.size > 1 ? SimilarityScorer.score(response_texts) : Array.new(robot_entries.size)
|
|
155
120
|
|
|
156
121
|
robot_entries.each_with_index do |entry, i|
|
|
157
122
|
entry[:similarity] = scores[i]
|
|
@@ -161,6 +126,39 @@ module AIA
|
|
|
161
126
|
end
|
|
162
127
|
end
|
|
163
128
|
|
|
129
|
+
# One turn entry for a single robot's result within a network flow.
|
|
130
|
+
def network_robot_entry(task_name, robot_result, input:, decisions:, now:)
|
|
131
|
+
raw = robot_result.raw
|
|
132
|
+
input_tokens = (raw.respond_to?(:input_tokens) && raw.input_tokens) || 0
|
|
133
|
+
output_tokens = (raw.respond_to?(:output_tokens) && raw.output_tokens) || 0
|
|
134
|
+
tokens = input_tokens + output_tokens
|
|
135
|
+
|
|
136
|
+
model_id = extract_model_id_from_raw(raw)
|
|
137
|
+
model_id ||= robot_result.respond_to?(:robot_name) ? robot_result.robot_name : task_name.to_s
|
|
138
|
+
|
|
139
|
+
{
|
|
140
|
+
model: model_id,
|
|
141
|
+
input_length: input.to_s.length,
|
|
142
|
+
input_tokens: input_tokens,
|
|
143
|
+
output_tokens: output_tokens,
|
|
144
|
+
tokens: tokens,
|
|
145
|
+
cost: tokens.positive? ? compute_cost_for_model(model_id, input_tokens, output_tokens) : 0.0,
|
|
146
|
+
elapsed: robot_result.respond_to?(:duration) ? (robot_result.duration || 0) : 0,
|
|
147
|
+
decisions: decisions&.to_h,
|
|
148
|
+
timestamp: now
|
|
149
|
+
}
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def extract_response_text(robot_result)
|
|
153
|
+
if robot_result.respond_to?(:reply)
|
|
154
|
+
robot_result.reply.to_s
|
|
155
|
+
elsif robot_result.respond_to?(:content)
|
|
156
|
+
robot_result.content.to_s
|
|
157
|
+
else
|
|
158
|
+
""
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
164
162
|
def extract_model_id_from_raw(raw)
|
|
165
163
|
return nil unless raw
|
|
166
164
|
return raw.model_id if raw.respond_to?(:model_id) && raw.model_id
|
|
@@ -15,11 +15,13 @@ module AIA
|
|
|
15
15
|
#
|
|
16
16
|
# @param responses [Array<String>] ordered response texts (first is reference)
|
|
17
17
|
# @return [Array<Float, nil>] similarity scores (nil for first, 0.0..1.0 for rest)
|
|
18
|
+
# :reek:TooManyStatements -- guarded scoring: two early-out shapes, TF-IDF fit/transform, pairwise map, rescue fallback
|
|
18
19
|
def self.score(responses)
|
|
19
|
-
|
|
20
|
+
count = responses.size
|
|
21
|
+
return Array.new(count) if count < 2
|
|
20
22
|
|
|
21
23
|
texts = responses.map { |r| r.to_s.strip }
|
|
22
|
-
return Array.new(
|
|
24
|
+
return Array.new(count) if texts.first.empty?
|
|
23
25
|
|
|
24
26
|
tfidf = Classifier::TFIDF.new
|
|
25
27
|
tfidf.fit(texts)
|
|
@@ -33,7 +35,7 @@ module AIA
|
|
|
33
35
|
end
|
|
34
36
|
end
|
|
35
37
|
rescue StandardError
|
|
36
|
-
Array.new(
|
|
38
|
+
Array.new(count)
|
|
37
39
|
end
|
|
38
40
|
end
|
|
39
41
|
end
|