meta_workflows 0.8.10 → 0.8.11

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: 9792925e97535114e20604bd6c65575fdd59ce7546af128acbb9464451441bb2
4
- data.tar.gz: 1e45fd28cd666352d7396575af106a994d0d3e679c029baa98218c76ca1b111a
3
+ metadata.gz: 88e0b63f0ddb77f268afe958db75e5b12b557e0426fe51fbc4c3387d1f457cda
4
+ data.tar.gz: 96dbf3330181b487494cc35b3cb7fa30fc9f41b95c4340acec101e7f02aa3913
5
5
  SHA512:
6
- metadata.gz: e3f5303a30b9d62178bb775dfdc52c328871186ecce597bc8db71247a67e1318963cc21c82fbca227b97bc83f6a63ca7af94abb4c9a11a040c5634fff46410b2
7
- data.tar.gz: fcd9e0397f55cc8e97af4d5bd00833aa6a8b832c06f722c0b9e9060984d430d7fe6372153859414f2e806bfa26803aaadf679b71710f9dc4371e2985b6a7fbf6
6
+ metadata.gz: e3d8b0365283b1221d9a149a6d250f53a04dc4db46e9e72ca5400861c8ee81eeb6beb909a7abcef5ac301c900e0042d51ad60c9052c461456b732227e794f114
7
+ data.tar.gz: e13c2fb2fe7d36b98c6d05f9acbbef7598ef03bbc1971ff7194bf2589b61b81890e69dd184629326ce376e829eb22e46d94708c1b9c81500824adf5cdfa208ca
Binary file
Binary file
@@ -6,17 +6,58 @@ module MetaWorkflows
6
6
  before_action :set_workflow_data, only: [:update]
7
7
 
8
8
  def update
9
- if params[:advance].present?
9
+ if params[:advance].present? || should_auto_advance?
10
10
  advance_workflow
11
11
  render_loader_stream
12
12
  else
13
- process_human_input
14
13
  render_response_form_stream
14
+ process_human_input
15
15
  end
16
16
  end
17
17
 
18
18
  private
19
19
 
20
+ def advance_workflow
21
+ dialogue = collect_messages_from_chat
22
+ @workflow_execution.increment_step
23
+
24
+ MetaWorkflows::MetaWorkflowJob.perform_later(
25
+ record_id: @record.id,
26
+ record_type: @record.class.name,
27
+ workflow_name: nil,
28
+ user_id: current_user.id,
29
+ inputs: { dialogue: dialogue }
30
+ )
31
+ end
32
+
33
+ def collect_messages_from_chat
34
+ messages = MetaWorkflows::Chat.find(params[:chat_id]).messages
35
+ messages.map do |m|
36
+ { role: m.role, content: m.content.strip }
37
+ end
38
+ end
39
+
40
+ def should_auto_advance?
41
+ step_repetitions = current_step_repetitions
42
+ return false unless step_repetitions
43
+
44
+ new_repetition = @workflow_step.increment_repetition!
45
+
46
+ new_repetition >= step_repetitions
47
+ end
48
+
49
+ def process_human_input
50
+ MetaWorkflows::HumanInputJob.perform_later(
51
+ user_id: current_user.id,
52
+ record: @record,
53
+ params: {
54
+ inputs: params[:message],
55
+ chat_id: params[:chat_id],
56
+ prompt_id: @prompt_id
57
+ }
58
+ )
59
+ end
60
+
20
61
  def render_loader_stream
21
62
  respond_to do |format|
22
63
  format.turbo_stream do
@@ -51,45 +92,14 @@ module MetaWorkflows
51
92
  end
52
93
  end
53
94
 
54
- def advance_workflow
55
- dialogue = collect_messages_from_chat
56
- @workflow_execution.increment_step
57
-
58
- MetaWorkflows::MetaWorkflowJob.perform_later(
59
- record_id: @record.id,
60
- record_type: @record.class.name,
61
- workflow_name: nil,
62
- user_id: current_user.id,
63
- inputs: { dialogue: dialogue }
64
- )
65
- end
66
-
67
- def process_human_input
68
- MetaWorkflows::HumanInputJob.perform_later(
69
- user_id: current_user.id,
70
- record: @record,
71
- params: {
72
- inputs: params[:message],
73
- chat_id: params[:chat_id],
74
- prompt_id: @prompt_id
75
- }
76
- )
77
- end
78
-
79
- def collect_messages_from_chat
80
- messages = MetaWorkflows::Chat.find(params[:chat_id]).messages
81
- messages.map do |m|
82
- { role: m.role, content: m.content.strip }
83
- end
84
- end
85
-
86
95
  def response_form_locals(response_enabled: true, responding: false)
87
96
  {
88
97
  record: @record,
89
98
  workflow_execution_id: @workflow_execution.id,
90
99
  chat_id: params[:chat_id],
91
100
  response_enabled: response_enabled,
92
- responding: responding
101
+ responding: responding,
102
+ step_has_repetitions: current_step_has_repetitions?(@workflow_execution)
93
103
  }
94
104
  end
95
105
  end
@@ -5,9 +5,11 @@ module MetaWorkflows
5
5
  include MetaWorkflows::MetaWorkflowsHelper
6
6
 
7
7
  def set_workflow_data
8
- @workflow_execution = MetaWorkflows::WorkflowExecution.find(params[:id])
8
+ @workflow_execution = MetaWorkflows::WorkflowExecution.includes(:record, :workflow,
9
+ :workflow_steps).find(params[:id])
9
10
  @record = @workflow_execution.record
10
11
  @workflow = @workflow_execution.workflow
12
+ @workflow_step = @workflow_execution.workflow_steps.find_by(step: @workflow_execution.current_step)
11
13
  @prompt_id = @workflow.prompt_id(@workflow_execution.current_step)
12
14
  end
13
15
 
@@ -17,5 +19,9 @@ module MetaWorkflows
17
19
  @workflow.step_progress(@workflow_execution.current_step) || ['Processing your request...',
18
20
  'Talking to the LLM...']
19
21
  end
22
+
23
+ def current_step_repetitions
24
+ @workflow.step_repetitions(@workflow_execution.current_step)
25
+ end
20
26
  end
21
27
  end
@@ -63,5 +63,9 @@ module MetaWorkflows
63
63
  ''
64
64
  end
65
65
  end
66
+
67
+ def current_step_has_repetitions?(workflow_execution)
68
+ workflow_execution.workflow.step_repetitions(workflow_execution.current_step).present?
69
+ end
66
70
  end
67
71
  end
@@ -42,7 +42,8 @@ module MetaWorkflows
42
42
  locals: { record: record,
43
43
  workflow_execution_id: workflow_execution&.id,
44
44
  response_enabled: true,
45
- chat_id: chat.id }
45
+ chat_id: chat.id,
46
+ step_has_repetitions: current_step_has_repetitions?(workflow_execution) }
46
47
  )
47
48
  end
48
49
  end
@@ -25,6 +25,10 @@ module MetaWorkflows
25
25
  recipe.dig('steps', step, 'output')
26
26
  end
27
27
 
28
+ def step_repetitions(step)
29
+ recipe.dig('steps', step, 'repetitions')
30
+ end
31
+
28
32
  def total_steps
29
33
  recipe['steps'].size
30
34
  end
@@ -6,6 +6,7 @@ module MetaWorkflows
6
6
  belongs_to :chat, class_name: 'MetaWorkflows::Chat', optional: true
7
7
 
8
8
  validates :step, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
9
+ validates :repetition, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, allow_nil: true
9
10
  validates :workflow_execution_id, uniqueness: { scope: :step }
10
11
 
11
12
  has_one :workflow, through: :workflow_execution, class_name: 'MetaWorkflows::Workflow'
@@ -45,5 +46,16 @@ module MetaWorkflows
45
46
 
46
47
  "#{error_type}: #{error_message}"
47
48
  end
49
+
50
+ # Repetition methods
51
+ def current_repetition
52
+ repetition || 0
53
+ end
54
+
55
+ def increment_repetition!
56
+ new_repetition = current_repetition + 1
57
+ update!(repetition: new_repetition)
58
+ new_repetition
59
+ end
48
60
  end
49
61
  end
@@ -37,7 +37,7 @@
37
37
  <!-- Input form -->
38
38
  <div class="w-full">
39
39
  <% active_execution = local_assigns[:record]&.workflow_executions&.order(created_at: :desc)&.first %>
40
- <%= render partial: "meta_workflows/response_form_lexi", locals: {record: local_assigns[:record], response_enabled: true, workflow_execution_id: active_execution&.id, chat_id: active_execution&.workflow_steps&.last&.chat&.id } %>
40
+ <%= render partial: meta_response_form, locals: {record: local_assigns[:record], response_enabled: true, workflow_execution_id: active_execution&.id, chat_id: active_execution&.workflow_steps&.last&.chat&.id, step_has_repetitions: true } %>
41
41
  </div>
42
42
  </div>
43
43
  </div>
@@ -1,5 +1,4 @@
1
1
  <%= turbo_frame_tag target_frame_id(record, form: true) do %>
2
- <% if local_assigns[:response_enabled] %>
3
2
  <div>
4
3
  <%= form_with url: (workflow_execution_id.present? ? meta_workflows.human_path(workflow_execution_id) : "#"), method: :patch do |form| %>
5
4
  <%= form.hidden_field :chat_id, value: chat_id %>
@@ -9,7 +8,7 @@
9
8
  <div class="flex flex-col max-h-[200px] border border-gray-300 rounded-lg bg-white/80 p-2">
10
9
  <!-- Input area with icons -->
11
10
  <div class="flex-1 relative">
12
- <%= form.text_area :message, rows: 1, placeholder: random_chat_placeholder, disabled: local_assigns[:responding], class: "w-full min-h-[50px] border-0 resize-none focus:outline-none focus:ring-0 bg-transparent text-base overflow-y-auto" %>
11
+ <%= form.text_area :message, rows: 1, placeholder: random_chat_placeholder, disabled: local_assigns[:responding] || !local_assigns[:response_enabled], class: "w-full min-h-[50px] border-0 resize-none focus:outline-none focus:ring-0 bg-transparent text-base overflow-y-auto" %>
13
12
  </div>
14
13
 
15
14
  <div class="flex justify-between">
@@ -39,15 +38,15 @@
39
38
  </div>
40
39
  </div>
41
40
 
42
- <!-- Next Button (outside input container) -->
43
- <div class="flex justify-end">
44
- <%= form.button type: "submit", name: "advance", value: "true", class: "text-xs mb-2 #{local_assigns[:responding] ? 'opacity-50 cursor-not-allowed' : ''}", disabled: local_assigns[:responding] do %>
45
- <i class="fa-light fa-arrow-right"></i> Next
46
- <% end %>
47
- </div>
41
+ <% unless local_assigns[:step_has_repetitions] %>
42
+ <div class="flex justify-end">
43
+ <%= form.button type: "submit", name: "advance", value: "true", class: "text-xs mb-2 #{local_assigns[:responding] ? 'opacity-50 cursor-not-allowed' : ''}", disabled: local_assigns[:responding] do %>
44
+ <i class="fa-light fa-arrow-right"></i> Next
45
+ <% end %>
46
+ </div>
47
+ <% end %>
48
48
  </div>
49
49
  </fieldset>
50
50
  <% end %>
51
51
  </div>
52
- <% end %>
53
52
  <% end %>
@@ -0,0 +1,5 @@
1
+ class AddRepetitionToMetaWorkflowsWorkflowSteps < ActiveRecord::Migration[7.2]
2
+ def change
3
+ add_column :meta_workflows_workflow_steps, :repetition, :integer, default: nil
4
+ end
5
+ end
@@ -3,7 +3,7 @@
3
3
  module MetaWorkflows
4
4
  MAJOR = 0
5
5
  MINOR = 8
6
- PATCH = 10 # this is automatically incremented by the build process
6
+ PATCH = 11 # this is automatically incremented by the build process
7
7
 
8
8
  VERSION = "#{MetaWorkflows::MAJOR}.#{MetaWorkflows::MINOR}.#{MetaWorkflows::PATCH}".freeze
9
9
  end
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.8.10
4
+ version: 0.8.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Medovyy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-06-26 00:00:00.000000000 Z
12
+ date: 2025-06-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -114,6 +114,10 @@ files:
114
114
  - CHANGELOG.md
115
115
  - README.md
116
116
  - Rakefile
117
+ - app/assets/images/lexi-chaticon.png
118
+ - app/assets/images/lexi-collapsed.png
119
+ - app/assets/images/lexi-expanded.png
120
+ - app/assets/images/lexi_logo_color.png
117
121
  - app/assets/javascripts/meta_workflows/controllers/loading_phrases_controller.js
118
122
  - app/assets/javascripts/meta_workflows/controllers/meta_flash_controller.js
119
123
  - app/assets/javascripts/meta_workflows/controllers/redirect_controller.js
@@ -170,6 +174,7 @@ files:
170
174
  - db/migrate/20250613213159_add_error_fields_to_workflow_steps.rb
171
175
  - db/migrate/20250617192849_remove_repetition_from_meta_workflows_workflow_executions.rb
172
176
  - db/migrate/20250618175439_add_call_id_and_status_to_meta_workflows_tool_calls.rb
177
+ - db/migrate/20250626211926_add_repetition_to_meta_workflows_workflow_steps.rb
173
178
  - lib/meta_workflows.rb
174
179
  - lib/meta_workflows/asset_installer.rb
175
180
  - lib/meta_workflows/configuration.rb