llm_meta_client 0.5.0 → 0.6.0
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/CHANGELOG.md +8 -0
- data/lib/generators/llm_meta_client/scaffold/scaffold_generator.rb +2 -2
- data/lib/generators/llm_meta_client/scaffold/templates/app/controllers/chats_controller.rb +1 -1
- data/lib/generators/llm_meta_client/scaffold/templates/app/controllers/prompts_controller.rb +2 -2
- data/lib/generators/llm_meta_client/scaffold/templates/app/models/chat.rb +13 -17
- data/lib/generators/llm_meta_client/scaffold/templates/app/models/message.rb +2 -2
- data/lib/generators/llm_meta_client/scaffold/templates/app/views/chats/_message.html.erb +3 -3
- data/lib/generators/llm_meta_client/scaffold/templates/app/views/chats/create.turbo_stream.erb +2 -2
- data/lib/generators/llm_meta_client/scaffold/templates/app/views/chats/update.turbo_stream.erb +2 -2
- data/lib/generators/llm_meta_client/scaffold/templates/app/views/layouts/_sidebar.html.erb +1 -1
- data/lib/generators/llm_meta_client/scaffold/templates/app/views/layouts/application.html.erb +1 -1
- data/lib/generators/llm_meta_client/scaffold/templates/db/migrate/create_messages.rb +1 -1
- data/lib/llm_meta_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2e6f2472a161a70eb1e9aa1af8495c25a9a7229d0351663f2b8784759377e813
|
|
4
|
+
data.tar.gz: 7830a137d1a7751942a314e5271a98e5db27aa105aa36885f2a753b02f63f9a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8b16d80ac8a8f96fbf3545688a8657ed12ad2ef298707ee6475789b9468399a314b494f7d01e829557039dc11985702fbf1b4a6f1f8f67dab8f9908395fdf1d0
|
|
7
|
+
data.tar.gz: c335cf07ce4e413b7251fdc75ea41d227b89e86ebca4f6e44a526cd8fbb6f44dc3185851d2b1055cf20ae86ee1658e1fd2138924da0370da2d33127699c18fb6
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.6.0] - 2026-03-18
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Rename `prompt_manager` references to `prompt_navigator` across all scaffold templates (models, controllers, views, migrations, generator config)
|
|
13
|
+
- Refactor chat template to use `PromptExecution#build_context` instead of manual message iteration
|
|
14
|
+
- Update `prompt_navigator` gem to 0.3.0
|
|
15
|
+
|
|
8
16
|
## [0.5.0] - 2026-03-17
|
|
9
17
|
|
|
10
18
|
### Added
|
|
@@ -97,8 +97,8 @@ module LlmMetaClient
|
|
|
97
97
|
|
|
98
98
|
def configure_asset_paths
|
|
99
99
|
inject_into_class "config/application.rb", "Application", <<-RUBY
|
|
100
|
-
# Add asset paths for
|
|
101
|
-
config.assets.paths << Rails.root.join("../
|
|
100
|
+
# Add asset paths for prompt_navigator gem
|
|
101
|
+
config.assets.paths << Rails.root.join("../prompt_navigator/app/assets/stylesheets")
|
|
102
102
|
# Add asset paths for chat_manager gem
|
|
103
103
|
config.assets.paths << Rails.root.join("../chat_manager/app/assets/stylesheets")
|
|
104
104
|
RUBY
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class ChatsController < ApplicationController
|
|
2
2
|
include ChatManager::ChatManageable
|
|
3
3
|
include ChatManager::CsvDownloadable
|
|
4
|
-
include
|
|
4
|
+
include PromptNavigator::HistoryManageable
|
|
5
5
|
# Allow access without login
|
|
6
6
|
skip_before_action :authenticate_user!, raise: false
|
|
7
7
|
before_action :authenticate_user!, only: [ :update_title, :download_csv, :download_all_csv ]
|
data/lib/generators/llm_meta_client/scaffold/templates/app/controllers/prompts_controller.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
class PromptsController < ApplicationController
|
|
2
2
|
include ChatManager::ChatManageable
|
|
3
|
-
include
|
|
3
|
+
include PromptNavigator::HistoryManageable
|
|
4
4
|
skip_before_action :authenticate_user!, raise: false
|
|
5
5
|
|
|
6
6
|
def show
|
|
7
|
-
@prompt_execution =
|
|
7
|
+
@prompt_execution = PromptNavigator::PromptExecution.includes(:messages).find_by(execution_id: params[:id])
|
|
8
8
|
@message = @prompt_execution.messages.first
|
|
9
9
|
@chat = @message.chat
|
|
10
10
|
@messages = @chat.ordered_messages
|
|
@@ -51,16 +51,16 @@ class Chat < ApplicationRecord
|
|
|
51
51
|
# Add a user message to the chat
|
|
52
52
|
def add_user_message(message, model, branch_from_uuid = nil)
|
|
53
53
|
parent_message = branch_from_uuid.present? ? messages.find_by(uuid: branch_from_uuid) : nil
|
|
54
|
-
prompt_execution =
|
|
54
|
+
prompt_execution = PromptNavigator::PromptExecution.create!(
|
|
55
55
|
prompt: message,
|
|
56
56
|
model: model,
|
|
57
57
|
configuration: "",
|
|
58
|
-
previous_id: parent_message&.
|
|
58
|
+
previous_id: parent_message&.prompt_navigator_prompt_execution_id
|
|
59
59
|
)
|
|
60
60
|
|
|
61
61
|
new_message = messages.create!(
|
|
62
62
|
role: "user",
|
|
63
|
-
|
|
63
|
+
prompt_navigator_prompt_execution: prompt_execution
|
|
64
64
|
)
|
|
65
65
|
|
|
66
66
|
[ prompt_execution, new_message ]
|
|
@@ -75,7 +75,7 @@ class Chat < ApplicationRecord
|
|
|
75
75
|
)
|
|
76
76
|
new_message = messages.create!(
|
|
77
77
|
role: "assistant",
|
|
78
|
-
|
|
78
|
+
prompt_navigator_prompt_execution: prompt_execution
|
|
79
79
|
)
|
|
80
80
|
|
|
81
81
|
new_message
|
|
@@ -84,18 +84,18 @@ class Chat < ApplicationRecord
|
|
|
84
84
|
# Get all messages in order
|
|
85
85
|
def ordered_messages
|
|
86
86
|
messages
|
|
87
|
-
.includes(:
|
|
87
|
+
.includes(:prompt_navigator_prompt_execution)
|
|
88
88
|
.order(:created_at)
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
def ordered_by_descending_prompt_executions
|
|
92
92
|
messages
|
|
93
93
|
.where(role: "user")
|
|
94
|
-
.includes(:
|
|
94
|
+
.includes(:prompt_navigator_prompt_execution)
|
|
95
95
|
.order(created_at: :desc)
|
|
96
96
|
.to_a
|
|
97
|
-
.select { |msg| msg.
|
|
98
|
-
.map(&:
|
|
97
|
+
.select { |msg| msg.prompt_navigator_prompt_execution }
|
|
98
|
+
.map(&:prompt_navigator_prompt_execution)
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
# Check if chat needs to be reset due to LLM or model change
|
|
@@ -129,20 +129,16 @@ class Chat < ApplicationRecord
|
|
|
129
129
|
# Error if no LLM is available
|
|
130
130
|
raise LlmMetaClient::Exceptions::OllamaUnavailableError, "No LLM available" if llm_options.empty?
|
|
131
131
|
|
|
132
|
-
#
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
# Build prompt and context from direct lineage via PromptExecution
|
|
133
|
+
last_msg = ordered_messages.last
|
|
134
|
+
pe = last_msg.prompt_manager_prompt_execution
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
context = all_messages[0...-1].last(Rails.configuration.summarize_conversation_count).map do |msg|
|
|
139
|
-
{ role: msg.role, prompt: msg.prompt_manager_prompt_execution.prompt, response: msg.prompt_manager_prompt_execution&.response }
|
|
140
|
-
end
|
|
136
|
+
prompt = { role: last_msg.role, prompt: pe.prompt }
|
|
137
|
+
context = pe.build_context(limit: Rails.configuration.summarize_conversation_count)
|
|
141
138
|
|
|
142
139
|
if context.empty?
|
|
143
140
|
summarized_context = "No context available."
|
|
144
141
|
else
|
|
145
|
-
# Summarize context
|
|
146
142
|
summarized_context = LlmMetaClient::ServerQuery.new.call(jwt_token, llm_uuid, model, context, "Please summarize the context")
|
|
147
143
|
end
|
|
148
144
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class Message < ApplicationRecord
|
|
2
2
|
belongs_to :chat
|
|
3
|
-
belongs_to :
|
|
4
|
-
class_name: "
|
|
3
|
+
belongs_to :prompt_navigator_prompt_execution,
|
|
4
|
+
class_name: "PromptNavigator::PromptExecution",
|
|
5
5
|
optional: false
|
|
6
6
|
|
|
7
7
|
validates :role, presence: true, inclusion: { in: %w[user assistant] }
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
<%% if message.role == 'user' %>
|
|
4
4
|
👤 You
|
|
5
5
|
<%% else %>
|
|
6
|
-
🤖 <%%= message.
|
|
6
|
+
🤖 <%%= message.prompt_navigator_prompt_execution.llm_platform&.capitalize || 'LLM' %>
|
|
7
7
|
<%% end %>
|
|
8
8
|
</div>
|
|
9
9
|
<div class="message-content">
|
|
10
10
|
<%% if message.role == 'user' %>
|
|
11
|
-
<%%= simple_format(message.
|
|
11
|
+
<%%= simple_format(message.prompt_navigator_prompt_execution&.prompt) %>
|
|
12
12
|
<%% else %>
|
|
13
|
-
<%%= simple_format(message.
|
|
13
|
+
<%%= simple_format(message.prompt_navigator_prompt_execution&.response) %>
|
|
14
14
|
<%% end %>
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
data/lib/generators/llm_meta_client/scaffold/templates/app/views/chats/create.turbo_stream.erb
CHANGED
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
<div id="history-content">
|
|
37
37
|
<h2>History</h2>
|
|
38
38
|
<div class="history-stack" id="history-stack" data-controller="history">
|
|
39
|
-
<%%= render '
|
|
39
|
+
<%%= render 'prompt_navigator/history_card', locals: {
|
|
40
40
|
ann: @prompt_execution,
|
|
41
41
|
next_ann: nil,
|
|
42
42
|
is_active: @prompt_execution.execution_id == @active_message_uuid,
|
|
43
43
|
card_path: ->(uuid) { prompt_path(uuid) }
|
|
44
44
|
} %>
|
|
45
45
|
<%% (@chat&.ordered_by_descending_prompt_executions || []).drop(1).each_with_index do |ann, idx| %>
|
|
46
|
-
<%%= render '
|
|
46
|
+
<%%= render 'prompt_navigator/history_card', locals: {
|
|
47
47
|
ann: ann,
|
|
48
48
|
next_ann: @chat.ordered_by_descending_prompt_executions[idx + 2],
|
|
49
49
|
is_active: ann.execution_id == @active_message_uuid,
|
data/lib/generators/llm_meta_client/scaffold/templates/app/views/chats/update.turbo_stream.erb
CHANGED
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
<div id="history-content">
|
|
31
31
|
<h2>History</h2>
|
|
32
32
|
<div class="history-stack" id="history-stack" data-controller="history">
|
|
33
|
-
<%%= render '
|
|
33
|
+
<%%= render 'prompt_navigator/history_card', locals: {
|
|
34
34
|
ann: @prompt_execution,
|
|
35
35
|
next_ann: nil,
|
|
36
36
|
is_active: @prompt_execution.execution_id == @active_message_uuid,
|
|
37
37
|
card_path: ->(uuid) { prompt_path(uuid) }
|
|
38
38
|
} %>
|
|
39
39
|
<%% (@chat&.ordered_by_descending_prompt_executions || []).drop(1).each_with_index do |ann, idx| %>
|
|
40
|
-
<%%= render '
|
|
40
|
+
<%%= render 'prompt_navigator/history_card', locals: {
|
|
41
41
|
ann: ann,
|
|
42
42
|
next_ann: @chat.ordered_by_descending_prompt_executions[idx + 2],
|
|
43
43
|
is_active: ann.execution_id == @active_message_uuid,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<%% if history.present? %>
|
|
13
13
|
<div class="history-stack" id="history-stack" data-controller="history">
|
|
14
14
|
<%% history.each_with_index do |ann, idx| %>
|
|
15
|
-
<%%= render '
|
|
15
|
+
<%%= render 'prompt_navigator/history_card', locals: {
|
|
16
16
|
ann: ann,
|
|
17
17
|
next_ann: history[idx + 1],
|
|
18
18
|
is_active: ann.uuid == active_uuid,
|
data/lib/generators/llm_meta_client/scaffold/templates/app/views/layouts/application.html.erb
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
<%% # Includes all stylesheet files in app/assets/stylesheets %>
|
|
22
22
|
<%%= stylesheet_link_tag :app %>
|
|
23
|
-
<%%= stylesheet_link_tag "
|
|
23
|
+
<%%= stylesheet_link_tag "prompt_navigator/history", "data-turbo-track": "reload" %>
|
|
24
24
|
<%%= stylesheet_link_tag "chat_manager/chat", "data-turbo-track": "reload" %>
|
|
25
25
|
<%%= javascript_importmap_tags %>
|
|
26
26
|
</head>
|
|
@@ -3,7 +3,7 @@ class CreateMessages < ActiveRecord::Migration[8.1]
|
|
|
3
3
|
create_table :messages do |t|
|
|
4
4
|
t.references :chat, null: false, foreign_key: true
|
|
5
5
|
# t.references :parent, foreign_key: { to_table: :messages }, index: true, null: true
|
|
6
|
-
t.references :
|
|
6
|
+
t.references :prompt_navigator_prompt_execution, null: true, foreign_key: { to_table: :prompt_navigator_prompt_executions }
|
|
7
7
|
t.string :role
|
|
8
8
|
|
|
9
9
|
t.timestamps
|