ruby_llm-agents 3.7.2 → 3.8.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/ruby_llm/agents/agents_controller.rb +14 -141
  3. data/app/controllers/ruby_llm/agents/dashboard_controller.rb +12 -166
  4. data/app/controllers/ruby_llm/agents/executions_controller.rb +1 -1
  5. data/app/helpers/ruby_llm/agents/application_helper.rb +38 -0
  6. data/app/models/ruby_llm/agents/execution/analytics.rb +302 -103
  7. data/app/models/ruby_llm/agents/execution.rb +76 -54
  8. data/app/models/ruby_llm/agents/execution_detail.rb +2 -0
  9. data/app/models/ruby_llm/agents/tenant.rb +39 -0
  10. data/app/services/ruby_llm/agents/agent_registry.rb +98 -0
  11. data/app/views/ruby_llm/agents/executions/_list.html.erb +3 -17
  12. data/lib/generators/ruby_llm_agents/templates/add_dashboard_performance_indexes_migration.rb.tt +23 -0
  13. data/lib/generators/ruby_llm_agents/templates/migration.rb.tt +3 -0
  14. data/lib/generators/ruby_llm_agents/upgrade_generator.rb +25 -0
  15. data/lib/ruby_llm/agents/base_agent.rb +7 -1
  16. data/lib/ruby_llm/agents/core/configuration.rb +1 -0
  17. data/lib/ruby_llm/agents/core/instrumentation.rb +15 -19
  18. data/lib/ruby_llm/agents/core/version.rb +1 -1
  19. data/lib/ruby_llm/agents/infrastructure/alert_manager.rb +4 -4
  20. data/lib/ruby_llm/agents/infrastructure/budget_tracker.rb +19 -11
  21. data/lib/ruby_llm/agents/pipeline/builder.rb +8 -4
  22. data/lib/ruby_llm/agents/pipeline/context.rb +43 -1
  23. data/lib/ruby_llm/agents/pipeline/middleware/budget.rb +6 -4
  24. data/lib/ruby_llm/agents/pipeline/middleware/cache.rb +6 -4
  25. data/lib/ruby_llm/agents/pipeline/middleware/instrumentation.rb +26 -75
  26. data/lib/ruby_llm/agents/pipeline/middleware/reliability.rb +6 -6
  27. data/lib/ruby_llm/agents/pipeline/middleware/tenant.rb +23 -27
  28. data/lib/ruby_llm/agents/providers/inception/capabilities.rb +107 -0
  29. data/lib/ruby_llm/agents/providers/inception/chat.rb +17 -0
  30. data/lib/ruby_llm/agents/providers/inception/configuration.rb +9 -0
  31. data/lib/ruby_llm/agents/providers/inception/models.rb +38 -0
  32. data/lib/ruby_llm/agents/providers/inception/registry.rb +45 -0
  33. data/lib/ruby_llm/agents/providers/inception.rb +50 -0
  34. data/lib/ruby_llm/agents/results/base.rb +4 -2
  35. data/lib/ruby_llm/agents/results/image_analysis_result.rb +4 -2
  36. data/lib/ruby_llm/agents/text/embedder.rb +4 -0
  37. data/lib/ruby_llm/agents.rb +4 -0
  38. metadata +8 -1
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLLM
4
+ module Agents
5
+ module Providers
6
+ class Inception
7
+ # Registers Mercury models in the RubyLLM model registry so they
8
+ # can be resolved by model ID without calling the Inception /models API.
9
+ module Registry
10
+ MODELS = [
11
+ {id: "mercury-2", name: "Mercury 2"},
12
+ {id: "mercury", name: "Mercury"},
13
+ {id: "mercury-coder-small", name: "Mercury Coder Small"},
14
+ {id: "mercury-edit", name: "Mercury Edit"}
15
+ ].freeze
16
+
17
+ module_function
18
+
19
+ def register_models!
20
+ models_instance = ::RubyLLM::Models.instance
21
+ capabilities = Inception::Capabilities
22
+
23
+ MODELS.each do |model_def|
24
+ model_id = model_def[:id]
25
+
26
+ model_info = ::RubyLLM::Model::Info.new(
27
+ id: model_id,
28
+ name: model_def[:name],
29
+ provider: "inception",
30
+ family: "mercury",
31
+ context_window: capabilities.context_window_for(model_id),
32
+ max_output_tokens: capabilities.max_tokens_for(model_id),
33
+ modalities: capabilities.modalities_for(model_id),
34
+ capabilities: capabilities.capabilities_for(model_id),
35
+ pricing: capabilities.pricing_for(model_id)
36
+ )
37
+
38
+ models_instance.all << model_info
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Configuration extension must be loaded first (adds inception_api_key to RubyLLM::Configuration)
4
+ require_relative "inception/configuration"
5
+
6
+ module RubyLLM
7
+ module Agents
8
+ module Providers
9
+ # Inception Labs Mercury API integration (OpenAI-compatible).
10
+ # Mercury models are diffusion LLMs (dLLMs) that generate tokens
11
+ # in parallel for dramatically faster inference.
12
+ #
13
+ # @see https://docs.inceptionlabs.ai/
14
+ class Inception < ::RubyLLM::Providers::OpenAI
15
+ def api_base
16
+ "https://api.inceptionlabs.ai/v1"
17
+ end
18
+
19
+ def headers
20
+ {
21
+ "Authorization" => "Bearer #{@config.inception_api_key}"
22
+ }
23
+ end
24
+
25
+ class << self
26
+ def capabilities
27
+ Inception::Capabilities
28
+ end
29
+
30
+ def configuration_requirements
31
+ %i[inception_api_key]
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ # Load sub-modules after the class is defined
40
+ require_relative "inception/capabilities"
41
+ require_relative "inception/chat"
42
+ require_relative "inception/models"
43
+ require_relative "inception/registry"
44
+
45
+ # Include modules after they're loaded
46
+ RubyLLM::Agents::Providers::Inception.include RubyLLM::Agents::Providers::Inception::Chat
47
+ RubyLLM::Agents::Providers::Inception.include RubyLLM::Agents::Providers::Inception::Models
48
+
49
+ # Register Mercury models in the RubyLLM model registry
50
+ RubyLLM::Agents::Providers::Inception::Registry.register_models!
@@ -219,16 +219,18 @@ module RubyLLM
219
219
  # Returns whether tool calls were made during execution
220
220
  #
221
221
  # @return [Boolean] true if tool_calls_count > 0
222
- def has_tool_calls?
222
+ def tool_calls?
223
223
  tool_calls_count.to_i > 0
224
224
  end
225
+ alias_method :has_tool_calls?, :tool_calls?
225
226
 
226
227
  # Returns whether thinking data is present in the result
227
228
  #
228
229
  # @return [Boolean] true if thinking_text is present
229
- def has_thinking?
230
+ def thinking?
230
231
  thinking_text.present?
231
232
  end
233
+ alias_method :has_thinking?, :thinking?
232
234
 
233
235
  # Converts the result to a hash
234
236
  #
@@ -161,17 +161,19 @@ module RubyLLM
161
161
  #
162
162
  # @param name [String] Object name to search for
163
163
  # @return [Boolean] Whether the object was detected
164
- def has_object?(name)
164
+ def includes_object?(name)
165
165
  objects.any? { |obj| obj[:name]&.downcase&.include?(name.to_s.downcase) }
166
166
  end
167
+ alias_method :has_object?, :includes_object?
167
168
 
168
169
  # Check if a specific tag is present
169
170
  #
170
171
  # @param tag [String] Tag to search for
171
172
  # @return [Boolean] Whether the tag is present
172
- def has_tag?(tag)
173
+ def includes_tag?(tag)
173
174
  tags.any? { |t| t.downcase == tag.to_s.downcase }
174
175
  end
176
+ alias_method :has_tag?, :includes_tag?
175
177
 
176
178
  # Timing
177
179
 
@@ -337,6 +337,10 @@ module RubyLLM
337
337
  embed_options = {model: context&.model || resolved_model}
338
338
  embed_options[:dimensions] = resolved_dimensions if resolved_dimensions
339
339
 
340
+ # Pass scoped RubyLLM context for thread-safe per-tenant API keys
341
+ llm_ctx = context&.llm
342
+ embed_options[:context] = llm_ctx if llm_ctx.is_a?(RubyLLM::Context)
343
+
340
344
  response = RubyLLM.embed(preprocessed, **embed_options)
341
345
 
342
346
  # ruby_llm returns vectors as an array (even for single text)
@@ -78,6 +78,10 @@ require_relative "agents/image/pipeline"
78
78
  # Evaluation framework
79
79
  require_relative "agents/eval"
80
80
 
81
+ # Providers (extends RubyLLM with additional providers)
82
+ require_relative "agents/providers/inception"
83
+ RubyLLM::Provider.register :inception, RubyLLM::Agents::Providers::Inception
84
+
81
85
  # Rails integration
82
86
  if defined?(Rails)
83
87
  require_relative "agents/core/inflections"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_llm-agents
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.2
4
+ version: 3.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - adham90
@@ -154,6 +154,7 @@ files:
154
154
  - lib/generators/ruby_llm_agents/templates/add_assistant_prompt_migration.rb.tt
155
155
  - lib/generators/ruby_llm_agents/templates/add_attempts_migration.rb.tt
156
156
  - lib/generators/ruby_llm_agents/templates/add_caching_migration.rb.tt
157
+ - lib/generators/ruby_llm_agents/templates/add_dashboard_performance_indexes_migration.rb.tt
157
158
  - lib/generators/ruby_llm_agents/templates/add_execution_type_migration.rb.tt
158
159
  - lib/generators/ruby_llm_agents/templates/add_finish_reason_migration.rb.tt
159
160
  - lib/generators/ruby_llm_agents/templates/add_prompts_migration.rb.tt
@@ -296,6 +297,12 @@ files:
296
297
  - lib/ruby_llm/agents/pricing/openrouter_adapter.rb
297
298
  - lib/ruby_llm/agents/pricing/portkey_adapter.rb
298
299
  - lib/ruby_llm/agents/pricing/ruby_llm_adapter.rb
300
+ - lib/ruby_llm/agents/providers/inception.rb
301
+ - lib/ruby_llm/agents/providers/inception/capabilities.rb
302
+ - lib/ruby_llm/agents/providers/inception/chat.rb
303
+ - lib/ruby_llm/agents/providers/inception/configuration.rb
304
+ - lib/ruby_llm/agents/providers/inception/models.rb
305
+ - lib/ruby_llm/agents/providers/inception/registry.rb
299
306
  - lib/ruby_llm/agents/rails/engine.rb
300
307
  - lib/ruby_llm/agents/results/background_removal_result.rb
301
308
  - lib/ruby_llm/agents/results/base.rb