meta_workflows 0.9.2 → 0.9.4
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/javascripts/meta_workflows/controllers/lexi_form_submit_controller.js +18 -0
- data/app/controllers/meta_workflows/humans_controller.rb +4 -22
- data/app/jobs/meta_workflows/human_input_job.rb +29 -3
- data/app/jobs/meta_workflows/meta_job.rb +6 -4
- data/app/views/meta_workflows/_response_form_lexi.html.erb +7 -4
- data/lib/meta_workflows/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac38b3388265de972978282c0b7fe92df27e82b495474936c9533a02bbba73ca
|
4
|
+
data.tar.gz: 41c108f736b959e737fa292cc41ee94ff083b4c5fd87628cbe98a843cf28c96e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79740ed1c7a624747d70057e003159ac2e7d4ce9b6b0fa547dc03de76f09d882403f66ad7be133e0194b8dc130b7267a9a63a8af00a95d3982fcb173def68c82
|
7
|
+
data.tar.gz: 0bd02cba1bce6c83c0140828301222060fb2fc201e17fec61f2c518fca56e18982b15df2d88a6d398d434b91c31483161978a39676157fd873a15eccb242dbc8
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus';
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
connect() {
|
5
|
+
this.element.addEventListener('keydown', this.handleKeyDown);
|
6
|
+
}
|
7
|
+
|
8
|
+
disconnect() {
|
9
|
+
this.element.removeEventListener('keydown', this.handleKeyDown);
|
10
|
+
}
|
11
|
+
|
12
|
+
handleKeyDown = (event) => {
|
13
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
14
|
+
event.preventDefault();
|
15
|
+
this.element.requestSubmit();
|
16
|
+
}
|
17
|
+
};
|
18
|
+
}
|
@@ -8,7 +8,7 @@ module MetaWorkflows
|
|
8
8
|
def update
|
9
9
|
if params[:advance].present? || should_auto_advance?
|
10
10
|
render_loader_stream
|
11
|
-
|
11
|
+
process_human_input(auto_advancing: should_auto_advance?, manual_advancing: params[:advance].present?)
|
12
12
|
else
|
13
13
|
render_response_form_stream
|
14
14
|
process_human_input
|
@@ -17,26 +17,6 @@ module MetaWorkflows
|
|
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
20
|
def should_auto_advance?
|
41
21
|
step_repetitions = current_step_repetitions
|
42
22
|
return false unless step_repetitions
|
@@ -46,10 +26,12 @@ module MetaWorkflows
|
|
46
26
|
new_repetition >= step_repetitions
|
47
27
|
end
|
48
28
|
|
49
|
-
def process_human_input
|
29
|
+
def process_human_input(auto_advancing: false, manual_advancing: false)
|
50
30
|
MetaWorkflows::HumanInputJob.perform_later(
|
51
31
|
user_id: current_user.id,
|
52
32
|
record: @record,
|
33
|
+
auto_advancing: auto_advancing,
|
34
|
+
manual_advancing: manual_advancing,
|
53
35
|
params: {
|
54
36
|
inputs: params[:message],
|
55
37
|
chat_id: params[:chat_id],
|
@@ -5,10 +5,11 @@ module MetaWorkflows
|
|
5
5
|
include MetaWorkflows::MetaWorkflowsHelper
|
6
6
|
queue_as :default
|
7
7
|
|
8
|
-
def perform(user_id:, record:, params:)
|
9
|
-
setup(user_id, record)
|
8
|
+
def perform(user_id:, record:, params:, auto_advancing: false, manual_advancing: false)
|
9
|
+
setup(user_id, record, auto_advancing, manual_advancing)
|
10
10
|
conversation = initialize_conversation(params)
|
11
|
-
process_and_broadcast(conversation)
|
11
|
+
process_and_broadcast(conversation) unless manual_advancing
|
12
|
+
advance_workflow(params) if advancing?
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
@@ -46,5 +47,30 @@ module MetaWorkflows
|
|
46
47
|
step_has_repetitions: current_step_has_repetitions?(workflow_execution) }
|
47
48
|
)
|
48
49
|
end
|
50
|
+
|
51
|
+
def advance_workflow(params)
|
52
|
+
dialogue = collect_messages_from_chat(params)
|
53
|
+
workflow_execution = active_workflow_execution
|
54
|
+
workflow_execution.increment_step
|
55
|
+
|
56
|
+
MetaWorkflows::MetaWorkflowJob.perform_later(
|
57
|
+
record_id: @record.id,
|
58
|
+
record_type: @record.class.name,
|
59
|
+
workflow_name: nil,
|
60
|
+
user_id: @user_id,
|
61
|
+
inputs: { dialogue: dialogue }
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def collect_messages_from_chat(params)
|
66
|
+
messages = MetaWorkflows::Chat.find(params[:chat_id]).messages
|
67
|
+
messages.map do |m|
|
68
|
+
{ role: m.role, content: m.content.strip }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def advancing?
|
73
|
+
auto_advancing || manual_advancing
|
74
|
+
end
|
49
75
|
end
|
50
76
|
end
|
@@ -2,14 +2,16 @@
|
|
2
2
|
|
3
3
|
module MetaWorkflows
|
4
4
|
class MetaJob < MetaWorkflows::ApplicationJob
|
5
|
-
attr_accessor :chat, :inputs, :full_response, :user_id, :record
|
5
|
+
attr_accessor :chat, :inputs, :full_response, :user_id, :record, :auto_advancing, :manual_advancing
|
6
6
|
|
7
7
|
private
|
8
8
|
|
9
|
-
def setup(user_id, record)
|
9
|
+
def setup(user_id, record, auto_advancing, manual_advancing)
|
10
10
|
@user_id = user_id
|
11
11
|
@record = record.class.find(record.id)
|
12
12
|
@full_response = +''
|
13
|
+
@auto_advancing = auto_advancing
|
14
|
+
@manual_advancing = manual_advancing
|
13
15
|
end
|
14
16
|
|
15
17
|
def initialize_conversation(params)
|
@@ -59,13 +61,13 @@ module MetaWorkflows
|
|
59
61
|
def execute_llm_conversation(conversation)
|
60
62
|
conversation.call_llm do |chunk|
|
61
63
|
@full_response << (chunk.content || '')
|
62
|
-
broadcast_response(chat, full_response)
|
64
|
+
broadcast_response(chat, full_response) unless auto_advancing
|
63
65
|
end
|
64
66
|
end
|
65
67
|
|
66
68
|
def finalize_conversation(conversation)
|
67
69
|
chat.update!(conversation_id: conversation.id) if chat.conversation_id.blank?
|
68
|
-
broadcast_form(chat)
|
70
|
+
broadcast_form(chat) unless auto_advancing
|
69
71
|
end
|
70
72
|
|
71
73
|
def handle_llm_error(error, workflow_step, conversation)
|
@@ -1,6 +1,9 @@
|
|
1
1
|
<%= turbo_frame_tag target_frame_id(record, form: true) do %>
|
2
2
|
<div>
|
3
|
-
<%= form_with url: (workflow_execution_id.present? ? meta_workflows.human_path(workflow_execution_id) : "#"),
|
3
|
+
<%= form_with url: (workflow_execution_id.present? ? meta_workflows.human_path(workflow_execution_id) : "#"),
|
4
|
+
method: :patch,
|
5
|
+
data: { controller: "meta-workflows--lexi-form-submit"},
|
6
|
+
id: "#{target_frame_id(record, form: true)}_lexi" do |form| %>
|
4
7
|
<%= form.hidden_field :chat_id, value: chat_id %>
|
5
8
|
<fieldset>
|
6
9
|
<div class="flex flex-col gap-1">
|
@@ -8,9 +11,9 @@
|
|
8
11
|
<div class="flex flex-col lexi-input-max-height border border-gray-300 rounded-lg bg-white/80 p-2">
|
9
12
|
<!-- Input area with icons -->
|
10
13
|
<div class="flex-1 relative">
|
11
|
-
|
14
|
+
<%= form.text_area :message, rows: 1, placeholder: random_chat_placeholder, disabled: local_assigns[:responding] || !local_assigns[:response_enabled], class: "w-full lexi-textarea-min-height border-0 resize-none focus:outline-none focus:ring-0 bg-transparent text-base overflow-y-auto" %>
|
12
15
|
</div>
|
13
|
-
|
16
|
+
|
14
17
|
<div class="flex justify-between">
|
15
18
|
<div class="flex gap-1 items-end justify-end">
|
16
19
|
<button type="button" class="p-2 rounded-xl hover:bg-gray-100" disabled>
|
@@ -52,4 +55,4 @@
|
|
52
55
|
</fieldset>
|
53
56
|
<% end %>
|
54
57
|
</div>
|
55
|
-
<% end %>
|
58
|
+
<% end %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module MetaWorkflows
|
4
4
|
MAJOR = 0
|
5
5
|
MINOR = 9
|
6
|
-
PATCH =
|
6
|
+
PATCH = 4 # 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.9.
|
4
|
+
version: 0.9.4
|
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-07-
|
12
|
+
date: 2025-07-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- app/assets/images/lexi-collapsed.png
|
119
119
|
- app/assets/images/lexi-expanded.png
|
120
120
|
- app/assets/images/lexi_logo_color.png
|
121
|
+
- app/assets/javascripts/meta_workflows/controllers/lexi_form_submit_controller.js
|
121
122
|
- app/assets/javascripts/meta_workflows/controllers/loading_phrases_controller.js
|
122
123
|
- app/assets/javascripts/meta_workflows/controllers/meta_flash_controller.js
|
123
124
|
- app/assets/javascripts/meta_workflows/controllers/redirect_controller.js
|