ruby_llm-agents 3.1.0 → 3.2.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/README.md +1 -0
- data/app/controllers/ruby_llm/agents/agents_controller.rb +16 -14
- data/app/controllers/ruby_llm/agents/dashboard_controller.rb +20 -20
- data/app/controllers/ruby_llm/agents/executions_controller.rb +5 -7
- data/app/helpers/ruby_llm/agents/application_helper.rb +57 -58
- data/app/models/ruby_llm/agents/execution/analytics.rb +27 -27
- data/app/models/ruby_llm/agents/execution/scopes.rb +4 -6
- data/app/models/ruby_llm/agents/execution.rb +25 -25
- data/app/models/ruby_llm/agents/tenant/budgetable.rb +16 -10
- data/app/models/ruby_llm/agents/tenant/resettable.rb +12 -12
- data/app/models/ruby_llm/agents/tenant/trackable.rb +7 -7
- data/app/services/ruby_llm/agents/agent_registry.rb +6 -6
- data/lib/generators/ruby_llm_agents/agent_generator.rb +4 -4
- data/lib/generators/ruby_llm_agents/background_remover_generator.rb +6 -6
- data/lib/generators/ruby_llm_agents/embedder_generator.rb +4 -4
- data/lib/generators/ruby_llm_agents/image_analyzer_generator.rb +7 -7
- data/lib/generators/ruby_llm_agents/image_editor_generator.rb +4 -4
- data/lib/generators/ruby_llm_agents/image_generator_generator.rb +6 -6
- data/lib/generators/ruby_llm_agents/image_pipeline_generator.rb +9 -9
- data/lib/generators/ruby_llm_agents/image_transformer_generator.rb +6 -6
- data/lib/generators/ruby_llm_agents/image_upscaler_generator.rb +4 -4
- data/lib/generators/ruby_llm_agents/image_variator_generator.rb +4 -4
- data/lib/generators/ruby_llm_agents/install_generator.rb +3 -3
- data/lib/generators/ruby_llm_agents/migrate_structure_generator.rb +4 -4
- data/lib/generators/ruby_llm_agents/multi_tenancy_generator.rb +2 -2
- data/lib/generators/ruby_llm_agents/restructure_generator.rb +13 -13
- data/lib/generators/ruby_llm_agents/speaker_generator.rb +6 -6
- data/lib/generators/ruby_llm_agents/transcriber_generator.rb +4 -4
- data/lib/generators/ruby_llm_agents/upgrade_generator.rb +2 -2
- data/lib/ruby_llm/agents/audio/speaker.rb +40 -31
- data/lib/ruby_llm/agents/audio/speech_client.rb +328 -0
- data/lib/ruby_llm/agents/audio/speech_pricing.rb +273 -0
- data/lib/ruby_llm/agents/audio/transcriber.rb +33 -33
- data/lib/ruby_llm/agents/base_agent.rb +14 -14
- data/lib/ruby_llm/agents/core/base/callbacks.rb +3 -3
- data/lib/ruby_llm/agents/core/configuration.rb +86 -73
- data/lib/ruby_llm/agents/core/errors.rb +27 -2
- data/lib/ruby_llm/agents/core/instrumentation.rb +64 -66
- data/lib/ruby_llm/agents/core/llm_tenant.rb +7 -7
- data/lib/ruby_llm/agents/core/version.rb +1 -1
- data/lib/ruby_llm/agents/dsl/base.rb +3 -3
- data/lib/ruby_llm/agents/dsl/reliability.rb +9 -9
- data/lib/ruby_llm/agents/image/analyzer/dsl.rb +1 -1
- data/lib/ruby_llm/agents/image/analyzer/execution.rb +4 -4
- data/lib/ruby_llm/agents/image/background_remover/dsl.rb +1 -1
- data/lib/ruby_llm/agents/image/background_remover/execution.rb +3 -3
- data/lib/ruby_llm/agents/image/concerns/image_operation_execution.rb +8 -8
- data/lib/ruby_llm/agents/image/editor/execution.rb +1 -1
- data/lib/ruby_llm/agents/image/generator/pricing.rb +9 -10
- data/lib/ruby_llm/agents/image/generator.rb +6 -6
- data/lib/ruby_llm/agents/image/pipeline/dsl.rb +6 -6
- data/lib/ruby_llm/agents/image/pipeline/execution.rb +9 -9
- data/lib/ruby_llm/agents/image/pipeline.rb +1 -1
- data/lib/ruby_llm/agents/image/transformer/execution.rb +1 -1
- data/lib/ruby_llm/agents/image/upscaler/dsl.rb +1 -1
- data/lib/ruby_llm/agents/image/upscaler/execution.rb +3 -5
- data/lib/ruby_llm/agents/image/variator/execution.rb +1 -1
- data/lib/ruby_llm/agents/infrastructure/alert_manager.rb +4 -4
- data/lib/ruby_llm/agents/infrastructure/attempt_tracker.rb +4 -4
- data/lib/ruby_llm/agents/infrastructure/budget/budget_query.rb +9 -9
- data/lib/ruby_llm/agents/infrastructure/budget/config_resolver.rb +3 -3
- data/lib/ruby_llm/agents/infrastructure/budget/forecaster.rb +1 -1
- data/lib/ruby_llm/agents/infrastructure/budget/spend_recorder.rb +17 -17
- data/lib/ruby_llm/agents/infrastructure/circuit_breaker.rb +1 -0
- data/lib/ruby_llm/agents/infrastructure/execution_logger_job.rb +1 -1
- data/lib/ruby_llm/agents/infrastructure/reliability.rb +6 -6
- data/lib/ruby_llm/agents/pipeline/builder.rb +11 -11
- data/lib/ruby_llm/agents/pipeline/middleware/budget.rb +3 -3
- data/lib/ruby_llm/agents/pipeline/middleware/cache.rb +4 -4
- data/lib/ruby_llm/agents/pipeline/middleware/instrumentation.rb +34 -22
- data/lib/ruby_llm/agents/pipeline/middleware/reliability.rb +2 -3
- data/lib/ruby_llm/agents/pipeline/middleware/tenant.rb +7 -7
- data/lib/ruby_llm/agents/results/background_removal_result.rb +6 -6
- data/lib/ruby_llm/agents/results/embedding_result.rb +15 -15
- data/lib/ruby_llm/agents/results/image_analysis_result.rb +7 -7
- data/lib/ruby_llm/agents/results/image_edit_result.rb +4 -4
- data/lib/ruby_llm/agents/results/image_generation_result.rb +5 -5
- data/lib/ruby_llm/agents/results/image_pipeline_result.rb +4 -4
- data/lib/ruby_llm/agents/results/image_transform_result.rb +4 -4
- data/lib/ruby_llm/agents/results/image_upscale_result.rb +5 -5
- data/lib/ruby_llm/agents/results/image_variation_result.rb +4 -4
- data/lib/ruby_llm/agents/results/transcription_result.rb +1 -1
- data/lib/ruby_llm/agents/text/embedder.rb +13 -13
- metadata +3 -1
|
@@ -21,8 +21,8 @@ module RubyLLM
|
|
|
21
21
|
#
|
|
22
22
|
class ImageGenerationResult
|
|
23
23
|
attr_reader :images, :prompt, :model_id, :size, :quality, :style,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
:started_at, :completed_at, :tenant_id, :generator_class,
|
|
25
|
+
:error_class, :error_message
|
|
26
26
|
|
|
27
27
|
# Initialize a new result
|
|
28
28
|
#
|
|
@@ -39,8 +39,8 @@ module RubyLLM
|
|
|
39
39
|
# @param error_class [String, nil] Error class name if failed
|
|
40
40
|
# @param error_message [String, nil] Error message if failed
|
|
41
41
|
def initialize(images:, prompt:, model_id:, size:, quality:, style:,
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
started_at:, completed_at:, tenant_id:, generator_class:,
|
|
43
|
+
error_class: nil, error_message: nil)
|
|
44
44
|
@images = images
|
|
45
45
|
@prompt = prompt
|
|
46
46
|
@model_id = model_id
|
|
@@ -294,7 +294,7 @@ module RubyLLM
|
|
|
294
294
|
#
|
|
295
295
|
class CachedImageGenerationResult
|
|
296
296
|
attr_reader :urls, :datas, :mime_type, :revised_prompts, :model_id,
|
|
297
|
-
|
|
297
|
+
:total_cost, :cached_at
|
|
298
298
|
|
|
299
299
|
def initialize(data)
|
|
300
300
|
@urls = data[:urls] || []
|
|
@@ -22,7 +22,7 @@ module RubyLLM
|
|
|
22
22
|
#
|
|
23
23
|
class ImagePipelineResult
|
|
24
24
|
attr_reader :step_results, :started_at, :completed_at, :tenant_id,
|
|
25
|
-
|
|
25
|
+
:pipeline_class, :context, :error_class, :error_message
|
|
26
26
|
|
|
27
27
|
# Initialize a new pipeline result
|
|
28
28
|
#
|
|
@@ -35,7 +35,7 @@ module RubyLLM
|
|
|
35
35
|
# @param error_class [String, nil] Error class name if failed
|
|
36
36
|
# @param error_message [String, nil] Error message if failed
|
|
37
37
|
def initialize(step_results:, started_at:, completed_at:, tenant_id:,
|
|
38
|
-
|
|
38
|
+
pipeline_class:, context:, error_class: nil, error_message: nil)
|
|
39
39
|
@step_results = step_results
|
|
40
40
|
@started_at = started_at
|
|
41
41
|
@completed_at = completed_at
|
|
@@ -100,7 +100,7 @@ module RubyLLM
|
|
|
100
100
|
step_data&.dig(:result)
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
alias_method :[], :step
|
|
104
104
|
|
|
105
105
|
# Get step names
|
|
106
106
|
#
|
|
@@ -378,7 +378,7 @@ module RubyLLM
|
|
|
378
378
|
step_data&.dig(:cached_result)
|
|
379
379
|
end
|
|
380
380
|
|
|
381
|
-
|
|
381
|
+
alias_method :[], :step
|
|
382
382
|
|
|
383
383
|
def final_image
|
|
384
384
|
# Find last non-analyzer step
|
|
@@ -18,8 +18,8 @@ module RubyLLM
|
|
|
18
18
|
#
|
|
19
19
|
class ImageTransformResult
|
|
20
20
|
attr_reader :images, :source_image, :prompt, :model_id, :size, :strength,
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
:started_at, :completed_at, :tenant_id, :transformer_class,
|
|
22
|
+
:error_class, :error_message
|
|
23
23
|
|
|
24
24
|
# Initialize a new result
|
|
25
25
|
#
|
|
@@ -36,8 +36,8 @@ module RubyLLM
|
|
|
36
36
|
# @param error_class [String, nil] Error class name if failed
|
|
37
37
|
# @param error_message [String, nil] Error message if failed
|
|
38
38
|
def initialize(images:, source_image:, prompt:, model_id:, size:, strength:,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
started_at:, completed_at:, tenant_id:, transformer_class:,
|
|
40
|
+
error_class: nil, error_message: nil)
|
|
41
41
|
@images = images
|
|
42
42
|
@source_image = source_image
|
|
43
43
|
@prompt = prompt
|
|
@@ -16,8 +16,8 @@ module RubyLLM
|
|
|
16
16
|
#
|
|
17
17
|
class ImageUpscaleResult
|
|
18
18
|
attr_reader :image, :source_image, :model_id, :scale, :output_size, :face_enhance,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
:started_at, :completed_at, :tenant_id, :upscaler_class,
|
|
20
|
+
:error_class, :error_message
|
|
21
21
|
|
|
22
22
|
# Initialize a new result
|
|
23
23
|
#
|
|
@@ -34,8 +34,8 @@ module RubyLLM
|
|
|
34
34
|
# @param error_class [String, nil] Error class name if failed
|
|
35
35
|
# @param error_message [String, nil] Error message if failed
|
|
36
36
|
def initialize(image:, source_image:, model_id:, scale:, output_size:, face_enhance:,
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
started_at:, completed_at:, tenant_id:, upscaler_class:,
|
|
38
|
+
error_class: nil, error_message: nil)
|
|
39
39
|
@image = image
|
|
40
40
|
@source_image = source_image
|
|
41
41
|
@model_id = model_id
|
|
@@ -198,7 +198,7 @@ module RubyLLM
|
|
|
198
198
|
# Lightweight result for cached upscales
|
|
199
199
|
class CachedImageUpscaleResult
|
|
200
200
|
attr_reader :url, :data, :mime_type, :model_id, :scale, :output_size,
|
|
201
|
-
|
|
201
|
+
:total_cost, :cached_at
|
|
202
202
|
|
|
203
203
|
def initialize(data)
|
|
204
204
|
@url = data[:url]
|
|
@@ -15,8 +15,8 @@ module RubyLLM
|
|
|
15
15
|
#
|
|
16
16
|
class ImageVariationResult
|
|
17
17
|
attr_reader :images, :source_image, :model_id, :size, :variation_strength,
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
:started_at, :completed_at, :tenant_id, :variator_class,
|
|
19
|
+
:error_class, :error_message
|
|
20
20
|
|
|
21
21
|
# Initialize a new result
|
|
22
22
|
#
|
|
@@ -32,8 +32,8 @@ module RubyLLM
|
|
|
32
32
|
# @param error_class [String, nil] Error class name if failed
|
|
33
33
|
# @param error_message [String, nil] Error message if failed
|
|
34
34
|
def initialize(images:, source_image:, model_id:, size:, variation_strength:,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
started_at:, completed_at:, tenant_id:, variator_class:,
|
|
36
|
+
error_class: nil, error_message: nil)
|
|
37
37
|
@images = images
|
|
38
38
|
@source_image = source_image
|
|
39
39
|
@model_id = model_id
|
|
@@ -117,19 +117,19 @@ module RubyLLM
|
|
|
117
117
|
|
|
118
118
|
def default_embedding_model
|
|
119
119
|
RubyLLM::Agents.configuration.default_embedding_model
|
|
120
|
-
rescue
|
|
120
|
+
rescue
|
|
121
121
|
"text-embedding-3-small"
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
def default_embedding_dimensions
|
|
125
125
|
RubyLLM::Agents.configuration.default_embedding_dimensions
|
|
126
|
-
rescue
|
|
126
|
+
rescue
|
|
127
127
|
nil
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def default_embedding_batch_size
|
|
131
131
|
RubyLLM::Agents.configuration.default_embedding_batch_size
|
|
132
|
-
rescue
|
|
132
|
+
rescue
|
|
133
133
|
100
|
|
134
134
|
end
|
|
135
135
|
end
|
|
@@ -333,7 +333,7 @@ module RubyLLM
|
|
|
333
333
|
def execute_batch(texts, context = nil)
|
|
334
334
|
preprocessed = texts.map { |t| preprocess(t) }
|
|
335
335
|
|
|
336
|
-
embed_options = {
|
|
336
|
+
embed_options = {model: context&.model || resolved_model}
|
|
337
337
|
embed_options[:dimensions] = resolved_dimensions if resolved_dimensions
|
|
338
338
|
|
|
339
339
|
response = RubyLLM.embed(preprocessed, **embed_options)
|
|
@@ -405,15 +405,15 @@ module RubyLLM
|
|
|
405
405
|
model_name = response.model.to_s
|
|
406
406
|
|
|
407
407
|
price_per_million = case model_name
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
408
|
+
when /text-embedding-3-small/
|
|
409
|
+
0.02
|
|
410
|
+
when /text-embedding-3-large/
|
|
411
|
+
0.13
|
|
412
|
+
when /text-embedding-ada/
|
|
413
|
+
0.10
|
|
414
|
+
else
|
|
415
|
+
0.02 # Default to small pricing
|
|
416
|
+
end
|
|
417
417
|
|
|
418
418
|
(tokens / 1_000_000.0) * price_per_million
|
|
419
419
|
end
|
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.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- adham90
|
|
@@ -209,6 +209,8 @@ files:
|
|
|
209
209
|
- lib/ruby_llm-agents.rb
|
|
210
210
|
- lib/ruby_llm/agents.rb
|
|
211
211
|
- lib/ruby_llm/agents/audio/speaker.rb
|
|
212
|
+
- lib/ruby_llm/agents/audio/speech_client.rb
|
|
213
|
+
- lib/ruby_llm/agents/audio/speech_pricing.rb
|
|
212
214
|
- lib/ruby_llm/agents/audio/transcriber.rb
|
|
213
215
|
- lib/ruby_llm/agents/base_agent.rb
|
|
214
216
|
- lib/ruby_llm/agents/core/base.rb
|