meta_workflows 0.9.13 → 0.9.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f4d3efc62028f81a371bad517bc54f92527ac1b734b2ba2591e29b3ad9c2964
4
- data.tar.gz: 7c24d71b9471737fa4fae693c1336229d0dbde16a95bd16fea5127ce847d2c7a
3
+ metadata.gz: 87c0ac3e466398e6e54347b2449fa4c6fd04ff1c212f47c236df34d2bccd3ffe
4
+ data.tar.gz: '08d0adfaa0e80315f52e3063dacb23735d805987a3e992357a4959aba50a853c'
5
5
  SHA512:
6
- metadata.gz: b4a3cfeda85bc79adaf82267bbf952c9ff8c5fc0bd9398ae4279efb916b405e6a3a2f1e3baedb7e45203222a233361a831f660dc471a1dfa9cc08d5c5def17f3
7
- data.tar.gz: 0b1065fa9f22c1f74b301f4196e9b2a250eeac081ffe243a2b97348041434579b28cd1150dc31b393a83665641b44f28ecc1985dedbb9c489fc9c5d2e63ca153
6
+ metadata.gz: 4a230b0d2dbd5896346f74b36436fb451f271dececd239321d891dd5681db1b9666a007fb878fdb3ecddc71acaed0b0972fe6b96e3ff6626b8f0e5b8a5febeb5
7
+ data.tar.gz: 8a7c331f06aebb0c53b7061acc088c10acbec3fbac9ad9a4a5e45e559dc8bd06cec2db7873cf1d5e5f69a1e4b263490ae3da1321cfcc5be059ae265d0a51ef97
data/CHANGELOG.md CHANGED
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
16
16
  - ViewComponent support for UI components
17
17
  - Turbo and Stimulus integration for frontend interactivity
18
18
  - PostgreSQL database support following host application patterns
19
+ - Per-step model configuration in workflow YAML files for optimized AI model selection (NXT-6891)
19
20
 
20
21
  ### Changed
21
22
  - Extracted from course-builder monolith into standalone engine
data/README.md CHANGED
@@ -60,6 +60,7 @@ MetaWorkflows supports several action types for different workflow needs:
60
60
  - Requires `prompt_id` configuration
61
61
  - Supports tool calling and complex reasoning tasks
62
62
  - Output is extracted and stored for subsequent steps
63
+ - Supports optional `model` parameter for step-specific AI model configuration
63
64
 
64
65
  ### `human`
65
66
  - Presents UI for human interaction and input collection
@@ -84,6 +85,38 @@ MetaWorkflows supports several action types for different workflow needs:
84
85
  - Marks workflow as complete
85
86
  - Requires `redirect_path` or `redirect_method` configuration
86
87
 
88
+ ## Model Configuration
89
+
90
+ MetaWorkflows supports configuring different AI models for different workflow steps, allowing you to optimize performance and cost by using the most appropriate model for each task.
91
+
92
+ ### Per-Step Model Configuration
93
+
94
+ You can specify a different AI model for any llm action by adding a `model` parameter to the step configuration:
95
+
96
+ ```yaml
97
+ steps:
98
+ - name: "simple_task"
99
+ action: "agent"
100
+ prompt_id: "simple_prompt"
101
+ model: "your-preferred-model-id" # Use appropriate model from RubyLLM documentation
102
+
103
+ - name: "complex_analysis"
104
+ action: "agent"
105
+ prompt_id: "analysis_prompt"
106
+ model: "your-preferred-model-id" # Use appropriate model from RubyLLM documentation
107
+ ```
108
+
109
+ ### Supported Models
110
+
111
+ The system supports any model identifier that is compatible with your `ruby_conversations` configuration. For the complete list of available models, refer to the [RubyLLM Available Models documentation](https://rubyllm.com/guides/available-models).
112
+
113
+
114
+ Use the exact model ID from the documentation when configuring your workflow steps. For AWS Bedrock models, look for model IDs like `anthropic.claude-3-5-sonnet-20241022-v2:0` or `anthropic.claude-3-haiku-20240307-v1:0` in the Bedrock section.
115
+
116
+ ### Fallback Behavior
117
+
118
+ - If no `model` is specified for a step, the system uses `RubyConversations.configuration.default_llm_model`
119
+
87
120
  ## Requirements
88
121
 
89
122
  - **Rails 7.2+**: Compatible with modern Rails applications
@@ -185,17 +218,6 @@ Rails.application.routes.draw do
185
218
  end
186
219
  ```
187
220
 
188
- ### 5. Configure Sidekiq
189
-
190
- Ensure Sidekiq is configured in your application for background job processing:
191
-
192
- ```ruby
193
- # config/application.rb or config/initializers/sidekiq.rb
194
- require 'sidekiq'
195
-
196
- # Configure Redis connection and other Sidekiq settings
197
- ```
198
-
199
221
  ## Usage
200
222
 
201
223
  ### Creating Workflow Definitions
@@ -210,6 +232,7 @@ steps:
210
232
  - name: "initial_generation"
211
233
  action: "agent"
212
234
  prompt_id: "generation_prompt"
235
+ model: "your-preferred-model-id" # Use appropriate model from RubyLLM documentation
213
236
  step_progress:
214
237
  - "Analyzing input parameters..."
215
238
  - "Generating initial content..."
@@ -282,20 +305,6 @@ class YourController < ApplicationController
282
305
  end
283
306
  ```
284
307
 
285
- #### Direct Job Execution
286
-
287
- ```ruby
288
- # Start a workflow
289
- MetaWorkflows::MetaWorkflowJob.perform_later(
290
- 'example_workflow',
291
- context: {
292
- user_id: 1,
293
- record_id: 123,
294
- record_type: 'YourModel'
295
- }
296
- )
297
- ```
298
-
299
308
  ### Using Meta Workflow UI Components
300
309
 
301
310
  Instead of creating custom views from scratch, use the provided Meta Workflow partials:
@@ -384,8 +393,7 @@ The dummy app demonstrates MetaWorkflows integration with:
384
393
  - User authentication (Devise)
385
394
  - Post and Comment models with associations
386
395
  - Complete CRUD operations
387
- - MetaWorkflows engine mounted at `/meta_workflows`
388
- - StrongMind Identity SSO integration
396
+ - MetaWorkflows engine mounted at `/meta_workflows_engine`
389
397
 
390
398
  ## Extending the System
391
399
 
@@ -473,19 +481,7 @@ To add a new action type:
473
481
  - Provide meaningful progress messages
474
482
  - Handle error cases gracefully
475
483
  - Use `record_update` steps to persist intermediate workflow results
476
-
477
- ### Performance
478
- - Use background jobs for long-running processes
479
- - Implement appropriate caching strategies
480
- - Monitor workflow execution times
481
- - Set reasonable timeouts for LLM interactions
482
- - Use bulk operations in collection creators when possible
483
-
484
- ### UI/UX Considerations
485
- - Use the provided meta partials for consistent UI
486
- - Provide meaningful step progress messages in workflow definitions
487
- - Ensure proper Turbo Stream configuration for real-time updates
488
- - Handle edge cases and error states appropriately
484
+ - Choose appropriate AI models for each step based on task complexity and cost considerations
489
485
 
490
486
  ## Architecture Details
491
487
 
@@ -496,32 +492,6 @@ To add a new action type:
496
492
  - Models use engine-specific associations and validations
497
493
  - Services organized under `Services::MetaWorkflows::` namespace
498
494
 
499
- ### Database Compatibility
500
- - Migration files include `table_exists?` checks to prevent conflicts
501
- - Exact schema compatibility maintained with existing applications
502
- - Proper foreign key references and indexes included
503
- - Migration timestamps ordered correctly for dependency resolution
504
-
505
- ## Contributing
506
-
507
- Bug reports and pull requests are welcome on GitHub at https://github.com/strongmind/meta_workflows.
508
-
509
- For development contributions:
510
- 1. Fork the repository
511
- 2. Create a feature branch
512
- 3. Add comprehensive tests
513
- 4. Follow the established code patterns and namespacing
514
- 5. Update documentation as needed
515
- 6. Submit a pull request
516
-
517
- ## Documentation
518
-
519
- For detailed information about the MetaWorkflows system:
520
- - [Setup Guide](https://strongmind.atlassian.net/wiki/spaces/MW/pages/3929833507) - Configuration and workflow setup
521
-
522
- ## License
523
-
524
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
525
495
 
526
496
  ## Styling Setup
527
497
 
@@ -631,3 +601,8 @@ end
631
601
  - The main content area (Alpha tray) is always visible and holds your page content.
632
602
 
633
603
  For more advanced usage or to contribute improvements, see the tray logic in `TrayConfigurable` and the engine layout file.
604
+
605
+ ## Confluence Documentation
606
+
607
+ For detailed information about the MetaWorkflows system:
608
+ - [Setup Guide](https://strongmind.atlassian.net/wiki/spaces/MW/pages/3929833507) - Configuration and workflow setup
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RecipeAccessible
4
+ extend ActiveSupport::Concern
5
+
6
+ def step_progress(step)
7
+ recipe&.dig('steps', step, 'step_progress')
8
+ end
9
+
10
+ def prompt_id(step)
11
+ recipe&.dig('steps', step, 'prompt_id')
12
+ end
13
+
14
+ def step_data(step)
15
+ recipe&.dig('steps', step)
16
+ end
17
+
18
+ def step_output(step)
19
+ recipe&.dig('steps', step, 'output')
20
+ end
21
+
22
+ def step_repetitions(step)
23
+ recipe&.dig('steps', step, 'repetitions')
24
+ end
25
+
26
+ def total_steps
27
+ recipe&.dig('steps')&.size || 0
28
+ end
29
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module MetaWorkflows
4
4
  class Workflow < ApplicationRecord
5
+ include RecipeAccessible
6
+
5
7
  validates :name, presence: true, uniqueness: true
6
8
  validates :recipe, presence: true
7
9
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  module MetaWorkflows
4
4
  class WorkflowExecution < ApplicationRecord
5
+ include RecipeAccessible
6
+
5
7
  belongs_to :workflow, class_name: 'MetaWorkflows::Workflow'
6
8
  belongs_to :record, polymorphic: true
7
9
  has_many :workflow_steps, dependent: :destroy, class_name: 'MetaWorkflows::WorkflowStep'
@@ -18,29 +20,5 @@ module MetaWorkflows
18
20
  def increment_step
19
21
  update(current_step: current_step + 1)
20
22
  end
21
-
22
- def step_progress(step)
23
- recipe&.dig('steps', step, 'step_progress')
24
- end
25
-
26
- def prompt_id(step)
27
- recipe&.dig('steps', step, 'prompt_id')
28
- end
29
-
30
- def step_data(step)
31
- recipe&.dig('steps', step)
32
- end
33
-
34
- def step_output(step)
35
- recipe&.dig('steps', step, 'output')
36
- end
37
-
38
- def step_repetitions(step)
39
- recipe&.dig('steps', step, 'repetitions')
40
- end
41
-
42
- def total_steps
43
- recipe&.dig('steps')&.size || 0
44
- end
45
23
  end
46
24
  end
@@ -3,7 +3,7 @@
3
3
  module MetaWorkflows
4
4
  MAJOR = 0
5
5
  MINOR = 9
6
- PATCH = 13 # this is automatically incremented by the build process
6
+ PATCH = 14 # this is automatically incremented by the build process
7
7
 
8
8
  VERSION = "#{MetaWorkflows::MAJOR}.#{MetaWorkflows::MINOR}.#{MetaWorkflows::PATCH}".freeze
9
9
  end
@@ -26,7 +26,7 @@ module Services
26
26
  if ACTIONS_WITHOUT_CONVERSATION.include?(execution_step['action'])
27
27
  process_action(execution_step, nil, workflow_execution, workflow)
28
28
  else
29
- chat = create_and_configure_chat(workflow_step)
29
+ chat = create_and_configure_chat(workflow_step, execution_step)
30
30
  conversation = create_and_configure_conversation(chat, workflow_execution, execution_output, execution_step)
31
31
  process_action(execution_step, conversation, workflow_execution, workflow)
32
32
  end
@@ -222,9 +222,13 @@ module Services
222
222
  conversation
223
223
  end
224
224
 
225
- def create_and_configure_chat(workflow_step)
226
- workflow_step.chat = ::MetaWorkflows::Chat.new(model_id: RubyConversations.configuration.default_llm_model,
227
- provider: RubyConversations.configuration.default_llm_provider)
225
+ def create_and_configure_chat(workflow_step, execution_step)
226
+ model_id = execution_step['model'] || RubyConversations.configuration.default_llm_model
227
+
228
+ workflow_step.chat = ::MetaWorkflows::Chat.new(
229
+ model_id: model_id,
230
+ provider: RubyConversations.configuration.default_llm_provider
231
+ )
228
232
  chat = workflow_step.chat
229
233
  chat.user = @user
230
234
  chat.save!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta_workflows
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.13
4
+ version: 0.9.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Medovyy
@@ -147,6 +147,7 @@ files:
147
147
  - app/jobs/meta_workflows/meta_workflow_job.rb
148
148
  - app/jobs/meta_workflows/record_redirect_job.rb
149
149
  - app/mailers/meta_workflows/application_mailer.rb
150
+ - app/models/concerns/recipe_accessible.rb
150
151
  - app/models/meta_workflows.rb
151
152
  - app/models/meta_workflows/application_record.rb
152
153
  - app/models/meta_workflows/chat.rb