meta_workflows 0.8.10 → 0.8.12
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/assets/images/lexi-chaticon.png +0 -0
- data/app/assets/images/lexi-collapsed.png +0 -0
- data/app/assets/images/lexi-expanded.png +0 -0
- data/app/assets/images/lexi_logo_color.png +0 -0
- data/app/controllers/meta_workflows/humans_controller.rb +45 -35
- data/app/controllers/meta_workflows/meta_controller.rb +7 -1
- data/app/helpers/meta_workflows/meta_workflows_helper.rb +4 -0
- data/app/jobs/meta_workflows/human_input_job.rb +2 -1
- data/app/models/meta_workflows/workflow.rb +4 -0
- data/app/models/meta_workflows/workflow_step.rb +12 -0
- data/app/views/meta_workflows/_lexi_chat_alpha_tray.html.erb +1 -1
- data/app/views/meta_workflows/_response_form_lexi.html.erb +8 -9
- data/db/migrate/20250626211926_add_repetition_to_meta_workflows_workflow_steps.rb +5 -0
- data/lib/meta_workflows/version.rb +1 -1
- data/lib/services/meta_workflows/meta_workflow_service.rb +4 -6
- data/lib/services/meta_workflows/updaters/meta_service.rb +6 -3
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c3e3a281ec142b84464171c5827bcf2b9d0610fcfda6268588727b0c291233b
|
4
|
+
data.tar.gz: 641415e402adbc3fe28ebc786ab718cf3fd73245405d30e2c56935500fea37e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d0502a24725b61701f2e332bdd248dbb32735e239ebeb8667cbe3f751683c9f25e037dbafd269c7ea6ee298049ac39a9dcb29a61ecba4f138f3b93737c0d520
|
7
|
+
data.tar.gz: 324ffa7ee80f572a06166e44e210906027d745e5ddd825a8c5342794fd6c7230adbd41f2b0d602c398bde7878fd68bf0e91eefb822f3f483fe8fbd021aa30cbb
|
Binary file
|
Binary file
|
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.
|
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
|
@@ -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
|
@@ -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:
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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 %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module MetaWorkflows
|
4
4
|
MAJOR = 0
|
5
5
|
MINOR = 8
|
6
|
-
PATCH =
|
6
|
+
PATCH = 12 # this is automatically incremented by the build process
|
7
7
|
|
8
8
|
VERSION = "#{MetaWorkflows::MAJOR}.#{MetaWorkflows::MINOR}.#{MetaWorkflows::PATCH}".freeze
|
9
9
|
end
|
@@ -181,17 +181,15 @@ module Services
|
|
181
181
|
|
182
182
|
raise ArgumentError, "Invalid record updater class: #{service_class_name}" unless service_class
|
183
183
|
|
184
|
-
target_record =
|
184
|
+
target_record = find_workflow_record(workflow_execution)
|
185
185
|
attributes_to_update = execution_step['attributes_to_update']
|
186
186
|
|
187
|
-
service_class.new(target_record, attributes_to_update, workflow_execution.workflow_params)
|
187
|
+
service_class.new(target_record, attributes_to_update, workflow_execution.workflow_params, inputs)
|
188
188
|
end
|
189
189
|
|
190
|
-
|
191
|
-
# to only use workflow_params and use better naming (instead of record_id and record_class)
|
192
|
-
def find_parent_record(workflow_execution)
|
190
|
+
def find_workflow_record(workflow_execution)
|
193
191
|
record_class = workflow_execution.record.class.name.constantize
|
194
|
-
record_class.find(workflow_execution.
|
192
|
+
record_class.find(workflow_execution.record_id)
|
195
193
|
end
|
196
194
|
|
197
195
|
def continue_workflow(workflow_execution, workflow)
|
@@ -4,13 +4,14 @@ module Services
|
|
4
4
|
module MetaWorkflows
|
5
5
|
module Updaters
|
6
6
|
class MetaService < Services::MetaWorkflows::ApplicationService
|
7
|
-
attr_reader :record, :attributes_to_update, :workflow_params
|
7
|
+
attr_reader :record, :attributes_to_update, :workflow_params, :inputs
|
8
8
|
|
9
|
-
def initialize(record, attributes_to_update, workflow_params)
|
9
|
+
def initialize(record, attributes_to_update, workflow_params, inputs = {})
|
10
10
|
super()
|
11
11
|
@record = record
|
12
12
|
@attributes_to_update = attributes_to_update
|
13
13
|
@workflow_params = workflow_params
|
14
|
+
@inputs = inputs
|
14
15
|
end
|
15
16
|
|
16
17
|
def call
|
@@ -25,7 +26,9 @@ module Services
|
|
25
26
|
attributes_hash = {}
|
26
27
|
|
27
28
|
attributes_to_update.each do |attribute_name|
|
28
|
-
|
29
|
+
# Check inputs first, then workflow_params
|
30
|
+
param_value = inputs[attribute_name] || inputs[attribute_name.to_sym] ||
|
31
|
+
workflow_params[attribute_name] || workflow_params[attribute_name.to_sym]
|
29
32
|
next if param_value.blank?
|
30
33
|
|
31
34
|
attributes_hash[attribute_name.to_sym] = param_value
|
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.
|
4
|
+
version: 0.8.12
|
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-
|
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
|