chat_manager 0.1.0 → 0.2.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/README.md +162 -5
- data/lib/chat_manager/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8b511ecced21ece0ee04d99c18a5ddc602583a0e8ec259669f8127e81fc80624
|
|
4
|
+
data.tar.gz: f7dfc3090521f0e533a5c1ab684f1ad3b25c8ed5f00d61c0bcc589d095760563
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 584400568e1b29a5de4cf9379399427815c7deccd1e59003a4fb69ecf850ce71636682a047115fb2170d14fb760afca584a6e0f29e7a5f625c493782c29975e4
|
|
7
|
+
data.tar.gz: 7643eac34c2623e4c46e068b9daf8e54b1adb41f71b0f59c1bab94c5c3953596b97a9cab1b0795567cc584d8499954044feea34d7f0f8082db79325056335daa
|
data/README.md
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
# ChatManager
|
|
2
|
-
Short description and motivation.
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
A Rails engine for managing LLM chat conversations with CSV export, auto-titling, and ready-to-use UI components.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Chat Management** — Controller concern (`ChatManageable`) for initializing and managing chat arrays with duplicate/nil prevention
|
|
8
|
+
- **Automatic Title Generation** — Model concern (`TitleGeneratable`) for generating chat titles from initial prompts
|
|
9
|
+
- **CSV Export** — Controller concern (`CsvDownloadable`) for individual and bulk chat CSV downloads
|
|
10
|
+
- **UI Components** — Chat list and chat card partials with Stimulus-powered inline title editing
|
|
11
|
+
- **Database Migration Generator** — `chat_manager:modeling` generator for creating the chats table
|
|
12
|
+
- **Turbo/Turbolinks Safe** — CSV download links work correctly with modern Rails JS frameworks
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- Ruby 4.0+
|
|
17
|
+
- Rails 8.1+
|
|
6
18
|
|
|
7
19
|
## Installation
|
|
20
|
+
|
|
8
21
|
Add this line to your application's Gemfile:
|
|
9
22
|
|
|
10
23
|
```ruby
|
|
@@ -12,17 +25,161 @@ gem "chat_manager"
|
|
|
12
25
|
```
|
|
13
26
|
|
|
14
27
|
And then execute:
|
|
28
|
+
|
|
15
29
|
```bash
|
|
16
|
-
$ bundle
|
|
30
|
+
$ bundle install
|
|
17
31
|
```
|
|
18
32
|
|
|
19
33
|
Or install it yourself as:
|
|
34
|
+
|
|
20
35
|
```bash
|
|
21
36
|
$ gem install chat_manager
|
|
22
37
|
```
|
|
23
38
|
|
|
39
|
+
## Setup
|
|
40
|
+
|
|
41
|
+
### 1. Run the migration generator
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
$ rails generate chat_manager:modeling
|
|
45
|
+
$ rails db:migrate
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This creates the `chat_manager_chats` table with the following columns:
|
|
49
|
+
|
|
50
|
+
| Column | Type | Description |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| `uuid` | string (NOT NULL) | Unique identifier for the chat |
|
|
53
|
+
| `title` | string | Chat title (auto-generated or manually set) |
|
|
54
|
+
| `llm_uuid` | string | LLM identifier |
|
|
55
|
+
| `model` | string | Model name/type |
|
|
56
|
+
| `created_at` | datetime | Timestamp |
|
|
57
|
+
| `updated_at` | datetime | Timestamp |
|
|
58
|
+
|
|
59
|
+
### 2. Include concerns in your controller
|
|
60
|
+
|
|
61
|
+
```ruby
|
|
62
|
+
class ChatsController < ApplicationController
|
|
63
|
+
include ChatManager::ChatManageable
|
|
64
|
+
include ChatManager::CsvDownloadable
|
|
65
|
+
|
|
66
|
+
def index
|
|
67
|
+
initialize_chat(current_user.chats)
|
|
68
|
+
set_active_chat_uuid(params[:uuid])
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 3. Include the title generation concern in your model
|
|
74
|
+
|
|
75
|
+
```ruby
|
|
76
|
+
class Chat < ApplicationRecord
|
|
77
|
+
include ChatManager::TitleGeneratable
|
|
78
|
+
|
|
79
|
+
# You must implement this method
|
|
80
|
+
def summarize_for_title(prompt_text, jwt_token)
|
|
81
|
+
# Call your LLM API to generate a title from the prompt
|
|
82
|
+
# Return a string (max 255 characters)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Usage
|
|
88
|
+
|
|
89
|
+
### ChatManageable (Controller Concern)
|
|
90
|
+
|
|
91
|
+
Provides methods for managing chat arrays in your controller:
|
|
92
|
+
|
|
93
|
+
```ruby
|
|
94
|
+
initialize_chat(chats) # Initialize with a collection of chats
|
|
95
|
+
set_active_chat_uuid(uuid) # Set the active chat UUID
|
|
96
|
+
add_chat(chat) # Add a chat (prevents nil and duplicates)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### CsvDownloadable (Controller Concern)
|
|
100
|
+
|
|
101
|
+
Provides CSV export actions:
|
|
102
|
+
|
|
103
|
+
```ruby
|
|
104
|
+
download_csv # Download a single chat as CSV
|
|
105
|
+
download_all_csv # Download all user chats as CSV
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
CSV output includes the following columns: `Chat Title`, `Role`, `Message Content`, `Sent At`, `Model`.
|
|
109
|
+
|
|
110
|
+
**Prerequisites:** The host application must provide:
|
|
111
|
+
|
|
112
|
+
- `current_user` method in the controller (returning an object with a `chats` association)
|
|
113
|
+
- `chats` association that supports `.includes(messages: :prompt_manager_prompt_execution)`
|
|
114
|
+
- `ordered_messages` method on the Chat model
|
|
115
|
+
- Each message must have a `role` attribute and a `prompt_manager_prompt_execution` association with `prompt` and `response` attributes
|
|
116
|
+
|
|
117
|
+
### TitleGeneratable (Model Concern)
|
|
118
|
+
|
|
119
|
+
Generates a chat title from the initial user prompt:
|
|
120
|
+
|
|
121
|
+
```ruby
|
|
122
|
+
chat.generate_title(prompt_text, jwt_token)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Delegates to the `summarize_for_title` method which must be implemented by the including model.
|
|
126
|
+
|
|
127
|
+
### View Helper
|
|
128
|
+
|
|
129
|
+
Use the `chat_list` helper in your views to render the chat list UI:
|
|
130
|
+
|
|
131
|
+
```erb
|
|
132
|
+
<%= chat_list(
|
|
133
|
+
->(uuid) { chat_path(uuid) },
|
|
134
|
+
active_uuid: @active_uuid,
|
|
135
|
+
download_csv_path: ->(uuid) { download_csv_chat_path(uuid) },
|
|
136
|
+
download_all_csv_path: download_all_csv_chats_path
|
|
137
|
+
) %>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Parameters:
|
|
141
|
+
|
|
142
|
+
| Parameter | Type | Required | Description |
|
|
143
|
+
|---|---|---|---|
|
|
144
|
+
| `card_path` | Positional | Yes | Proc/lambda that receives a UUID string and returns the path for each chat card link |
|
|
145
|
+
| `active_uuid` | Keyword | No | ID of the currently active chat (for highlighting) |
|
|
146
|
+
| `download_csv_path` | Keyword | No | Proc/lambda that receives a UUID string and returns the CSV download path for each chat |
|
|
147
|
+
| `download_all_csv_path` | Keyword | No | Path for the "Download All Chats CSV" button |
|
|
148
|
+
|
|
149
|
+
### UI Components
|
|
150
|
+
|
|
151
|
+
The engine provides two partials:
|
|
152
|
+
|
|
153
|
+
- **`chat_manager/chat_list`** — Renders the full chat list with optional bulk CSV download button
|
|
154
|
+
- **`chat_manager/chat_card`** — Renders an individual chat card with:
|
|
155
|
+
- Title display (truncated to 30 characters)
|
|
156
|
+
- Active state highlighting
|
|
157
|
+
- Inline title editing via Stimulus (`chat-title-edit` controller)
|
|
158
|
+
- Optional per-chat CSV download button
|
|
159
|
+
|
|
160
|
+
### Stylesheets
|
|
161
|
+
|
|
162
|
+
The engine includes CSS for the chat interface. Available CSS classes:
|
|
163
|
+
|
|
164
|
+
- `.chat-stack` — Flex column layout for the chat list
|
|
165
|
+
- `.chat-card` — Card styling with hover effects and active state (`.is-active` modifier)
|
|
166
|
+
- `.chat-card-row` — Flex row layout for card content and download button
|
|
167
|
+
- `.chat-card-link` — Grid layout for card link area
|
|
168
|
+
- `.chat-card-prompt` — Title text display with line clamping
|
|
169
|
+
- `.chat-card-number` — Chat number label
|
|
170
|
+
- `.chat-card-download` — Per-chat CSV download button
|
|
171
|
+
- `.chat-card-title-input` — Inline edit input field
|
|
172
|
+
- `.chat-download-all` — Container for the bulk download button
|
|
173
|
+
- `.chat-download-all-link` — Bulk download button
|
|
174
|
+
|
|
24
175
|
## Contributing
|
|
25
|
-
|
|
176
|
+
|
|
177
|
+
1. Fork it
|
|
178
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
179
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
180
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
181
|
+
5. Create a new Pull Request
|
|
26
182
|
|
|
27
183
|
## License
|
|
184
|
+
|
|
28
185
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/chat_manager/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chat_manager
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- dhq_boiler
|
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
95
|
version: '0'
|
|
96
96
|
requirements: []
|
|
97
|
-
rubygems_version:
|
|
97
|
+
rubygems_version: 4.0.3
|
|
98
98
|
specification_version: 4
|
|
99
99
|
summary: A Rails engine for managing LLM chat conversations with CSV export and auto-titling.
|
|
100
100
|
test_files: []
|