ruby_llm-agents 1.0.0 → 1.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/app/controllers/concerns/ruby_llm/agents/paginatable.rb +9 -3
- data/app/controllers/concerns/ruby_llm/agents/sortable.rb +58 -0
- data/app/controllers/ruby_llm/agents/agents_controller.rb +59 -16
- data/app/controllers/ruby_llm/agents/dashboard_controller.rb +144 -20
- data/app/controllers/ruby_llm/agents/executions_controller.rb +13 -16
- data/app/controllers/ruby_llm/agents/workflows_controller.rb +279 -90
- data/app/helpers/ruby_llm/agents/application_helper.rb +100 -0
- data/app/mailers/ruby_llm/agents/alert_mailer.rb +84 -0
- data/app/mailers/ruby_llm/agents/application_mailer.rb +28 -0
- data/app/models/ruby_llm/agents/execution/analytics.rb +170 -20
- data/app/models/ruby_llm/agents/execution/scopes.rb +0 -31
- data/app/models/ruby_llm/agents/execution/workflow.rb +0 -129
- data/app/models/ruby_llm/agents/execution.rb +50 -14
- data/app/models/ruby_llm/agents/tenant/budgetable.rb +277 -0
- data/app/models/ruby_llm/agents/tenant/configurable.rb +135 -0
- data/app/models/ruby_llm/agents/tenant/trackable.rb +310 -0
- data/app/models/ruby_llm/agents/tenant.rb +146 -0
- data/app/models/ruby_llm/agents/tenant_budget.rb +12 -253
- data/app/services/ruby_llm/agents/agent_registry.rb +18 -12
- data/app/views/layouts/ruby_llm/agents/application.html.erb +72 -76
- data/app/views/ruby_llm/agents/agents/_agent.html.erb +0 -12
- data/app/views/ruby_llm/agents/agents/_sortable_header.html.erb +56 -0
- data/app/views/ruby_llm/agents/agents/_workflow.html.erb +5 -15
- data/app/views/ruby_llm/agents/agents/index.html.erb +271 -100
- data/app/views/ruby_llm/agents/agents/show.html.erb +1 -0
- data/app/views/ruby_llm/agents/alert_mailer/alert_notification.html.erb +107 -0
- data/app/views/ruby_llm/agents/alert_mailer/alert_notification.text.erb +18 -0
- data/app/views/ruby_llm/agents/api_configurations/show.html.erb +4 -1
- data/app/views/ruby_llm/agents/dashboard/_agent_comparison.html.erb +66 -359
- data/app/views/ruby_llm/agents/dashboard/_model_comparison.html.erb +56 -0
- data/app/views/ruby_llm/agents/dashboard/_model_cost_breakdown.html.erb +115 -0
- data/app/views/ruby_llm/agents/dashboard/_now_strip.html.erb +35 -60
- data/app/views/ruby_llm/agents/dashboard/_top_errors.html.erb +17 -6
- data/app/views/ruby_llm/agents/dashboard/index.html.erb +373 -72
- data/app/views/ruby_llm/agents/executions/_execution.html.erb +0 -1
- data/app/views/ruby_llm/agents/executions/_filters.html.erb +51 -39
- data/app/views/ruby_llm/agents/executions/_list.html.erb +53 -195
- data/app/views/ruby_llm/agents/executions/_workflow_summary.html.erb +5 -20
- data/app/views/ruby_llm/agents/executions/index.html.erb +7 -83
- data/app/views/ruby_llm/agents/executions/show.html.erb +10 -20
- data/app/views/ruby_llm/agents/shared/_agent_type_badge.html.erb +2 -1
- data/app/views/ruby_llm/agents/shared/_doc_link.html.erb +12 -0
- data/app/views/ruby_llm/agents/shared/_executions_table.html.erb +3 -15
- data/app/views/ruby_llm/agents/shared/_filter_dropdown.html.erb +1 -1
- data/app/views/ruby_llm/agents/shared/_select_dropdown.html.erb +1 -1
- data/app/views/ruby_llm/agents/shared/_sortable_header.html.erb +53 -0
- data/app/views/ruby_llm/agents/shared/_status_badge.html.erb +7 -0
- data/app/views/ruby_llm/agents/shared/_status_dot.html.erb +1 -1
- data/app/views/ruby_llm/agents/shared/_workflow_type_badge.html.erb +9 -35
- data/app/views/ruby_llm/agents/system_config/show.html.erb +4 -1
- data/app/views/ruby_llm/agents/tenants/index.html.erb +4 -1
- data/app/views/ruby_llm/agents/workflows/_step_performance.html.erb +7 -15
- data/app/views/ruby_llm/agents/workflows/_structure_dsl.html.erb +539 -0
- data/app/views/ruby_llm/agents/workflows/_workflow_diagram.html.erb +920 -0
- data/app/views/ruby_llm/agents/workflows/index.html.erb +179 -0
- data/app/views/ruby_llm/agents/workflows/show.html.erb +164 -139
- data/config/routes.rb +1 -1
- data/lib/generators/ruby_llm_agents/agent_generator.rb +6 -36
- data/lib/generators/ruby_llm_agents/background_remover_generator.rb +7 -37
- data/lib/generators/ruby_llm_agents/embedder_generator.rb +5 -38
- data/lib/generators/ruby_llm_agents/image_analyzer_generator.rb +7 -37
- data/lib/generators/ruby_llm_agents/image_editor_generator.rb +7 -37
- data/lib/generators/ruby_llm_agents/image_generator_generator.rb +8 -41
- data/lib/generators/ruby_llm_agents/image_pipeline_generator.rb +18 -46
- data/lib/generators/ruby_llm_agents/image_transformer_generator.rb +7 -37
- data/lib/generators/ruby_llm_agents/image_upscaler_generator.rb +7 -37
- data/lib/generators/ruby_llm_agents/image_variator_generator.rb +7 -37
- data/lib/generators/ruby_llm_agents/install_generator.rb +33 -56
- data/lib/generators/ruby_llm_agents/migrate_structure_generator.rb +480 -0
- data/lib/generators/ruby_llm_agents/multi_tenancy_generator.rb +42 -22
- data/lib/generators/ruby_llm_agents/restructure_generator.rb +2 -2
- data/lib/generators/ruby_llm_agents/speaker_generator.rb +8 -39
- data/lib/generators/ruby_llm_agents/templates/add_tenant_to_executions_migration.rb.tt +13 -2
- data/lib/generators/ruby_llm_agents/templates/agent.rb.tt +5 -8
- data/lib/generators/ruby_llm_agents/templates/application_agent.rb.tt +40 -42
- data/lib/generators/ruby_llm_agents/templates/application_background_remover.rb.tt +20 -22
- data/lib/generators/ruby_llm_agents/templates/application_embedder.rb.tt +24 -26
- data/lib/generators/ruby_llm_agents/templates/application_image_analyzer.rb.tt +20 -22
- data/lib/generators/ruby_llm_agents/templates/application_image_editor.rb.tt +19 -17
- data/lib/generators/ruby_llm_agents/templates/application_image_generator.rb.tt +31 -33
- data/lib/generators/ruby_llm_agents/templates/application_image_pipeline.rb.tt +125 -127
- data/lib/generators/ruby_llm_agents/templates/application_image_transformer.rb.tt +20 -18
- data/lib/generators/ruby_llm_agents/templates/application_image_upscaler.rb.tt +19 -17
- data/lib/generators/ruby_llm_agents/templates/application_image_variator.rb.tt +19 -17
- data/lib/generators/ruby_llm_agents/templates/application_speaker.rb.tt +38 -40
- data/lib/generators/ruby_llm_agents/templates/application_transcriber.rb.tt +42 -44
- data/lib/generators/ruby_llm_agents/templates/application_workflow.rb.tt +48 -0
- data/lib/generators/ruby_llm_agents/templates/background_remover.rb.tt +19 -21
- data/lib/generators/ruby_llm_agents/templates/create_tenant_budgets_migration.rb.tt +11 -0
- data/lib/generators/ruby_llm_agents/templates/create_tenants_migration.rb.tt +72 -0
- data/lib/generators/ruby_llm_agents/templates/embedder.rb.tt +19 -21
- data/lib/generators/ruby_llm_agents/templates/image_analyzer.rb.tt +20 -22
- data/lib/generators/ruby_llm_agents/templates/image_editor.rb.tt +15 -17
- data/lib/generators/ruby_llm_agents/templates/image_generator.rb.tt +25 -27
- data/lib/generators/ruby_llm_agents/templates/image_pipeline.rb.tt +19 -21
- data/lib/generators/ruby_llm_agents/templates/image_transformer.rb.tt +20 -22
- data/lib/generators/ruby_llm_agents/templates/image_upscaler.rb.tt +17 -19
- data/lib/generators/ruby_llm_agents/templates/image_variator.rb.tt +15 -17
- data/lib/generators/ruby_llm_agents/templates/rename_tenant_budgets_to_tenants_migration.rb.tt +34 -0
- data/lib/generators/ruby_llm_agents/templates/skills/AGENTS.md.tt +87 -24
- data/lib/generators/ruby_llm_agents/templates/skills/BACKGROUND_REMOVERS.md.tt +21 -27
- data/lib/generators/ruby_llm_agents/templates/skills/EMBEDDERS.md.tt +46 -54
- data/lib/generators/ruby_llm_agents/templates/skills/IMAGE_ANALYZERS.md.tt +31 -39
- data/lib/generators/ruby_llm_agents/templates/skills/IMAGE_EDITORS.md.tt +22 -28
- data/lib/generators/ruby_llm_agents/templates/skills/IMAGE_GENERATORS.md.tt +53 -63
- data/lib/generators/ruby_llm_agents/templates/skills/IMAGE_PIPELINES.md.tt +46 -56
- data/lib/generators/ruby_llm_agents/templates/skills/IMAGE_TRANSFORMERS.md.tt +23 -31
- data/lib/generators/ruby_llm_agents/templates/skills/IMAGE_UPSCALERS.md.tt +22 -30
- data/lib/generators/ruby_llm_agents/templates/skills/IMAGE_VARIATORS.md.tt +23 -31
- data/lib/generators/ruby_llm_agents/templates/skills/SPEAKERS.md.tt +38 -46
- data/lib/generators/ruby_llm_agents/templates/skills/TOOLS.md.tt +7 -7
- data/lib/generators/ruby_llm_agents/templates/skills/TRANSCRIBERS.md.tt +59 -71
- data/lib/generators/ruby_llm_agents/templates/skills/WORKFLOWS.md.tt +274 -23
- data/lib/generators/ruby_llm_agents/templates/speaker.rb.tt +29 -31
- data/lib/generators/ruby_llm_agents/templates/transcriber.rb.tt +28 -30
- data/lib/generators/ruby_llm_agents/transcriber_generator.rb +10 -43
- data/lib/generators/ruby_llm_agents/upgrade_generator.rb +26 -0
- data/lib/ruby_llm/agents/core/configuration.rb +55 -43
- data/lib/ruby_llm/agents/core/llm_tenant.rb +60 -60
- data/lib/ruby_llm/agents/core/version.rb +1 -1
- data/lib/ruby_llm/agents/infrastructure/alert_manager.rb +26 -0
- data/lib/ruby_llm/agents/infrastructure/budget/config_resolver.rb +4 -2
- data/lib/ruby_llm/agents/pipeline.rb +69 -0
- data/lib/ruby_llm/agents/workflow/approval.rb +205 -0
- data/lib/ruby_llm/agents/workflow/approval_store.rb +179 -0
- data/lib/ruby_llm/agents/workflow/dsl/executor.rb +467 -0
- data/lib/ruby_llm/agents/workflow/dsl/input_schema.rb +244 -0
- data/lib/ruby_llm/agents/workflow/dsl/iteration_executor.rb +289 -0
- data/lib/ruby_llm/agents/workflow/dsl/parallel_group.rb +107 -0
- data/lib/ruby_llm/agents/workflow/dsl/route_builder.rb +150 -0
- data/lib/ruby_llm/agents/workflow/dsl/schedule_helpers.rb +187 -0
- data/lib/ruby_llm/agents/workflow/dsl/step_config.rb +352 -0
- data/lib/ruby_llm/agents/workflow/dsl/step_executor.rb +415 -0
- data/lib/ruby_llm/agents/workflow/dsl/wait_config.rb +257 -0
- data/lib/ruby_llm/agents/workflow/dsl/wait_executor.rb +317 -0
- data/lib/ruby_llm/agents/workflow/dsl.rb +576 -0
- data/lib/ruby_llm/agents/workflow/instrumentation.rb +2 -7
- data/lib/ruby_llm/agents/workflow/notifiers/base.rb +117 -0
- data/lib/ruby_llm/agents/workflow/notifiers/email.rb +117 -0
- data/lib/ruby_llm/agents/workflow/notifiers/slack.rb +180 -0
- data/lib/ruby_llm/agents/workflow/notifiers/webhook.rb +121 -0
- data/lib/ruby_llm/agents/workflow/notifiers.rb +70 -0
- data/lib/ruby_llm/agents/workflow/orchestrator.rb +190 -23
- data/lib/ruby_llm/agents/workflow/result.rb +202 -0
- data/lib/ruby_llm/agents/workflow/throttle_manager.rb +206 -0
- data/lib/ruby_llm/agents/workflow/wait_result.rb +213 -0
- metadata +43 -6
- data/app/views/ruby_llm/agents/dashboard/_execution_item.html.erb +0 -66
- data/lib/ruby_llm/agents/workflow/parallel.rb +0 -299
- data/lib/ruby_llm/agents/workflow/pipeline.rb +0 -306
- data/lib/ruby_llm/agents/workflow/router.rb +0 -429
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Images Variators
|
|
2
2
|
|
|
3
3
|
This directory contains image variation services. All variators inherit from `ApplicationImageVariator`.
|
|
4
4
|
|
|
@@ -12,13 +12,11 @@ rails generate ruby_llm_agents:image_variator Product --count 4
|
|
|
12
12
|
|
|
13
13
|
Or create manually:
|
|
14
14
|
```ruby
|
|
15
|
-
module
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
size "1024x1024"
|
|
21
|
-
end
|
|
15
|
+
module Images
|
|
16
|
+
class ProductVariator < ApplicationImageVariator
|
|
17
|
+
model "gpt-image-1"
|
|
18
|
+
count 4
|
|
19
|
+
size "1024x1024"
|
|
22
20
|
end
|
|
23
21
|
end
|
|
24
22
|
```
|
|
@@ -40,7 +38,7 @@ end
|
|
|
40
38
|
## Using Variators
|
|
41
39
|
|
|
42
40
|
```ruby
|
|
43
|
-
result =
|
|
41
|
+
result = Images::ProductVariator.call(image: "product.png")
|
|
44
42
|
|
|
45
43
|
result.urls # Array of variation URLs
|
|
46
44
|
result.images # Array of image data
|
|
@@ -51,7 +49,7 @@ result.total_cost # Combined cost
|
|
|
51
49
|
### Override Count
|
|
52
50
|
|
|
53
51
|
```ruby
|
|
54
|
-
result =
|
|
52
|
+
result = Images::ProductVariator.call(
|
|
55
53
|
image: "logo.png",
|
|
56
54
|
count: 8 # Generate 8 variations
|
|
57
55
|
)
|
|
@@ -60,7 +58,7 @@ result = <%= @root_namespace %>::Image::ProductVariator.call(
|
|
|
60
58
|
### Save All Variations
|
|
61
59
|
|
|
62
60
|
```ruby
|
|
63
|
-
result =
|
|
61
|
+
result = Images::ProductVariator.call(image: "design.png")
|
|
64
62
|
|
|
65
63
|
result.images.each_with_index do |image_data, i|
|
|
66
64
|
File.write("variation_#{i}.png", image_data)
|
|
@@ -72,28 +70,24 @@ end
|
|
|
72
70
|
### Design Exploration
|
|
73
71
|
|
|
74
72
|
```ruby
|
|
75
|
-
module
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
variation_strength 0.5 # Moderate differences
|
|
80
|
-
end
|
|
73
|
+
module Images
|
|
74
|
+
class DesignVariator < ApplicationImageVariator
|
|
75
|
+
count 6
|
|
76
|
+
variation_strength 0.5 # Moderate differences
|
|
81
77
|
end
|
|
82
78
|
end
|
|
83
79
|
|
|
84
80
|
# Generate design alternatives
|
|
85
|
-
result =
|
|
81
|
+
result = Images::DesignVariator.call(image: "concept.png")
|
|
86
82
|
```
|
|
87
83
|
|
|
88
84
|
### A/B Testing Assets
|
|
89
85
|
|
|
90
86
|
```ruby
|
|
91
|
-
module
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
variation_strength 0.3 # Similar but different
|
|
96
|
-
end
|
|
87
|
+
module Images
|
|
88
|
+
class MarketingVariator < ApplicationImageVariator
|
|
89
|
+
count 4
|
|
90
|
+
variation_strength 0.3 # Similar but different
|
|
97
91
|
end
|
|
98
92
|
end
|
|
99
93
|
```
|
|
@@ -101,13 +95,11 @@ end
|
|
|
101
95
|
### Avatar Options
|
|
102
96
|
|
|
103
97
|
```ruby
|
|
104
|
-
module
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
variation_strength 0.4
|
|
110
|
-
end
|
|
98
|
+
module Images
|
|
99
|
+
class AvatarVariator < ApplicationImageVariator
|
|
100
|
+
count 8
|
|
101
|
+
size "512x512"
|
|
102
|
+
variation_strength 0.4
|
|
111
103
|
end
|
|
112
104
|
end
|
|
113
105
|
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Audio Speakers
|
|
2
2
|
|
|
3
3
|
This directory contains text-to-speech (TTS) speakers. All speakers inherit from `ApplicationSpeaker`.
|
|
4
4
|
|
|
@@ -13,15 +13,13 @@ rails generate ruby_llm_agents:speaker Podcast --provider elevenlabs --voice Rac
|
|
|
13
13
|
|
|
14
14
|
Or create manually:
|
|
15
15
|
```ruby
|
|
16
|
-
module
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
output_format :mp3
|
|
24
|
-
end
|
|
16
|
+
module Audio
|
|
17
|
+
class NarratorSpeaker < ApplicationSpeaker
|
|
18
|
+
provider :openai
|
|
19
|
+
model "tts-1"
|
|
20
|
+
voice "nova"
|
|
21
|
+
speed 1.0
|
|
22
|
+
output_format :mp3
|
|
25
23
|
end
|
|
26
24
|
end
|
|
27
25
|
```
|
|
@@ -89,7 +87,7 @@ end
|
|
|
89
87
|
### Generate Speech
|
|
90
88
|
|
|
91
89
|
```ruby
|
|
92
|
-
result =
|
|
90
|
+
result = Audio::NarratorSpeaker.call(text: "Hello world")
|
|
93
91
|
|
|
94
92
|
result.audio # Binary audio data
|
|
95
93
|
result.format # :mp3
|
|
@@ -100,7 +98,7 @@ result.total_cost # Cost in USD
|
|
|
100
98
|
### Save to File
|
|
101
99
|
|
|
102
100
|
```ruby
|
|
103
|
-
result =
|
|
101
|
+
result = Audio::NarratorSpeaker.call(text: "Hello world")
|
|
104
102
|
result.save_to("output.mp3")
|
|
105
103
|
```
|
|
106
104
|
|
|
@@ -109,7 +107,7 @@ result.save_to("output.mp3")
|
|
|
109
107
|
For long text, stream chunks as they're generated:
|
|
110
108
|
|
|
111
109
|
```ruby
|
|
112
|
-
|
|
110
|
+
Audio::NarratorSpeaker.stream(text: long_article) do |chunk|
|
|
113
111
|
audio_player.play(chunk.audio)
|
|
114
112
|
end
|
|
115
113
|
```
|
|
@@ -117,7 +115,7 @@ end
|
|
|
117
115
|
### Override Settings at Runtime
|
|
118
116
|
|
|
119
117
|
```ruby
|
|
120
|
-
result =
|
|
118
|
+
result = Audio::NarratorSpeaker.call(
|
|
121
119
|
text: "Speak slowly and clearly",
|
|
122
120
|
voice: "onyx",
|
|
123
121
|
speed: 0.8
|
|
@@ -129,46 +127,42 @@ result = <%= @root_namespace %>::Audio::NarratorSpeaker.call(
|
|
|
129
127
|
### Article Narration
|
|
130
128
|
|
|
131
129
|
```ruby
|
|
132
|
-
module
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
pronounce 'TypeScript', 'type-script'
|
|
145
|
-
end
|
|
130
|
+
module Audio
|
|
131
|
+
class ArticleNarratorSpeaker < ApplicationSpeaker
|
|
132
|
+
provider :openai
|
|
133
|
+
model "tts-1-hd"
|
|
134
|
+
voice "fable"
|
|
135
|
+
speed 0.9
|
|
136
|
+
|
|
137
|
+
cache_for 30.days
|
|
138
|
+
|
|
139
|
+
lexicon do
|
|
140
|
+
pronounce 'JavaScript', 'java-script'
|
|
141
|
+
pronounce 'TypeScript', 'type-script'
|
|
146
142
|
end
|
|
147
143
|
end
|
|
148
144
|
end
|
|
149
145
|
|
|
150
146
|
# Usage
|
|
151
147
|
article = Article.find(params[:id])
|
|
152
|
-
result =
|
|
148
|
+
result = Audio::ArticleNarratorSpeaker.call(text: article.body)
|
|
153
149
|
result.save_to("public/audio/articles/#{article.id}.mp3")
|
|
154
150
|
```
|
|
155
151
|
|
|
156
152
|
### Voice Announcements
|
|
157
153
|
|
|
158
154
|
```ruby
|
|
159
|
-
module
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
output_format :mp3
|
|
166
|
-
end
|
|
155
|
+
module Audio
|
|
156
|
+
class AnnouncementSpeaker < ApplicationSpeaker
|
|
157
|
+
provider :openai
|
|
158
|
+
voice "nova"
|
|
159
|
+
speed 1.1
|
|
160
|
+
output_format :mp3
|
|
167
161
|
end
|
|
168
162
|
end
|
|
169
163
|
|
|
170
164
|
# Usage
|
|
171
|
-
|
|
165
|
+
Audio::AnnouncementSpeaker.call(
|
|
172
166
|
text: "Your order has been shipped!"
|
|
173
167
|
)
|
|
174
168
|
```
|
|
@@ -176,13 +170,11 @@ end
|
|
|
176
170
|
### Multilingual TTS
|
|
177
171
|
|
|
178
172
|
```ruby
|
|
179
|
-
module
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
voice "Rachel"
|
|
185
|
-
end
|
|
173
|
+
module Audio
|
|
174
|
+
class MultilingualSpeaker < ApplicationSpeaker
|
|
175
|
+
provider :elevenlabs
|
|
176
|
+
model "eleven_multilingual_v2"
|
|
177
|
+
voice "Rachel"
|
|
186
178
|
end
|
|
187
179
|
end
|
|
188
180
|
```
|
|
@@ -190,7 +182,7 @@ end
|
|
|
190
182
|
## Testing Speakers
|
|
191
183
|
|
|
192
184
|
```ruby
|
|
193
|
-
RSpec.describe
|
|
185
|
+
RSpec.describe Audio::NarratorSpeaker do
|
|
194
186
|
describe ".call" do
|
|
195
187
|
it "generates audio from text" do
|
|
196
188
|
result = described_class.call(text: "Hello world")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Agents Tools
|
|
2
2
|
|
|
3
3
|
This directory contains tools that agents can use to perform actions. Tools allow LLM agents to interact with external systems, APIs, databases, and more.
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ This directory contains tools that agents can use to perform actions. Tools allo
|
|
|
7
7
|
Tools use the RubyLLM tool interface. Create a class that includes `RubyLLM::Tool`:
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
|
-
module
|
|
10
|
+
module Agents
|
|
11
11
|
class SearchTool
|
|
12
12
|
include RubyLLM::Tool
|
|
13
13
|
|
|
@@ -68,7 +68,7 @@ end
|
|
|
68
68
|
Register tools in your agent:
|
|
69
69
|
|
|
70
70
|
```ruby
|
|
71
|
-
module
|
|
71
|
+
module Agents
|
|
72
72
|
class ResearchAgent < ApplicationAgent
|
|
73
73
|
model "gpt-4o"
|
|
74
74
|
|
|
@@ -97,7 +97,7 @@ end
|
|
|
97
97
|
### Database Query Tool
|
|
98
98
|
|
|
99
99
|
```ruby
|
|
100
|
-
module
|
|
100
|
+
module Agents
|
|
101
101
|
class CustomerLookupTool
|
|
102
102
|
include RubyLLM::Tool
|
|
103
103
|
|
|
@@ -129,7 +129,7 @@ end
|
|
|
129
129
|
### API Integration Tool
|
|
130
130
|
|
|
131
131
|
```ruby
|
|
132
|
-
module
|
|
132
|
+
module Agents
|
|
133
133
|
class WeatherTool
|
|
134
134
|
include RubyLLM::Tool
|
|
135
135
|
|
|
@@ -161,7 +161,7 @@ end
|
|
|
161
161
|
### Action Tool
|
|
162
162
|
|
|
163
163
|
```ruby
|
|
164
|
-
module
|
|
164
|
+
module Agents
|
|
165
165
|
class SendEmailTool
|
|
166
166
|
include RubyLLM::Tool
|
|
167
167
|
|
|
@@ -198,7 +198,7 @@ end
|
|
|
198
198
|
## Testing Tools
|
|
199
199
|
|
|
200
200
|
```ruby
|
|
201
|
-
RSpec.describe
|
|
201
|
+
RSpec.describe Agents::SearchTool do
|
|
202
202
|
describe "#execute" do
|
|
203
203
|
it "returns search results" do
|
|
204
204
|
tool = described_class.new
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Audio Transcribers
|
|
2
2
|
|
|
3
3
|
This directory contains audio transcription services. All transcribers inherit from `ApplicationTranscriber`.
|
|
4
4
|
|
|
@@ -13,14 +13,12 @@ rails generate ruby_llm_agents:transcriber Podcast --output_format srt
|
|
|
13
13
|
|
|
14
14
|
Or create manually:
|
|
15
15
|
```ruby
|
|
16
|
-
module
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
include_timestamps :segment
|
|
23
|
-
end
|
|
16
|
+
module Audio
|
|
17
|
+
class MeetingTranscriber < ApplicationTranscriber
|
|
18
|
+
model "whisper-1"
|
|
19
|
+
language "en"
|
|
20
|
+
output_format :text
|
|
21
|
+
include_timestamps :segment
|
|
24
22
|
end
|
|
25
23
|
end
|
|
26
24
|
```
|
|
@@ -85,7 +83,7 @@ end
|
|
|
85
83
|
### Basic Transcription
|
|
86
84
|
|
|
87
85
|
```ruby
|
|
88
|
-
result =
|
|
86
|
+
result = Audio::MeetingTranscriber.call(audio: "meeting.mp3")
|
|
89
87
|
|
|
90
88
|
result.text # The transcribed text
|
|
91
89
|
result.duration # Audio duration in seconds
|
|
@@ -96,20 +94,20 @@ result.total_cost # Cost in USD
|
|
|
96
94
|
### From File Path
|
|
97
95
|
|
|
98
96
|
```ruby
|
|
99
|
-
result =
|
|
97
|
+
result = Audio::MeetingTranscriber.call(audio: "/path/to/audio.mp3")
|
|
100
98
|
```
|
|
101
99
|
|
|
102
100
|
### From Binary Data
|
|
103
101
|
|
|
104
102
|
```ruby
|
|
105
103
|
audio_data = File.read("recording.wav", mode: "rb")
|
|
106
|
-
result =
|
|
104
|
+
result = Audio::MeetingTranscriber.call(audio: audio_data)
|
|
107
105
|
```
|
|
108
106
|
|
|
109
107
|
### From URL
|
|
110
108
|
|
|
111
109
|
```ruby
|
|
112
|
-
result =
|
|
110
|
+
result = Audio::MeetingTranscriber.call(
|
|
113
111
|
audio: "https://example.com/audio.mp3"
|
|
114
112
|
)
|
|
115
113
|
```
|
|
@@ -117,17 +115,15 @@ result = <%= @root_namespace %>::Audio::MeetingTranscriber.call(
|
|
|
117
115
|
### With Timestamps (SRT)
|
|
118
116
|
|
|
119
117
|
```ruby
|
|
120
|
-
module
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
include_timestamps :segment
|
|
126
|
-
end
|
|
118
|
+
module Audio
|
|
119
|
+
class SubtitleTranscriber < ApplicationTranscriber
|
|
120
|
+
model "whisper-1"
|
|
121
|
+
output_format :srt
|
|
122
|
+
include_timestamps :segment
|
|
127
123
|
end
|
|
128
124
|
end
|
|
129
125
|
|
|
130
|
-
result =
|
|
126
|
+
result = Audio::SubtitleTranscriber.call(audio: "video.mp4")
|
|
131
127
|
File.write("subtitles.srt", result.text)
|
|
132
128
|
```
|
|
133
129
|
|
|
@@ -136,23 +132,21 @@ File.write("subtitles.srt", result.text)
|
|
|
136
132
|
### Meeting Transcription
|
|
137
133
|
|
|
138
134
|
```ruby
|
|
139
|
-
module
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
.squeeze(' ')
|
|
155
|
-
end
|
|
135
|
+
module Audio
|
|
136
|
+
class MeetingTranscriber < ApplicationTranscriber
|
|
137
|
+
model "whisper-1"
|
|
138
|
+
language "en"
|
|
139
|
+
cache_for 90.days
|
|
140
|
+
|
|
141
|
+
def prompt
|
|
142
|
+
"Business meeting with technical discussions"
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def postprocess_text(text)
|
|
146
|
+
text
|
|
147
|
+
.gsub(/\bum\b/i, '')
|
|
148
|
+
.gsub(/\buh\b/i, '')
|
|
149
|
+
.squeeze(' ')
|
|
156
150
|
end
|
|
157
151
|
end
|
|
158
152
|
end
|
|
@@ -161,16 +155,14 @@ end
|
|
|
161
155
|
### Podcast Subtitles
|
|
162
156
|
|
|
163
157
|
```ruby
|
|
164
|
-
module
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
"Technology podcast discussing software development"
|
|
173
|
-
end
|
|
158
|
+
module Audio
|
|
159
|
+
class PodcastTranscriber < ApplicationTranscriber
|
|
160
|
+
model "whisper-1"
|
|
161
|
+
output_format :vtt
|
|
162
|
+
include_timestamps :segment
|
|
163
|
+
|
|
164
|
+
def prompt
|
|
165
|
+
"Technology podcast discussing software development"
|
|
174
166
|
end
|
|
175
167
|
end
|
|
176
168
|
end
|
|
@@ -179,20 +171,18 @@ end
|
|
|
179
171
|
### Voice Note Processing
|
|
180
172
|
|
|
181
173
|
```ruby
|
|
182
|
-
module
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
.squeeze(' ')
|
|
195
|
-
end
|
|
174
|
+
module Audio
|
|
175
|
+
class VoiceNoteTranscriber < ApplicationTranscriber
|
|
176
|
+
model "whisper-1"
|
|
177
|
+
output_format :json
|
|
178
|
+
|
|
179
|
+
def postprocess_text(text)
|
|
180
|
+
# Clean up casual speech
|
|
181
|
+
text
|
|
182
|
+
.gsub(/\byou know\b/i, '')
|
|
183
|
+
.gsub(/\bi mean\b/i, '')
|
|
184
|
+
.gsub(/\bkind of\b/i, '')
|
|
185
|
+
.squeeze(' ')
|
|
196
186
|
end
|
|
197
187
|
end
|
|
198
188
|
end
|
|
@@ -201,24 +191,22 @@ end
|
|
|
201
191
|
### Multilingual Transcription
|
|
202
192
|
|
|
203
193
|
```ruby
|
|
204
|
-
module
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
output_format :json
|
|
210
|
-
end
|
|
194
|
+
module Audio
|
|
195
|
+
class MultilingualTranscriber < ApplicationTranscriber
|
|
196
|
+
model "whisper-1"
|
|
197
|
+
# Leave language nil for auto-detection
|
|
198
|
+
output_format :json
|
|
211
199
|
end
|
|
212
200
|
end
|
|
213
201
|
|
|
214
|
-
result =
|
|
202
|
+
result = Audio::MultilingualTranscriber.call(audio: "spanish.mp3")
|
|
215
203
|
result.language # => "es"
|
|
216
204
|
```
|
|
217
205
|
|
|
218
206
|
## Testing Transcribers
|
|
219
207
|
|
|
220
208
|
```ruby
|
|
221
|
-
RSpec.describe
|
|
209
|
+
RSpec.describe Audio::MeetingTranscriber do
|
|
222
210
|
describe ".call" do
|
|
223
211
|
it "transcribes audio file" do
|
|
224
212
|
result = described_class.call(audio: fixture_file("sample.mp3"))
|