tracebook 0.1.0 → 0.1.1
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 +16 -2
- data/README.md +87 -124
- data/app/assets/stylesheets/tracebook/application.css +38 -0
- data/app/controllers/tracebook/interactions_controller.rb +3 -3
- data/app/models/tracebook/interaction.rb +8 -5
- data/app/views/tracebook/interactions/index.html.erb +3 -0
- data/config/routes.rb +2 -0
- data/lib/generators/tracebook/install/USAGE +10 -0
- data/lib/generators/tracebook/install/install_generator.rb +36 -0
- data/lib/generators/tracebook/install/templates/initializer.rb.tt +10 -0
- data/lib/tracebook/config.rb +5 -0
- data/lib/tracebook/version.rb +1 -1
- data/lib/tracebook.rb +3 -2
- metadata +19 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ae82d99eb8f5d552c59dbcb77d1a99c587ecd729a6597fea01c20411e3b866d8
|
|
4
|
+
data.tar.gz: ed9a874f85ec046d24469de3d48886ef0dee878959e964af41dd3843a9c7bd0f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f49482e0e49ccf7d7b5dd095eaf2a2ce2899f8eb3bbbb5d6d5c4e7b1c89bfc2cdd88015a361873e8c00fa28e18cf04c29456c5942ceefd25c26799614dd1b5c3
|
|
7
|
+
data.tar.gz: 3c613e6abc82a4bd30235fbaa4d4abef6606b61ae0d913bc27ea38f514185837e41efa729ad1a73d0af367eb178fc27ce043bcd94d73c164d538ab57631c78d2
|
data/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,21 @@ 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
|
-
## [
|
|
8
|
+
## [0.1.1] - 2025-12-16
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Install Generator**: `bin/rails generate tracebook:install` for simplified setup
|
|
13
|
+
- **Pagination**: UI pagination for interactions list using Pagy
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **Root Route**: Added missing root route redirect to `/interactions`
|
|
18
|
+
- **Payload Keys**: Fixed `build_normalized_interaction` using wrong keys for payloads
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- **Documentation**: Clarified that encryption is optional, added setup instructions for users who want to enable it
|
|
9
23
|
|
|
10
24
|
## [0.1.0] - 2025-11-12
|
|
11
25
|
|
|
@@ -39,5 +53,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
39
53
|
- **Normalized Schema**: Consistent data structure across all providers
|
|
40
54
|
- **Test Suite**: Full MiniTest coverage for models, controllers, jobs, and lib
|
|
41
55
|
|
|
42
|
-
[
|
|
56
|
+
[0.1.1]: https://github.com/dpaluy/tracebook/compare/v0.1.0...v0.1.1
|
|
43
57
|
[0.1.0]: https://github.com/dpaluy/tracebook/releases/tag/v0.1.0
|
data/README.md
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
[](https://rubygems.org/gems/tracebook)
|
|
4
4
|
[](https://github.com/dpaluy/tracebook/actions/workflows/ci.yml)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
> **Note:** This gem is in active development. APIs may change before 1.0 release.
|
|
7
|
+
|
|
8
|
+
TraceBook is a Rails engine that ingests, redacts, and reviews LLM interactions with optional encryption. It ships with a Hotwire UI, cost tracking, rollup analytics, and adapters for popular Ruby LLM libraries.
|
|
7
9
|
|
|
8
10
|
## Features
|
|
9
11
|
|
|
10
|
-
- **Privacy-first**: Request/response payloads are redacted (PII removal)
|
|
12
|
+
- **Privacy-first**: Request/response payloads are redacted (PII removal) with optional encryption at rest
|
|
11
13
|
- **Cost tracking**: Automatic token usage and cost calculation per provider/model
|
|
12
14
|
- **Review workflow**: Approve, flag, or reject interactions with audit trail
|
|
13
15
|
- **Hierarchical sessions**: Track parent-child relationships for agent chains
|
|
@@ -34,78 +36,36 @@ TraceBook is a Rails engine that ingests, redacts, encrypts, and reviews LLM int
|
|
|
34
36
|
- [Cost Tracking](#cost-tracking)
|
|
35
37
|
- [Reviewing Data](#reviewing-data)
|
|
36
38
|
- [Production Setup](#production-setup)
|
|
39
|
+
- [Securing the Dashboard](#securing-the-dashboard)
|
|
37
40
|
- [Development & Testing](#development--testing)
|
|
38
41
|
|
|
39
42
|
## Installation & Setup
|
|
40
43
|
|
|
41
|
-
### 1. Add the gem
|
|
42
|
-
|
|
43
|
-
```ruby
|
|
44
|
-
# Gemfile
|
|
45
|
-
gem "tracebook" # or path: "../gems/tracebook" for local development
|
|
46
|
-
```
|
|
47
|
-
|
|
48
44
|
```bash
|
|
49
|
-
bundle
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
### 2. Install migrations
|
|
53
|
-
|
|
54
|
-
Rails engines keep migrations inside the gem. Copy them into the host app and migrate:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
bin/rails railties:install:migrations FROM=tracebook
|
|
45
|
+
bundle add tracebook
|
|
46
|
+
bin/rails generate tracebook:install
|
|
58
47
|
bin/rails db:migrate
|
|
59
48
|
```
|
|
60
49
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
- **`tracebook_interactions`** — Main table for LLM calls
|
|
64
|
-
- Encrypted columns: `request`, `response`, `review_comment`
|
|
65
|
-
- Indexes: `provider`, `model`, `review_state`, `session_id`, `parent_id`, `occurred_at`
|
|
66
|
-
- Fields: provider, model, request (JSONB), response (JSONB), usage stats, duration, review metadata, tags, etc.
|
|
67
|
-
|
|
68
|
-
- **`tracebook_pricing_rules`** — Cost per 1k tokens for provider/model patterns
|
|
69
|
-
- Fields: `provider`, `model_pattern` (glob), `input_per_1k`, `output_per_1k`, `currency`, `effective_from`
|
|
70
|
-
- Example: `provider: "openai", model_pattern: "gpt-4o*", input_per_1k: 2.50, output_per_1k: 10.00`
|
|
71
|
-
|
|
72
|
-
- **`tracebook_redaction_rules`** — PII detection patterns
|
|
73
|
-
- Fields: `name`, `pattern` (regex), `detector` (class name), `replacement`, `enabled`
|
|
74
|
-
- Built-in rules: email addresses, SSNs, credit cards, phone numbers
|
|
75
|
-
|
|
76
|
-
- **`tracebook_rollup_daily`** — Aggregated metrics by date/provider/model/project
|
|
77
|
-
- Composite PK: `(date, provider, model, project)`
|
|
78
|
-
- Fields: call counts, token sums, cost totals, error rates, avg duration
|
|
50
|
+
The install generator copies migrations and creates `config/initializers/tracebook.rb`.
|
|
79
51
|
|
|
80
|
-
|
|
52
|
+
### Mount the engine
|
|
81
53
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
Update `config/routes.rb` to expose the UI:
|
|
54
|
+
Add to `config/routes.rb`:
|
|
85
55
|
|
|
86
56
|
```ruby
|
|
87
|
-
|
|
88
|
-
Rails.application.routes.draw do
|
|
89
|
-
# Wrap with authentication/authorization
|
|
90
|
-
authenticate :user, ->(u) { u.admin? } do
|
|
91
|
-
mount TraceBook::Engine => "/tracebook"
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# Or use a constraint
|
|
95
|
-
constraints -> (req) { req.session[:user_id] && User.find(req.session[:user_id])&.admin? } do
|
|
96
|
-
mount TraceBook::Engine => "/tracebook"
|
|
97
|
-
end
|
|
98
|
-
end
|
|
57
|
+
mount TraceBook::Engine => "/tracebook"
|
|
99
58
|
```
|
|
100
59
|
|
|
101
|
-
|
|
60
|
+
See [Securing the Dashboard](#securing-the-dashboard) for authentication options.
|
|
61
|
+
|
|
62
|
+
### Optional: Configure encryption
|
|
102
63
|
|
|
103
|
-
|
|
64
|
+
TraceBook supports ActiveRecord::Encryption for encrypting sensitive payload data at rest. This is **optional** but recommended for production environments handling sensitive data.
|
|
104
65
|
|
|
105
|
-
|
|
66
|
+
**Step 1: Generate encryption keys**
|
|
106
67
|
|
|
107
68
|
```bash
|
|
108
|
-
# Generate encryption keys
|
|
109
69
|
bin/rails db:encryption:init
|
|
110
70
|
```
|
|
111
71
|
|
|
@@ -118,7 +78,7 @@ active_record_encryption:
|
|
|
118
78
|
key_derivation_salt: [generated_salt]
|
|
119
79
|
```
|
|
120
80
|
|
|
121
|
-
Add
|
|
81
|
+
**Step 2: Add keys to credentials**
|
|
122
82
|
|
|
123
83
|
```bash
|
|
124
84
|
EDITOR=vim bin/rails credentials:edit
|
|
@@ -132,81 +92,50 @@ active_record_encryption:
|
|
|
132
92
|
key_derivation_salt: <generated_salt>
|
|
133
93
|
```
|
|
134
94
|
|
|
135
|
-
|
|
95
|
+
**Step 3: Enable encryption in your app**
|
|
96
|
+
|
|
97
|
+
Create an initializer to add encryption to the Interaction model:
|
|
98
|
+
|
|
99
|
+
```ruby
|
|
100
|
+
# config/initializers/tracebook_encryption.rb
|
|
101
|
+
Rails.application.config.after_initialize do
|
|
102
|
+
Tracebook::Interaction.class_eval do
|
|
103
|
+
encrypts :request_payload, :response_payload
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
> **Note**: Enabling encryption on an existing database requires migrating existing unencrypted data. See the [Rails encryption guide](https://guides.rubyonrails.org/active_record_encryption.html) for migration strategies.
|
|
136
109
|
|
|
137
110
|
## Configuration
|
|
138
111
|
|
|
139
|
-
|
|
112
|
+
The install generator creates `config/initializers/tracebook.rb` with sensible defaults.
|
|
113
|
+
|
|
114
|
+
Available options:
|
|
140
115
|
|
|
141
116
|
```ruby
|
|
142
117
|
TraceBook.configure do |config|
|
|
143
|
-
#
|
|
144
|
-
|
|
145
|
-
# ========================================
|
|
146
|
-
# This proc receives (user, action, resource) and must return true/false
|
|
147
|
-
# Actions: :read, :review, :export
|
|
148
|
-
config.authorize = ->(user, action, resource) do
|
|
149
|
-
case action
|
|
150
|
-
when :read
|
|
151
|
-
user&.admin? || user&.reviewer?
|
|
152
|
-
when :review
|
|
153
|
-
user&.admin?
|
|
154
|
-
when :export
|
|
155
|
-
user&.admin?
|
|
156
|
-
else
|
|
157
|
-
false
|
|
158
|
-
end
|
|
159
|
-
end
|
|
118
|
+
# Project identifier for filtering in the dashboard
|
|
119
|
+
config.project_name = "My App"
|
|
160
120
|
|
|
161
|
-
#
|
|
162
|
-
#
|
|
163
|
-
# ========================================
|
|
164
|
-
# Project identifier for this application
|
|
165
|
-
config.project_name = "TraceBook Dashboard"
|
|
166
|
-
|
|
167
|
-
# ========================================
|
|
168
|
-
# OPTIONAL: Persistence
|
|
169
|
-
# ========================================
|
|
170
|
-
# Use async jobs for persistence (recommended for production)
|
|
171
|
-
# When true, TraceBook.record! enqueues PersistInteractionJob
|
|
172
|
-
# When false, writes happen inline (useful for tests)
|
|
121
|
+
# Use async jobs for persistence (default: true)
|
|
122
|
+
# Set to false for tests or simple setups
|
|
173
123
|
config.persist_async = Rails.env.production?
|
|
174
124
|
|
|
175
|
-
# Payload size threshold for ActiveStorage spillover (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
#
|
|
183
|
-
config.
|
|
184
|
-
|
|
185
|
-
# ========================================
|
|
186
|
-
# OPTIONAL: Export
|
|
187
|
-
# ========================================
|
|
188
|
-
# Available export formats
|
|
189
|
-
config.export_formats = %i[csv ndjson]
|
|
190
|
-
|
|
191
|
-
# ========================================
|
|
192
|
-
# OPTIONAL: Redaction
|
|
193
|
-
# ========================================
|
|
194
|
-
# Custom PII redactors (in addition to built-in email/SSN/etc)
|
|
195
|
-
config.redactors += [
|
|
196
|
-
->(payload) {
|
|
197
|
-
# Example: Redact API keys
|
|
198
|
-
payload.gsub(/api_key["\s]*[:=]["\s]*\K[\w-]+/, "[REDACTED]")
|
|
199
|
-
},
|
|
200
|
-
->(payload) {
|
|
201
|
-
# Example: Redact authorization headers
|
|
202
|
-
payload.gsub(/authorization["\s]*:["\s]*\K[^"]+/, "[REDACTED]")
|
|
203
|
-
}
|
|
125
|
+
# Payload size threshold for ActiveStorage spillover (default: 64KB)
|
|
126
|
+
config.inline_payload_bytes = 64 * 1024
|
|
127
|
+
|
|
128
|
+
# Auto-enable adapters on boot
|
|
129
|
+
config.auto_subscribe_ruby_llm = true
|
|
130
|
+
config.auto_subscribe_active_agent = true
|
|
131
|
+
|
|
132
|
+
# Custom PII redactors (in addition to built-in email/phone/card)
|
|
133
|
+
config.custom_redactors += [
|
|
134
|
+
->(payload) { payload.gsub(/api_key=\w+/, "api_key=[REDACTED]") }
|
|
204
135
|
]
|
|
205
136
|
end
|
|
206
137
|
```
|
|
207
138
|
|
|
208
|
-
**Important**: The `authorize` proc is mandatory. TraceBook will raise an error on boot if it's missing.
|
|
209
|
-
|
|
210
139
|
Configuration is frozen after the block runs. Call `TraceBook.reset_configuration!` in tests when you need a clean slate.
|
|
211
140
|
|
|
212
141
|
## Capturing Interactions
|
|
@@ -271,7 +200,7 @@ When `config.persist_async = true`, the interaction is enqueued via `Tracebook::
|
|
|
271
200
|
|
|
272
201
|
### Background Jobs & Rollups
|
|
273
202
|
|
|
274
|
-
**PersistInteractionJob** handles redaction,
|
|
203
|
+
**PersistInteractionJob** handles redaction, cost calculation, and writes the `Interaction` record.
|
|
275
204
|
|
|
276
205
|
**DailyRollupsJob** summarizes counts, token totals, and cost into `RollupDaily` rows. Schedule it nightly per provider/model/project:
|
|
277
206
|
|
|
@@ -705,6 +634,40 @@ Only `admin` users (as defined in your `authorize` proc) can change review state
|
|
|
705
634
|
|
|
706
635
|
## Production Setup
|
|
707
636
|
|
|
637
|
+
### Securing the Dashboard
|
|
638
|
+
|
|
639
|
+
The dashboard should only be accessible to trusted reviewers. Here are common approaches:
|
|
640
|
+
|
|
641
|
+
**Devise with admin check:**
|
|
642
|
+
|
|
643
|
+
```ruby
|
|
644
|
+
# config/routes.rb
|
|
645
|
+
authenticate :user, ->(u) { u.admin? } do
|
|
646
|
+
mount TraceBook::Engine => "/tracebook"
|
|
647
|
+
end
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
**Session-based constraint:**
|
|
651
|
+
|
|
652
|
+
```ruby
|
|
653
|
+
# config/routes.rb
|
|
654
|
+
constraints ->(req) { req.session[:admin] } do
|
|
655
|
+
mount TraceBook::Engine => "/tracebook"
|
|
656
|
+
end
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
**HTTP Basic Auth (simple setups):**
|
|
660
|
+
|
|
661
|
+
```ruby
|
|
662
|
+
# config/routes.rb
|
|
663
|
+
TraceBook::Engine.middleware.use Rack::Auth::Basic do |username, password|
|
|
664
|
+
ActiveSupport::SecurityUtils.secure_compare(username, ENV["TRACEBOOK_USER"]) &
|
|
665
|
+
ActiveSupport::SecurityUtils.secure_compare(password, ENV["TRACEBOOK_PASSWORD"])
|
|
666
|
+
end
|
|
667
|
+
|
|
668
|
+
mount TraceBook::Engine => "/tracebook"
|
|
669
|
+
```
|
|
670
|
+
|
|
708
671
|
### Queue Adapter
|
|
709
672
|
|
|
710
673
|
Configure ActiveJob to use a production queue backend:
|
|
@@ -714,9 +677,9 @@ Configure ActiveJob to use a production queue backend:
|
|
|
714
677
|
config.active_job.queue_adapter = :sidekiq # or :solid_queue, etc.
|
|
715
678
|
```
|
|
716
679
|
|
|
717
|
-
### Encryption Keys
|
|
680
|
+
### Encryption Keys (if enabled)
|
|
718
681
|
|
|
719
|
-
|
|
682
|
+
If you've enabled payload encryption (see [Configure encryption](#optional-configure-encryption)), store keys securely:
|
|
720
683
|
|
|
721
684
|
- Use Rails encrypted credentials (`bin/rails credentials:edit`)
|
|
722
685
|
- Or environment variables with a secrets manager (AWS Secrets Manager, HashiCorp Vault)
|
|
@@ -812,10 +775,10 @@ bundle exec rubocop --fix-unsafe # Fix style issues
|
|
|
812
775
|
|
|
813
776
|
### Inside a host application
|
|
814
777
|
|
|
815
|
-
After
|
|
778
|
+
After updating the gem, install any new migrations:
|
|
816
779
|
|
|
817
780
|
```bash
|
|
818
|
-
bin/rails
|
|
781
|
+
bin/rails tracebook:install:migrations
|
|
819
782
|
bin/rails db:migrate
|
|
820
783
|
```
|
|
821
784
|
|
|
@@ -171,3 +171,41 @@ pre {
|
|
|
171
171
|
border-radius: 0.5rem;
|
|
172
172
|
overflow-x: auto;
|
|
173
173
|
}
|
|
174
|
+
|
|
175
|
+
.tb-pagination {
|
|
176
|
+
display: flex;
|
|
177
|
+
justify-content: center;
|
|
178
|
+
padding: 1rem 0;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.tb-pagination nav {
|
|
182
|
+
display: flex;
|
|
183
|
+
gap: 0.25rem;
|
|
184
|
+
align-items: center;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.tb-pagination a,
|
|
188
|
+
.tb-pagination span {
|
|
189
|
+
padding: 0.5rem 0.75rem;
|
|
190
|
+
border: 1px solid var(--tb-border);
|
|
191
|
+
border-radius: 0.375rem;
|
|
192
|
+
text-decoration: none;
|
|
193
|
+
color: var(--tb-text);
|
|
194
|
+
font-size: 0.875rem;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.tb-pagination a:hover {
|
|
198
|
+
background: rgba(11, 95, 255, 0.08);
|
|
199
|
+
border-color: var(--tb-accent);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.tb-pagination .current {
|
|
203
|
+
background: var(--tb-accent);
|
|
204
|
+
color: white;
|
|
205
|
+
border-color: var(--tb-accent);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.tb-pagination .disabled {
|
|
209
|
+
color: var(--tb-muted);
|
|
210
|
+
cursor: not-allowed;
|
|
211
|
+
}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
module Tracebook
|
|
4
4
|
class InteractionsController < ApplicationController
|
|
5
|
+
include Pagy::Method
|
|
6
|
+
|
|
5
7
|
before_action :set_interaction, only: [ :show, :review ]
|
|
6
8
|
helper InteractionsHelper
|
|
7
9
|
|
|
8
|
-
PER_PAGE = 100
|
|
9
|
-
|
|
10
10
|
def index
|
|
11
11
|
@filters = filter_params
|
|
12
12
|
scope = Interaction.filtered(@filters)
|
|
13
13
|
@kpis = kpis_for(scope)
|
|
14
|
-
@interactions = scope.order(created_at: :desc).
|
|
14
|
+
@pagy, @interactions = pagy(scope.order(created_at: :desc), limit: Tracebook.config.per_page)
|
|
15
15
|
@providers = Interaction.distinct.order(:provider).pluck(:provider)
|
|
16
16
|
@models = Interaction.distinct.order(:model).pluck(:model)
|
|
17
17
|
@projects = Interaction.distinct.order(:project).pluck(:project).compact
|
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
module Tracebook
|
|
4
4
|
# ActiveRecord model for LLM interactions.
|
|
5
5
|
#
|
|
6
|
-
# Stores all data related to an LLM API call including request/response payloads
|
|
7
|
-
#
|
|
6
|
+
# Stores all data related to an LLM API call including request/response payloads,
|
|
7
|
+
# usage metrics, cost, review state, and relationships.
|
|
8
8
|
#
|
|
9
|
-
# ##
|
|
10
|
-
# - `request_payload` - Full request sent to provider
|
|
11
|
-
# - `response_payload` - Full response from provider
|
|
9
|
+
# ## Payload Fields
|
|
10
|
+
# - `request_payload` - Full request sent to provider (JSON)
|
|
11
|
+
# - `response_payload` - Full response from provider (JSON)
|
|
12
12
|
# - `review_comment` - Reviewer's comments
|
|
13
13
|
#
|
|
14
|
+
# Note: Encryption is optional. See README for instructions on enabling
|
|
15
|
+
# ActiveRecord::Encryption for these fields.
|
|
16
|
+
#
|
|
14
17
|
# ## Enums
|
|
15
18
|
# - `status`: `:success`, `:error`, `:canceled`
|
|
16
19
|
# - `review_state`: `:pending`, `:approved`, `:flagged`, `:rejected`
|
data/config/routes.rb
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
Install TraceBook by copying migrations and creating an initializer.
|
|
3
|
+
|
|
4
|
+
Example:
|
|
5
|
+
bin/rails generate tracebook:install
|
|
6
|
+
|
|
7
|
+
After running:
|
|
8
|
+
1. Run: bin/rails db:migrate
|
|
9
|
+
2. Mount the engine in config/routes.rb
|
|
10
|
+
3. Configure authorization in the initializer
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators/base"
|
|
4
|
+
|
|
5
|
+
module Tracebook
|
|
6
|
+
module Generators
|
|
7
|
+
class InstallGenerator < Rails::Generators::Base
|
|
8
|
+
source_root File.expand_path("templates", __dir__)
|
|
9
|
+
|
|
10
|
+
desc "Install TraceBook: copy migrations and create initializer"
|
|
11
|
+
|
|
12
|
+
def copy_migrations
|
|
13
|
+
rake "tracebook:install:migrations"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def create_initializer
|
|
17
|
+
template "initializer.rb.tt", "config/initializers/tracebook.rb"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def show_next_steps
|
|
21
|
+
say ""
|
|
22
|
+
say "TraceBook installed!", :green
|
|
23
|
+
say ""
|
|
24
|
+
say "Next steps:"
|
|
25
|
+
say " 1. Run migrations: bin/rails db:migrate"
|
|
26
|
+
say " 2. Mount the engine in config/routes.rb:"
|
|
27
|
+
say ""
|
|
28
|
+
say " mount TraceBook::Engine => \"/tracebook\""
|
|
29
|
+
say ""
|
|
30
|
+
say " 3. Configure authorization in config/initializers/tracebook.rb"
|
|
31
|
+
say " 4. Set up ActiveRecord encryption (see README)"
|
|
32
|
+
say ""
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/tracebook/config.rb
CHANGED
|
@@ -74,6 +74,10 @@ module Tracebook
|
|
|
74
74
|
# @return [Boolean] Auto-enable ActiveAgent adapter on boot (default: false)
|
|
75
75
|
attr_accessor :auto_subscribe_active_agent
|
|
76
76
|
|
|
77
|
+
# @!attribute [rw] per_page
|
|
78
|
+
# @return [Integer] Number of interactions per page in dashboard (default: 100)
|
|
79
|
+
attr_accessor :per_page
|
|
80
|
+
|
|
77
81
|
# Creates a new configuration with default values.
|
|
78
82
|
#
|
|
79
83
|
# @return [Config]
|
|
@@ -87,6 +91,7 @@ module Tracebook
|
|
|
87
91
|
@custom_redactors = []
|
|
88
92
|
@auto_subscribe_ruby_llm = false
|
|
89
93
|
@auto_subscribe_active_agent = false
|
|
94
|
+
@per_page = 100
|
|
90
95
|
end
|
|
91
96
|
|
|
92
97
|
# Returns true if configuration has been finalized.
|
data/lib/tracebook/version.rb
CHANGED
data/lib/tracebook.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require "pagy"
|
|
1
2
|
require "tracebook/version"
|
|
2
3
|
require "tracebook/engine"
|
|
3
4
|
require "tracebook/errors"
|
|
@@ -178,8 +179,8 @@ module Tracebook
|
|
|
178
179
|
provider: attributes.fetch(:provider),
|
|
179
180
|
model: attributes.fetch(:model),
|
|
180
181
|
project: attributes[:project],
|
|
181
|
-
request_payload: attributes[:
|
|
182
|
-
response_payload: attributes[:
|
|
182
|
+
request_payload: attributes[:request_payload],
|
|
183
|
+
response_payload: attributes[:response_payload],
|
|
183
184
|
request_text: attributes[:request_text],
|
|
184
185
|
response_text: attributes[:response_text],
|
|
185
186
|
input_tokens: attributes[:input_tokens],
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tracebook
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- dpaluy
|
|
@@ -65,6 +65,20 @@ dependencies:
|
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
67
|
version: '3.3'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: pagy
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '43.0'
|
|
75
|
+
type: :runtime
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '43.0'
|
|
68
82
|
description: TraceBook provides a Rails engine for capturing, storing, and reviewing
|
|
69
83
|
LLM API interactions with built-in support for OpenAI, Anthropic, and Ollama. Features
|
|
70
84
|
include PII redaction, cost tracking, review workflows, and export capabilities.
|
|
@@ -109,6 +123,9 @@ files:
|
|
|
109
123
|
- db/migrate/20241112000200_create_tracebook_rollups_dailies.rb
|
|
110
124
|
- db/migrate/20241112000300_create_tracebook_pricing_rules.rb
|
|
111
125
|
- db/migrate/20241112000400_create_tracebook_redaction_rules.rb
|
|
126
|
+
- lib/generators/tracebook/install/USAGE
|
|
127
|
+
- lib/generators/tracebook/install/install_generator.rb
|
|
128
|
+
- lib/generators/tracebook/install/templates/initializer.rb.tt
|
|
112
129
|
- lib/tasks/tracebook_tasks.rake
|
|
113
130
|
- lib/tasks/yard.rake
|
|
114
131
|
- lib/tracebook.rb
|
|
@@ -158,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
158
175
|
- !ruby/object:Gem::Version
|
|
159
176
|
version: '0'
|
|
160
177
|
requirements: []
|
|
161
|
-
rubygems_version:
|
|
178
|
+
rubygems_version: 3.6.9
|
|
162
179
|
specification_version: 4
|
|
163
180
|
summary: Rails engine for LLM interaction telemetry and review.
|
|
164
181
|
test_files: []
|