llm_logs 0.1.3 → 0.1.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 +4 -4
- data/app/controllers/llm_logs/prompts_controller.rb +5 -1
- data/app/helpers/llm_logs/prompts_helper.rb +19 -0
- data/app/models/llm_logs/span.rb +2 -2
- data/app/views/llm_logs/prompts/index.html.erb +3 -3
- data/lib/llm_logs/tracer.rb +19 -10
- data/lib/llm_logs/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c9f1ecb908532e887783dec76409b9d1064e414c2560864b984dde135757e507
|
|
4
|
+
data.tar.gz: e2a6567f55ef52cb4defaed521506502640c2a57e1df33709c8a598910ef767c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60677029d50f6bb17c6a3e580643bbe2615a8886b2f9e5c40678e737175e41d6ab56d39990abccf7ce8a17354e4d101d7724273e987f70c0b65fdb48c1037317
|
|
7
|
+
data.tar.gz: 46fdf2fb90bfaf0ea4b85044c2f12baf38decb36d5d7f96e540d99cc4afecdf7a8b6a43322c3f45320111ecdc990aaf21a899d14623a7443aafff327a82e4dd5
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
module LlmLogs
|
|
2
2
|
class PromptsController < ApplicationController
|
|
3
|
+
SORT_COLUMNS = { "name" => :name, "slug" => :slug, "updated" => :updated_at }.freeze
|
|
4
|
+
|
|
3
5
|
def index
|
|
4
6
|
tag = params[:tag].is_a?(String) ? params[:tag].presence : nil
|
|
5
|
-
|
|
7
|
+
@sort = SORT_COLUMNS.key?(params[:sort]) ? params[:sort] : "name"
|
|
8
|
+
@direction = params[:direction] == "desc" ? "desc" : "asc"
|
|
9
|
+
scope = Prompt.order(SORT_COLUMNS.fetch(@sort) => @direction.to_sym).includes(:versions)
|
|
6
10
|
scope = scope.with_tag(tag) if tag
|
|
7
11
|
@prompts = scope.page(params[:page]).per(25)
|
|
8
12
|
@active_tag = tag
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module LlmLogs
|
|
2
|
+
module PromptsHelper
|
|
3
|
+
def sort_link(label, column)
|
|
4
|
+
active = @sort == column
|
|
5
|
+
next_direction = active && @direction == "asc" ? "desc" : "asc"
|
|
6
|
+
arrow = active ? (@direction == "asc" ? " ↑" : " ↓") : ""
|
|
7
|
+
|
|
8
|
+
link_to(
|
|
9
|
+
"#{label}#{arrow}",
|
|
10
|
+
prompts_path(
|
|
11
|
+
sort: column,
|
|
12
|
+
direction: next_direction,
|
|
13
|
+
tag: @active_tag
|
|
14
|
+
),
|
|
15
|
+
class: "hover:text-gray-700 #{'text-gray-900' if active}"
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/app/models/llm_logs/span.rb
CHANGED
|
@@ -15,8 +15,8 @@ module LlmLogs
|
|
|
15
15
|
duration_ms: (Time.current - started_at) * 1000
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
-
# Restore parent span as current
|
|
19
|
-
|
|
18
|
+
# Restore parent span as current (Fiber[] so child fibers inherit it)
|
|
19
|
+
LlmLogs::Tracer.current_span = parent_span
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def record_response(message)
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
<table class="min-w-full divide-y divide-gray-200">
|
|
18
18
|
<thead class="bg-gray-50">
|
|
19
19
|
<tr>
|
|
20
|
-
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"
|
|
21
|
-
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"
|
|
20
|
+
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"><%= sort_link "Name", "name" %></th>
|
|
21
|
+
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"><%= sort_link "Slug", "slug" %></th>
|
|
22
22
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Tags</th>
|
|
23
23
|
<th class="px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase">Version</th>
|
|
24
|
-
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"
|
|
24
|
+
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase"><%= sort_link "Updated", "updated" %></th>
|
|
25
25
|
</tr>
|
|
26
26
|
</thead>
|
|
27
27
|
<tbody class="divide-y divide-gray-200">
|
data/lib/llm_logs/tracer.rb
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
module LlmLogs
|
|
2
2
|
module Tracer
|
|
3
|
+
# Trace/span context is kept in Fiber-local storage (Fiber[]), which child
|
|
4
|
+
# fibers inherit on creation. This matters for fiber-based schedulers such as
|
|
5
|
+
# socketry/async: work driven inside a child fiber still sees the active
|
|
6
|
+
# trace. The legacy Thread.current[:key] store is *not* inherited by child
|
|
7
|
+
# fibers, which caused spans to auto-create orphan traces instead of nesting.
|
|
3
8
|
def self.current_trace
|
|
4
|
-
|
|
9
|
+
Fiber[:llm_logs_trace]
|
|
5
10
|
end
|
|
6
11
|
|
|
7
12
|
def self.current_span
|
|
8
|
-
|
|
13
|
+
Fiber[:llm_logs_span]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.current_span=(span)
|
|
17
|
+
Fiber[:llm_logs_span] = span
|
|
9
18
|
end
|
|
10
19
|
|
|
11
20
|
def self.start_trace(name, metadata: {})
|
|
@@ -16,10 +25,10 @@ module LlmLogs
|
|
|
16
25
|
started_at: Time.current
|
|
17
26
|
)
|
|
18
27
|
|
|
19
|
-
previous_trace =
|
|
20
|
-
previous_span =
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
previous_trace = Fiber[:llm_logs_trace]
|
|
29
|
+
previous_span = Fiber[:llm_logs_span]
|
|
30
|
+
Fiber[:llm_logs_trace] = trace
|
|
31
|
+
Fiber[:llm_logs_span] = nil
|
|
23
32
|
|
|
24
33
|
begin
|
|
25
34
|
yield trace
|
|
@@ -28,8 +37,8 @@ module LlmLogs
|
|
|
28
37
|
raise
|
|
29
38
|
ensure
|
|
30
39
|
trace.complete! if trace.status == "running"
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
Fiber[:llm_logs_trace] = previous_trace
|
|
41
|
+
Fiber[:llm_logs_span] = previous_span
|
|
33
42
|
end
|
|
34
43
|
end
|
|
35
44
|
|
|
@@ -50,7 +59,7 @@ module LlmLogs
|
|
|
50
59
|
started_at: Time.current
|
|
51
60
|
)
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
Fiber[:llm_logs_span] = span
|
|
54
63
|
span
|
|
55
64
|
end
|
|
56
65
|
|
|
@@ -60,7 +69,7 @@ module LlmLogs
|
|
|
60
69
|
status: "running",
|
|
61
70
|
started_at: Time.current
|
|
62
71
|
)
|
|
63
|
-
|
|
72
|
+
Fiber[:llm_logs_trace] = trace
|
|
64
73
|
trace
|
|
65
74
|
end
|
|
66
75
|
end
|
data/lib/llm_logs/version.rb
CHANGED
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.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anton
|
|
@@ -108,6 +108,7 @@ files:
|
|
|
108
108
|
- app/controllers/llm_logs/spans_controller.rb
|
|
109
109
|
- app/controllers/llm_logs/traces_controller.rb
|
|
110
110
|
- app/helpers/llm_logs/formatting_helper.rb
|
|
111
|
+
- app/helpers/llm_logs/prompts_helper.rb
|
|
111
112
|
- app/models/llm_logs/application_record.rb
|
|
112
113
|
- app/models/llm_logs/prompt.rb
|
|
113
114
|
- app/models/llm_logs/prompt_version.rb
|