llm_logs 0.2.2 → 0.2.5

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: 5eb2c037f1c19d83e843722bd9ca664324311e7fb6b75de47a96569919cae05b
4
- data.tar.gz: 0db8f27945ce97dd74f9e4fedb5c337b68af537a83ab17dfc3f6bcd9ad18d360
3
+ metadata.gz: 3bb808cbb1283ea0377f8f86fea214292206fd926417f06210226c937880228d
4
+ data.tar.gz: 15565f490c2d97e4548fa1f49adef4f8d21d3caf77b787cc01fd50dcd2ad0d09
5
5
  SHA512:
6
- metadata.gz: fa82e4b390f8528a1d89c386ffb92b3c51f7e2f496ecec4061d4357dac679eb880dec648f6ca2d8885c256b3f175c8821a96143e318ac4e875dfa39aea4fe578
7
- data.tar.gz: 8f3c2ae33e33667c3b4d1afa60a3afbe3154e6f5f6c9982892e772d4c8d7c60f5b5fa7c437ab5c597f79f9eefe9a0ecafea1642f6280e0508143d91ee20d50b2
6
+ metadata.gz: 07cffca75a8ced5f19a8e0b54cd3b0b161f6c610453f21e40f421b0e1c62cdd6a64acb706f09bf9850a2275eb03061f0e67caf4c4d6d5a6a58ef349485553cdc
7
+ data.tar.gz: 28ec05567c6ced0eb8b9b61d74a4d153e53b9a5c2fa6a76710a6b524856b025946d6e2dde06858fad26b1a6ed0fb81506f0dd7d3565a493069611382e4df01f8
data/README.md CHANGED
@@ -267,6 +267,7 @@ LlmLogs.setup do |config|
267
267
  config.prompt_subfolders = %w[skills fragments templates]
268
268
  config.batch_enabled = true # enable the batch API integration
269
269
  config.batch_provider = :openai_responses # batch backend
270
+ config.page_size = 50 # rows per page on all index pages
270
271
  end
271
272
  ```
272
273
 
@@ -4,12 +4,12 @@ module LlmLogs
4
4
  @batches = Batch.recent
5
5
  @batches = @batches.where(purpose: params[:purpose]) if params[:purpose].present?
6
6
  @batches = @batches.where(status: params[:status]) if params[:status].present?
7
- @batches = @batches.page(params[:page]).per(50)
7
+ @batches = @batches.page(params[:page]).per(LlmLogs.page_size)
8
8
  end
9
9
 
10
10
  def show
11
11
  @batch = Batch.find(params[:id])
12
- @requests = @batch.requests.order(:created_at).page(params[:page]).per(100)
12
+ @requests = @batch.requests.order(:created_at).page(params[:page]).per(LlmLogs.page_size)
13
13
  end
14
14
  end
15
15
  end
@@ -8,7 +8,7 @@ module LlmLogs
8
8
  @direction = params[:direction] == "desc" ? "desc" : "asc"
9
9
  scope = Prompt.order(SORT_COLUMNS.fetch(@sort) => @direction.to_sym).includes(:versions)
10
10
  scope = scope.with_tag(tag) if tag
11
- @prompts = scope.page(params[:page]).per(25)
11
+ @prompts = scope.page(params[:page]).per(LlmLogs.page_size)
12
12
  @active_tag = tag
13
13
  @all_tags = Prompt.pluck(:tags).flatten.compact.uniq.sort
14
14
  end
@@ -1,13 +1,13 @@
1
1
  module LlmLogs
2
2
  class TracesController < ApplicationController
3
3
  def index
4
- @traces = Trace.recent
4
+ @traces = Trace.recent.includes(batch_request: :batch)
5
5
  @traces = @traces.by_status(params[:status]) if params[:status].present?
6
6
  if params[:prompt_version_id].present?
7
7
  @traces = @traces.where(prompt_version_id: params[:prompt_version_id])
8
8
  @filter_version = PromptVersion.find_by(id: params[:prompt_version_id])
9
9
  end
10
- @traces = @traces.page(params[:page]).per(50)
10
+ @traces = @traces.page(params[:page]).per(LlmLogs.page_size)
11
11
  end
12
12
 
13
13
  def show
@@ -1,6 +1,7 @@
1
1
  module LlmLogs
2
2
  class Trace < ApplicationRecord
3
3
  has_many :spans, dependent: :destroy
4
+ has_one :batch_request, class_name: "LlmLogs::BatchRequest", dependent: :nullify
4
5
  belongs_to :prompt_version, class_name: "LlmLogs::PromptVersion", optional: true
5
6
 
6
7
  validates :name, presence: true
@@ -15,6 +15,7 @@
15
15
  <table class="min-w-full divide-y divide-gray-200">
16
16
  <thead class="bg-gray-50">
17
17
  <tr>
18
+ <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">ID</th>
18
19
  <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Purpose</th>
19
20
  <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Model</th>
20
21
  <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">OpenAI Batch</th>
@@ -27,6 +28,7 @@
27
28
  <% status_colors = { "pending" => "bg-gray-100 text-gray-800", "submitted" => "bg-yellow-100 text-yellow-800", "completed" => "bg-blue-100 text-blue-800", "reconciled" => "bg-green-100 text-green-800", "failed" => "bg-red-100 text-red-800", "expired" => "bg-red-100 text-red-800" } %>
28
29
  <% @batches.each do |batch| %>
29
30
  <tr class="hover:bg-gray-50">
31
+ <td class="px-4 py-3 text-sm"><%= link_to "##{batch.id}", batch_path(batch), class: "text-indigo-600 hover:text-indigo-900 font-mono" %></td>
30
32
  <td class="px-4 py-3 text-sm"><%= link_to batch.purpose, batch_path(batch), class: "text-indigo-600 hover:text-indigo-900 font-medium" %></td>
31
33
  <td class="px-4 py-3 text-sm text-gray-500"><%= batch.model %></td>
32
34
  <td class="px-4 py-3 text-sm text-gray-500 font-mono"><%= batch.openai_batch_id %></td>
@@ -38,7 +40,7 @@
38
40
  </tr>
39
41
  <% end %>
40
42
  <% if @batches.empty? %>
41
- <tr><td colspan="6" class="px-4 py-8 text-center text-sm text-gray-500">No batches found.</td></tr>
43
+ <tr><td colspan="7" class="px-4 py-8 text-center text-sm text-gray-500">No batches found.</td></tr>
42
44
  <% end %>
43
45
  </tbody>
44
46
  </table>
@@ -35,7 +35,7 @@
35
35
  </dl>
36
36
  </td>
37
37
  <td class="px-4 py-3 text-sm">
38
- <%= link_to "trace", trace_path(request.trace_id), class: "text-indigo-600 hover:text-indigo-900" if request.trace_id %>
38
+ <%= link_to "##{request.trace_id}", trace_path(request.trace_id), class: "text-indigo-600 hover:text-indigo-900 font-mono" if request.trace_id %>
39
39
  </td>
40
40
  <td class="px-4 py-3 text-xs text-red-600"><%= request.error %></td>
41
41
  </tr>
@@ -28,6 +28,7 @@
28
28
  <table class="min-w-full divide-y divide-gray-200">
29
29
  <thead class="bg-gray-50">
30
30
  <tr>
31
+ <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">ID</th>
31
32
  <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Name</th>
32
33
  <th class="px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase">Spans</th>
33
34
  <th class="px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase">Tokens</th>
@@ -40,8 +41,12 @@
40
41
  <tbody class="divide-y divide-gray-200">
41
42
  <% @traces.each do |trace| %>
42
43
  <tr class="hover:bg-gray-50">
44
+ <td class="px-4 py-3 text-sm"><%= link_to "##{trace.id}", trace_path(trace), class: "text-indigo-600 hover:text-indigo-900 font-mono" %></td>
43
45
  <td class="px-4 py-3 text-sm">
44
46
  <%= link_to trace.name, trace_path(trace), class: "text-indigo-600 hover:text-indigo-900 font-medium" %>
47
+ <% if (batch = trace.batch_request&.batch) %>
48
+ <%= link_to "##{batch.id}", batch_path(batch), class: "ml-1 text-xs text-gray-400 hover:text-indigo-900", title: "Batch #{batch.purpose}" %>
49
+ <% end %>
45
50
  </td>
46
51
  <td class="px-4 py-3 text-sm text-gray-500 text-right"><%= trace.spans_count %></td>
47
52
  <td class="px-4 py-3 text-sm text-gray-500 text-right">
@@ -68,7 +73,7 @@
68
73
 
69
74
  <% if @traces.empty? %>
70
75
  <tr>
71
- <td colspan="7" class="px-4 py-8 text-center text-sm text-gray-500">No traces found.</td>
76
+ <td colspan="8" class="px-4 py-8 text-center text-sm text-gray-500">No traces found.</td>
72
77
  </tr>
73
78
  <% end %>
74
79
  </tbody>
@@ -1,7 +1,7 @@
1
1
  module LlmLogs
2
2
  class Configuration
3
3
  attr_accessor :enabled, :auto_instrument, :retention_days, :prompts_source_path, :prompt_subfolders,
4
- :batch_enabled, :batch_provider
4
+ :batch_enabled, :batch_provider, :page_size
5
5
 
6
6
  def initialize
7
7
  @enabled = true
@@ -11,6 +11,7 @@ module LlmLogs
11
11
  @prompt_subfolders = %w[skills fragments templates]
12
12
  @batch_enabled = true
13
13
  @batch_provider = :openai_responses
14
+ @page_size = 50
14
15
  end
15
16
  end
16
17
 
@@ -1,3 +1,3 @@
1
1
  module LlmLogs
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.5"
3
3
  end
data/lib/llm_logs.rb CHANGED
@@ -38,6 +38,14 @@ module LlmLogs
38
38
  configuration.retention_days = retention_days
39
39
  end
40
40
 
41
+ def self.page_size
42
+ configuration.page_size
43
+ end
44
+
45
+ def self.page_size=(page_size)
46
+ configuration.page_size = page_size
47
+ end
48
+
41
49
  def self.batch_enabled?
42
50
  configuration.batch_enabled
43
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm_logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton