meta_workflows 0.9.1 → 0.9.3

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: 50ae604291373e74675fbac7838bb9cbbdcef8beb635a07ac40f06c89f784a75
4
- data.tar.gz: cefff5fe7d2a949941dee57e2a642e7eb54d2eaec220a489e252799fb8888f1c
3
+ metadata.gz: e5bff6e81f6281c59b4cf7c41d4b8d63357a8cb2e2e6e8bdc7374afdd68e2850
4
+ data.tar.gz: 4024549d8f91d0e42c4da57967a1400cafaf0b823653ea15d0f88824ab0f1636
5
5
  SHA512:
6
- metadata.gz: ec4974b30bfe8c3c17fbd779228e2bdf469ba86fd808fcfdfa792b4bad5419591e919d23570a42c70aedc06c68021321174a33d91faaf1b935eced1aa5504072
7
- data.tar.gz: 940604b1494c067ead7d9dbf6da6be88b10538e59bba4551e90a575ac070ff6fe882134a170e0f1d4f2045d2a9cffb75a3116fc010d3591361bbd74666e4efb5
6
+ metadata.gz: a2c684c560750d0bf6e6a555f414f835f82a9fd587ce8ed235ea657a2ce3c2b93d03dd5e255295e76b5a7d2519279aa29fd2bb2b25d489f1499662e969b7c7f8
7
+ data.tar.gz: 6448e7c99bce7f9a828bd9381a78862ceb1f170acd9ddd5c724984432451d3d9af2f52d4228db65cbb49c034bec502fda9c644e373e51edda4f3fbf6cc85d65c
@@ -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
- advance_workflow
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)
@@ -18,7 +18,7 @@
18
18
  <!-- Content area with chat and Lexi side by side -->
19
19
  <div class="flex-1 flex min-h-0">
20
20
  <!-- Lexi auto-width side column -->
21
- <div class="flex-shrink-0 flex flex-col justify-end pb-4">
21
+ <div class="flex-shrink-0 flex flex-col justify-end">
22
22
  <%= image_tag("lexi-expanded.png", alt: "Lexi Avatar", class: "lexi-avatar-large w-auto") %>
23
23
  </div>
24
24
 
@@ -30,7 +30,7 @@
30
30
  <!-- Input area -->
31
31
  <div class="w-full">
32
32
  <% active_execution = local_assigns[:record]&.workflow_executions&.order(created_at: :desc)&.first %>
33
- <%= 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 } %>
33
+ <%= 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 } %>
34
34
  </div>
35
35
  </div>
36
36
 
@@ -3,7 +3,7 @@
3
3
  module MetaWorkflows
4
4
  MAJOR = 0
5
5
  MINOR = 9
6
- PATCH = 1 # this is automatically incremented by the build process
6
+ PATCH = 3 # 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.1
4
+ version: 0.9.3
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-01 00:00:00.000000000 Z
12
+ date: 2025-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails