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,44 +1,42 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
module Image
|
|
3
|
+
module Images
|
|
5
4
|
<%- if class_name.include?("::") -%>
|
|
6
5
|
<%- class_name.split("::")[0..-2].each_with_index do |mod, i| -%>
|
|
7
|
-
<%= " " * (i +
|
|
6
|
+
<%= " " * (i + 1) %>module <%= mod %>
|
|
8
7
|
<%- end -%>
|
|
9
|
-
<%= " " *
|
|
8
|
+
<%= " " * class_name.split("::").length %>class <%= class_name.split("::").last %>BackgroundRemover < ApplicationBackgroundRemover
|
|
10
9
|
<%- else -%>
|
|
11
|
-
|
|
10
|
+
class <%= class_name %>BackgroundRemover < ApplicationBackgroundRemover
|
|
12
11
|
<%- end -%>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
# Model configuration
|
|
13
|
+
model "<%= options[:model] %>"
|
|
14
|
+
output_format :<%= options[:output_format] %>
|
|
16
15
|
<% if options[:refine_edges] -%>
|
|
17
|
-
|
|
16
|
+
refine_edges true
|
|
18
17
|
<% end -%>
|
|
19
18
|
<% if options[:alpha_matting] -%>
|
|
20
|
-
|
|
19
|
+
alpha_matting true
|
|
21
20
|
<% end -%>
|
|
22
21
|
<% if options[:return_mask] -%>
|
|
23
|
-
|
|
22
|
+
return_mask true
|
|
24
23
|
<% end -%>
|
|
25
24
|
<% if options[:cache] -%>
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
# Caching
|
|
27
|
+
cache_for <%= options[:cache] %>
|
|
29
28
|
<% end -%>
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
# Optional: Edge threshold
|
|
31
|
+
# edge_threshold 0.5
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
# Optional: Description
|
|
34
|
+
# description "Removes backgrounds from <%= class_name.downcase %> images"
|
|
36
35
|
<%- if class_name.include?("::") -%>
|
|
37
|
-
<%-
|
|
38
|
-
<%= " " * (class_name.split("::").length
|
|
36
|
+
<%- class_name.split("::").length.times do |i| -%>
|
|
37
|
+
<%= " " * (class_name.split("::").length - i) %>end
|
|
39
38
|
<%- end -%>
|
|
40
39
|
<%- else -%>
|
|
41
|
-
end
|
|
42
|
-
<%- end -%>
|
|
43
40
|
end
|
|
41
|
+
<%- end -%>
|
|
44
42
|
end
|
|
@@ -36,10 +36,21 @@ class CreateRubyLLMAgentsTenantBudgets < ActiveRecord::Migration<%= migration_ve
|
|
|
36
36
|
# Whether to inherit from global config for unset limits
|
|
37
37
|
t.boolean :inherit_global_defaults, default: true
|
|
38
38
|
|
|
39
|
+
# Polymorphic association to tenant model (e.g., Organization, Account)
|
|
40
|
+
# Allows direct association with ActiveRecord models using llm_tenant DSL
|
|
41
|
+
# Uses string type for tenant_record_id to support both integer and UUID primary keys
|
|
42
|
+
t.string :tenant_record_type
|
|
43
|
+
t.string :tenant_record_id
|
|
44
|
+
|
|
39
45
|
t.timestamps
|
|
40
46
|
end
|
|
41
47
|
|
|
42
48
|
# Ensure unique tenant IDs
|
|
43
49
|
add_index :ruby_llm_agents_tenant_budgets, :tenant_id, unique: true
|
|
50
|
+
|
|
51
|
+
# Index for polymorphic tenant record lookup
|
|
52
|
+
add_index :ruby_llm_agents_tenant_budgets,
|
|
53
|
+
[:tenant_record_type, :tenant_record_id],
|
|
54
|
+
name: "index_tenant_budgets_on_tenant_record"
|
|
44
55
|
end
|
|
45
56
|
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Migration to create the tenants table for multi-tenancy support
|
|
4
|
+
#
|
|
5
|
+
# This table stores tenant configuration including:
|
|
6
|
+
# - Budget limits (cost, tokens, executions)
|
|
7
|
+
# - Enforcement mode (none, soft, hard)
|
|
8
|
+
# - Polymorphic link to user's tenant model
|
|
9
|
+
#
|
|
10
|
+
# Run with: rails db:migrate
|
|
11
|
+
class CreateRubyLLMAgentsTenants < ActiveRecord::Migration<%= migration_version %>
|
|
12
|
+
def change
|
|
13
|
+
create_table :ruby_llm_agents_tenants do |t|
|
|
14
|
+
# Identity
|
|
15
|
+
t.string :tenant_id, null: false
|
|
16
|
+
t.string :name
|
|
17
|
+
|
|
18
|
+
# Polymorphic association to user's tenant model (e.g., Organization, Account)
|
|
19
|
+
# Uses string type for tenant_record_id to support both integer and UUID primary keys
|
|
20
|
+
t.string :tenant_record_type
|
|
21
|
+
t.string :tenant_record_id
|
|
22
|
+
|
|
23
|
+
# Cost limits (in USD, 6 decimal precision)
|
|
24
|
+
t.decimal :daily_limit, precision: 12, scale: 6
|
|
25
|
+
t.decimal :monthly_limit, precision: 12, scale: 6
|
|
26
|
+
|
|
27
|
+
# Token limits
|
|
28
|
+
t.bigint :daily_token_limit
|
|
29
|
+
t.bigint :monthly_token_limit
|
|
30
|
+
|
|
31
|
+
# Execution/call limits
|
|
32
|
+
t.bigint :daily_execution_limit
|
|
33
|
+
t.bigint :monthly_execution_limit
|
|
34
|
+
|
|
35
|
+
# Per-agent limits (JSON hash)
|
|
36
|
+
# Format: { "AgentName" => limit_value }
|
|
37
|
+
t.json :per_agent_daily, null: false, default: {}
|
|
38
|
+
t.json :per_agent_monthly, null: false, default: {}
|
|
39
|
+
|
|
40
|
+
# Enforcement mode: "none", "soft", or "hard"
|
|
41
|
+
# - none: no enforcement, only tracking
|
|
42
|
+
# - soft: log warnings when limits exceeded
|
|
43
|
+
# - hard: block execution when limits exceeded
|
|
44
|
+
t.string :enforcement, default: "soft"
|
|
45
|
+
|
|
46
|
+
# Whether to inherit from global config for unset limits
|
|
47
|
+
t.boolean :inherit_global_defaults, default: true
|
|
48
|
+
|
|
49
|
+
# Status (for soft-delete/disable)
|
|
50
|
+
t.boolean :active, default: true
|
|
51
|
+
|
|
52
|
+
# Extensible metadata (JSON)
|
|
53
|
+
t.json :metadata, null: false, default: {}
|
|
54
|
+
|
|
55
|
+
t.timestamps
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Ensure unique tenant IDs
|
|
59
|
+
add_index :ruby_llm_agents_tenants, :tenant_id, unique: true
|
|
60
|
+
|
|
61
|
+
# Index for name lookups
|
|
62
|
+
add_index :ruby_llm_agents_tenants, :name
|
|
63
|
+
|
|
64
|
+
# Index for active/inactive filtering
|
|
65
|
+
add_index :ruby_llm_agents_tenants, :active
|
|
66
|
+
|
|
67
|
+
# Index for polymorphic tenant record lookup
|
|
68
|
+
add_index :ruby_llm_agents_tenants,
|
|
69
|
+
[:tenant_record_type, :tenant_record_id],
|
|
70
|
+
name: "index_tenants_on_tenant_record"
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -1,41 +1,39 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
module Text
|
|
3
|
+
module Embedders
|
|
5
4
|
<%- if class_name.include?("::") -%>
|
|
6
5
|
<%- class_name.split("::")[0..-2].each_with_index do |mod, i| -%>
|
|
7
|
-
<%= " " * (i +
|
|
6
|
+
<%= " " * (i + 1) %>module <%= mod %>
|
|
8
7
|
<%- end -%>
|
|
9
|
-
<%= " " *
|
|
8
|
+
<%= " " * class_name.split("::").length %>class <%= class_name.split("::").last %>Embedder < ApplicationEmbedder
|
|
10
9
|
<%- else -%>
|
|
11
|
-
|
|
10
|
+
class <%= class_name %>Embedder < ApplicationEmbedder
|
|
12
11
|
<%- end -%>
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
# Model configuration
|
|
13
|
+
model "<%= options[:model] %>"
|
|
15
14
|
<% if options[:dimensions] -%>
|
|
16
|
-
|
|
15
|
+
dimensions <%= options[:dimensions] %>
|
|
17
16
|
<% end -%>
|
|
18
17
|
<% if options[:batch_size] != 100 -%>
|
|
19
|
-
|
|
18
|
+
batch_size <%= options[:batch_size] %>
|
|
20
19
|
<% end -%>
|
|
21
20
|
<% if options[:cache] -%>
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
# Caching
|
|
23
|
+
cache_for <%= options[:cache] %>
|
|
25
24
|
<% end -%>
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
# Optional: Custom preprocessing
|
|
27
|
+
# Override this method to normalize/clean text before embedding
|
|
28
|
+
#
|
|
29
|
+
# def preprocess(text)
|
|
30
|
+
# text.strip.downcase.gsub(/\s+/, ' ')
|
|
31
|
+
# end
|
|
33
32
|
<%- if class_name.include?("::") -%>
|
|
34
|
-
<%-
|
|
35
|
-
<%= " " * (class_name.split("::").length
|
|
33
|
+
<%- class_name.split("::").length.times do |i| -%>
|
|
34
|
+
<%= " " * (class_name.split("::").length - i) %>end
|
|
36
35
|
<%- end -%>
|
|
37
36
|
<%- else -%>
|
|
38
|
-
end
|
|
39
|
-
<%- end -%>
|
|
40
37
|
end
|
|
38
|
+
<%- end -%>
|
|
41
39
|
end
|
|
@@ -1,45 +1,43 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
module Image
|
|
3
|
+
module Images
|
|
5
4
|
<%- if class_name.include?("::") -%>
|
|
6
5
|
<%- class_name.split("::")[0..-2].each_with_index do |mod, i| -%>
|
|
7
|
-
<%= " " * (i +
|
|
6
|
+
<%= " " * (i + 1) %>module <%= mod %>
|
|
8
7
|
<%- end -%>
|
|
9
|
-
<%= " " *
|
|
8
|
+
<%= " " * class_name.split("::").length %>class <%= class_name.split("::").last %>Analyzer < ApplicationImageAnalyzer
|
|
10
9
|
<%- else -%>
|
|
11
|
-
|
|
10
|
+
class <%= class_name %>Analyzer < ApplicationImageAnalyzer
|
|
12
11
|
<%- end -%>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
# Model configuration
|
|
13
|
+
model "<%= options[:model] %>"
|
|
14
|
+
analysis_type :<%= options[:analysis_type] %>
|
|
16
15
|
<% if options[:extract_colors] -%>
|
|
17
|
-
|
|
16
|
+
extract_colors true
|
|
18
17
|
<% end -%>
|
|
19
18
|
<% if options[:detect_objects] -%>
|
|
20
|
-
|
|
19
|
+
detect_objects true
|
|
21
20
|
<% end -%>
|
|
22
21
|
<% if options[:extract_text] -%>
|
|
23
|
-
|
|
22
|
+
extract_text true
|
|
24
23
|
<% end -%>
|
|
25
|
-
|
|
24
|
+
max_tags <%= options[:max_tags] %>
|
|
26
25
|
<% if options[:cache] -%>
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
# Caching
|
|
28
|
+
cache_for <%= options[:cache] %>
|
|
30
29
|
<% end -%>
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
# Optional: Custom analysis prompt
|
|
32
|
+
# prompt "Analyze this image and describe..."
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
# Optional: Description
|
|
35
|
+
# description "Analyzes <%= class_name.downcase %> images"
|
|
37
36
|
<%- if class_name.include?("::") -%>
|
|
38
|
-
<%-
|
|
39
|
-
<%= " " * (class_name.split("::").length
|
|
37
|
+
<%- class_name.split("::").length.times do |i| -%>
|
|
38
|
+
<%= " " * (class_name.split("::").length - i) %>end
|
|
40
39
|
<%- end -%>
|
|
41
40
|
<%- else -%>
|
|
42
|
-
end
|
|
43
|
-
<%- end -%>
|
|
44
41
|
end
|
|
42
|
+
<%- end -%>
|
|
45
43
|
end
|
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
module Image
|
|
3
|
+
module Images
|
|
5
4
|
<%- if class_name.include?("::") -%>
|
|
6
5
|
<%- class_name.split("::")[0..-2].each_with_index do |mod, i| -%>
|
|
7
|
-
<%= " " * (i +
|
|
6
|
+
<%= " " * (i + 1) %>module <%= mod %>
|
|
8
7
|
<%- end -%>
|
|
9
|
-
<%= " " *
|
|
8
|
+
<%= " " * class_name.split("::").length %>class <%= class_name.split("::").last %>Editor < ApplicationImageEditor
|
|
10
9
|
<%- else -%>
|
|
11
|
-
|
|
10
|
+
class <%= class_name %>Editor < ApplicationImageEditor
|
|
12
11
|
<%- end -%>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
# Model configuration
|
|
13
|
+
model "<%= options[:model] %>"
|
|
14
|
+
size "<%= options[:size] %>"
|
|
16
15
|
<% if options[:content_policy] != "standard" -%>
|
|
17
|
-
|
|
16
|
+
content_policy :<%= options[:content_policy] %>
|
|
18
17
|
<% end -%>
|
|
19
18
|
<% if options[:cache] -%>
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
# Caching
|
|
21
|
+
cache_for <%= options[:cache] %>
|
|
23
22
|
<% end -%>
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
# Optional: Description
|
|
25
|
+
# description "Edits <%= class_name.downcase %> images"
|
|
27
26
|
<%- if class_name.include?("::") -%>
|
|
28
|
-
<%-
|
|
29
|
-
<%= " " * (class_name.split("::").length
|
|
27
|
+
<%- class_name.split("::").length.times do |i| -%>
|
|
28
|
+
<%= " " * (class_name.split("::").length - i) %>end
|
|
30
29
|
<%- end -%>
|
|
31
30
|
<%- else -%>
|
|
32
|
-
end
|
|
33
|
-
<%- end -%>
|
|
34
31
|
end
|
|
32
|
+
<%- end -%>
|
|
35
33
|
end
|
|
@@ -1,47 +1,45 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
module Image
|
|
3
|
+
module Images
|
|
5
4
|
<%- if class_name.include?("::") -%>
|
|
6
5
|
<%- class_name.split("::")[0..-2].each_with_index do |mod, i| -%>
|
|
7
|
-
<%= " " * (i +
|
|
6
|
+
<%= " " * (i + 1) %>module <%= mod %>
|
|
8
7
|
<%- end -%>
|
|
9
|
-
<%= " " *
|
|
8
|
+
<%= " " * class_name.split("::").length %>class <%= class_name.split("::").last %>Generator < ApplicationImageGenerator
|
|
10
9
|
<%- else -%>
|
|
11
|
-
|
|
10
|
+
class <%= class_name %>Generator < ApplicationImageGenerator
|
|
12
11
|
<%- end -%>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
# Model configuration
|
|
13
|
+
model "<%= options[:model] %>"
|
|
14
|
+
size "<%= options[:size] %>"
|
|
15
|
+
quality "<%= options[:quality] %>"
|
|
16
|
+
style "<%= options[:style] %>"
|
|
18
17
|
<% if options[:content_policy] != "standard" -%>
|
|
19
|
-
|
|
18
|
+
content_policy :<%= options[:content_policy] %>
|
|
20
19
|
<% end -%>
|
|
21
20
|
<% if options[:cache] -%>
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
# Caching
|
|
23
|
+
cache_for <%= options[:cache] %>
|
|
25
24
|
<% end -%>
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
# Optional: Add a prompt template
|
|
27
|
+
# template "Professional {prompt}, high quality, detailed"
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
# Optional: Add negative prompts (for models that support it)
|
|
30
|
+
# negative_prompt "blurry, low quality, distorted"
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
# Optional: Custom preprocessing
|
|
33
|
+
# Override this method to modify prompts before generation
|
|
34
|
+
#
|
|
35
|
+
# def preprocess_prompt(prompt)
|
|
36
|
+
# "#{prompt}, professional quality"
|
|
37
|
+
# end
|
|
39
38
|
<%- if class_name.include?("::") -%>
|
|
40
|
-
<%-
|
|
41
|
-
<%= " " * (class_name.split("::").length
|
|
39
|
+
<%- class_name.split("::").length.times do |i| -%>
|
|
40
|
+
<%= " " * (class_name.split("::").length - i) %>end
|
|
42
41
|
<%- end -%>
|
|
43
42
|
<%- else -%>
|
|
44
|
-
end
|
|
45
|
-
<%- end -%>
|
|
46
43
|
end
|
|
44
|
+
<%- end -%>
|
|
47
45
|
end
|
|
@@ -1,50 +1,48 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
module Image
|
|
3
|
+
module Images
|
|
5
4
|
<%- if class_name.include?("::") -%>
|
|
6
5
|
<%- class_name.split("::")[0..-2].each_with_index do |mod, i| -%>
|
|
7
|
-
<%= " " * (i +
|
|
6
|
+
<%= " " * (i + 1) %>module <%= mod %>
|
|
8
7
|
<%- end -%>
|
|
9
|
-
<%= " " *
|
|
8
|
+
<%= " " * class_name.split("::").length %>class <%= class_name.split("::").last %>Pipeline < ApplicationImagePipeline
|
|
10
9
|
<%- else -%>
|
|
11
|
-
|
|
10
|
+
class <%= class_name %>Pipeline < ApplicationImagePipeline
|
|
12
11
|
<%- end -%>
|
|
13
|
-
|
|
12
|
+
# Pipeline steps
|
|
14
13
|
<%- parsed_steps.each do |step| -%>
|
|
15
14
|
<%- case step -%>
|
|
16
15
|
<%- when :generate -%>
|
|
17
|
-
|
|
16
|
+
step :<%= step %>, generator: <%= class_name %>Generator
|
|
18
17
|
<%- when :upscale -%>
|
|
19
|
-
|
|
18
|
+
step :<%= step %>, upscaler: <%= class_name %>Upscaler
|
|
20
19
|
<%- when :transform -%>
|
|
21
|
-
|
|
20
|
+
step :<%= step %>, transformer: <%= class_name %>Transformer
|
|
22
21
|
<%- when :analyze -%>
|
|
23
|
-
|
|
22
|
+
step :<%= step %>, analyzer: <%= class_name %>Analyzer
|
|
24
23
|
<%- when :remove_background -%>
|
|
25
|
-
|
|
24
|
+
step :<%= step %>, remover: <%= class_name %>BackgroundRemover
|
|
26
25
|
<%- else -%>
|
|
27
|
-
|
|
26
|
+
# step :<%= step %>, ...: <%= class_name %><%= step.to_s.camelize %>
|
|
28
27
|
<%- end -%>
|
|
29
28
|
<%- end -%>
|
|
30
29
|
<%- if options[:stop_on_error] == false -%>
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
stop_on_error false
|
|
33
32
|
<%- end -%>
|
|
34
33
|
<% if options[:cache] -%>
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
# Caching
|
|
36
|
+
cache_for <%= options[:cache] %>
|
|
38
37
|
<% end -%>
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
description "<%= class_name %> image processing pipeline"
|
|
40
|
+
version "1.0"
|
|
42
41
|
<%- if class_name.include?("::") -%>
|
|
43
|
-
<%-
|
|
44
|
-
<%= " " * (class_name.split("::").length
|
|
42
|
+
<%- class_name.split("::").length.times do |i| -%>
|
|
43
|
+
<%= " " * (class_name.split("::").length - i) %>end
|
|
45
44
|
<%- end -%>
|
|
46
45
|
<%- else -%>
|
|
47
|
-
end
|
|
48
|
-
<%- end -%>
|
|
49
46
|
end
|
|
47
|
+
<%- end -%>
|
|
50
48
|
end
|
|
@@ -1,44 +1,42 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
module Image
|
|
3
|
+
module Images
|
|
5
4
|
<%- if class_name.include?("::") -%>
|
|
6
5
|
<%- class_name.split("::")[0..-2].each_with_index do |mod, i| -%>
|
|
7
|
-
<%= " " * (i +
|
|
6
|
+
<%= " " * (i + 1) %>module <%= mod %>
|
|
8
7
|
<%- end -%>
|
|
9
|
-
<%= " " *
|
|
8
|
+
<%= " " * class_name.split("::").length %>class <%= class_name.split("::").last %>Transformer < ApplicationImageTransformer
|
|
10
9
|
<%- else -%>
|
|
11
|
-
|
|
10
|
+
class <%= class_name %>Transformer < ApplicationImageTransformer
|
|
12
11
|
<%- end -%>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
# Model configuration
|
|
13
|
+
model "<%= options[:model] %>"
|
|
14
|
+
size "<%= options[:size] %>"
|
|
15
|
+
strength <%= options[:strength] %>
|
|
17
16
|
<% if options[:content_policy] != "standard" -%>
|
|
18
|
-
|
|
17
|
+
content_policy :<%= options[:content_policy] %>
|
|
19
18
|
<% end -%>
|
|
20
19
|
<% if options[:template] -%>
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
# Prompt template
|
|
22
|
+
template "<%= options[:template] %>"
|
|
24
23
|
<% end -%>
|
|
25
24
|
<% if options[:cache] -%>
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
# Caching
|
|
27
|
+
cache_for <%= options[:cache] %>
|
|
29
28
|
<% end -%>
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
# Optional: Negative prompts
|
|
31
|
+
# negative_prompt "blurry, low quality, distorted"
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
# Optional: Description
|
|
34
|
+
# description "Transforms images into <%= class_name.downcase %> style"
|
|
36
35
|
<%- if class_name.include?("::") -%>
|
|
37
|
-
<%-
|
|
38
|
-
<%= " " * (class_name.split("::").length
|
|
36
|
+
<%- class_name.split("::").length.times do |i| -%>
|
|
37
|
+
<%= " " * (class_name.split("::").length - i) %>end
|
|
39
38
|
<%- end -%>
|
|
40
39
|
<%- else -%>
|
|
41
|
-
end
|
|
42
|
-
<%- end -%>
|
|
43
40
|
end
|
|
41
|
+
<%- end -%>
|
|
44
42
|
end
|
|
@@ -1,38 +1,36 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
module Image
|
|
3
|
+
module Images
|
|
5
4
|
<%- if class_name.include?("::") -%>
|
|
6
5
|
<%- class_name.split("::")[0..-2].each_with_index do |mod, i| -%>
|
|
7
|
-
<%= " " * (i +
|
|
6
|
+
<%= " " * (i + 1) %>module <%= mod %>
|
|
8
7
|
<%- end -%>
|
|
9
|
-
<%= " " *
|
|
8
|
+
<%= " " * class_name.split("::").length %>class <%= class_name.split("::").last %>Upscaler < ApplicationImageUpscaler
|
|
10
9
|
<%- else -%>
|
|
11
|
-
|
|
10
|
+
class <%= class_name %>Upscaler < ApplicationImageUpscaler
|
|
12
11
|
<%- end -%>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
# Model configuration
|
|
13
|
+
model "<%= options[:model] %>"
|
|
14
|
+
scale <%= options[:scale] %>
|
|
16
15
|
<% if options[:face_enhance] -%>
|
|
17
|
-
|
|
16
|
+
face_enhance true
|
|
18
17
|
<% end -%>
|
|
19
18
|
<% if options[:cache] -%>
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
# Caching
|
|
21
|
+
cache_for <%= options[:cache] %>
|
|
23
22
|
<% end -%>
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
# Optional: Denoise strength (0.0-1.0)
|
|
25
|
+
# denoise_strength 0.5
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
# Optional: Description
|
|
28
|
+
# description "Upscales <%= class_name.downcase %> images"
|
|
30
29
|
<%- if class_name.include?("::") -%>
|
|
31
|
-
<%-
|
|
32
|
-
<%= " " * (class_name.split("::").length
|
|
30
|
+
<%- class_name.split("::").length.times do |i| -%>
|
|
31
|
+
<%= " " * (class_name.split("::").length - i) %>end
|
|
33
32
|
<%- end -%>
|
|
34
33
|
<%- else -%>
|
|
35
|
-
end
|
|
36
|
-
<%- end -%>
|
|
37
34
|
end
|
|
35
|
+
<%- end -%>
|
|
38
36
|
end
|
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
4
|
-
module Image
|
|
3
|
+
module Images
|
|
5
4
|
<%- if class_name.include?("::") -%>
|
|
6
5
|
<%- class_name.split("::")[0..-2].each_with_index do |mod, i| -%>
|
|
7
|
-
<%= " " * (i +
|
|
6
|
+
<%= " " * (i + 1) %>module <%= mod %>
|
|
8
7
|
<%- end -%>
|
|
9
|
-
<%= " " *
|
|
8
|
+
<%= " " * class_name.split("::").length %>class <%= class_name.split("::").last %>Variator < ApplicationImageVariator
|
|
10
9
|
<%- else -%>
|
|
11
|
-
|
|
10
|
+
class <%= class_name %>Variator < ApplicationImageVariator
|
|
12
11
|
<%- end -%>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
# Model configuration
|
|
13
|
+
model "<%= options[:model] %>"
|
|
14
|
+
size "<%= options[:size] %>"
|
|
15
|
+
variation_strength <%= options[:variation_strength] %>
|
|
17
16
|
<% if options[:cache] -%>
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
# Caching
|
|
19
|
+
cache_for <%= options[:cache] %>
|
|
21
20
|
<% end -%>
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
# Optional: Description
|
|
23
|
+
# description "Creates variations of <%= class_name.downcase %> images"
|
|
25
24
|
<%- if class_name.include?("::") -%>
|
|
26
|
-
<%-
|
|
27
|
-
<%= " " * (class_name.split("::").length
|
|
25
|
+
<%- class_name.split("::").length.times do |i| -%>
|
|
26
|
+
<%= " " * (class_name.split("::").length - i) %>end
|
|
28
27
|
<%- end -%>
|
|
29
28
|
<%- else -%>
|
|
30
|
-
end
|
|
31
|
-
<%- end -%>
|
|
32
29
|
end
|
|
30
|
+
<%- end -%>
|
|
33
31
|
end
|