completion-kit 0.28.14 → 0.28.16

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: 3aa50615418395ad99363761cda1ae26f1423659511d52db2252cd41b5cd13d9
4
- data.tar.gz: 053ac0c75a8f0eaf921132adf4f6a6dee9f926495a0698700213e143fbc43a59
3
+ metadata.gz: 73425cba956dc09f3a16e93b78cd3d64ca5f840ccf0c9dbd86bdf99adfafe1a3
4
+ data.tar.gz: 480da4d4bb8491e780bbe81f97031259f50148efbbd29c8e1ae1ae1d0878fca8
5
5
  SHA512:
6
- metadata.gz: 9eb01763e01bc3b96d0994a73dbf5a38ecd9f4ea928c133cca98575879eb0088754b256ae540ca2c2df66fcf94608f3de90acf9e88a14d2aa0c12939d8e45840
7
- data.tar.gz: bf6992f1fb1a1f19abb7f1b59cde253a23e661a7301f590511328e7c1a662b6ed4199701d5b235beba681e15b6b9056dd80567301d338a15f391f8fa6b837fa0
6
+ metadata.gz: e26ab2bc7b435f18d89d6a68799c4b7f24ae8d8733e7db89ed309bf79ae4785b2e82d31ab94fc8b838c7a257e62909c5b4ab7ed303d10019c423577fdb4f8d58
7
+ data.tar.gz: 82a4cffb2ebf3205cba3b09756c6d3e753ab28777f578be0e08cc092e00fa661ec7109ce567e451e2945e8b651a86c593e556afd219f328051dfddbf2894915d
@@ -4554,6 +4554,12 @@ table.ck-runs-table {
4554
4554
  border-radius: 0 var(--ck-radius) var(--ck-radius) 0;
4555
4555
  }
4556
4556
 
4557
+ .ck-suggest-caveat {
4558
+ margin: 0 0 0.6rem;
4559
+ color: var(--ck-warning);
4560
+ font-size: 0.85rem;
4561
+ }
4562
+
4557
4563
  .ck-suggest-reasoning .ck-kicker {
4558
4564
  margin-bottom: 0.5rem;
4559
4565
  }
@@ -9,7 +9,7 @@ module CompletionKit
9
9
 
10
10
  def show
11
11
  @runs = Run.where(prompt_id: @prompt.family_versions.select(:id))
12
- .includes(:prompt, :dataset, responses: :reviews)
12
+ .includes(:prompt, :dataset, :tags, responses: :reviews)
13
13
  .order(created_at: :desc)
14
14
  .display_scoped
15
15
  end
@@ -1,5 +1,14 @@
1
1
  module CompletionKit
2
2
  module ApplicationHelper
3
+ def ck_markdown(text)
4
+ return "".html_safe if text.blank?
5
+
6
+ inline = text.to_s
7
+ .gsub(/\*\*(.+?)\*\*/, '<strong>\1</strong>')
8
+ .gsub(/`([^`]+)`/, '<code>\1</code>')
9
+ simple_format(inline)
10
+ end
11
+
3
12
  def ck_runs_display_footer(runs)
4
13
  partial = CompletionKit.config.runs_display_footer_partial
5
14
  return unless partial
@@ -117,7 +117,12 @@ module CompletionKit
117
117
  end
118
118
 
119
119
  def reviews_for_summary
120
- @reviews_for_summary ||= Review.where(response_id: responses.select(:id)).to_a
120
+ @reviews_for_summary ||=
121
+ if responses.loaded? && responses.all? { |response| response.association(:reviews).loaded? }
122
+ responses.flat_map(&:reviews)
123
+ else
124
+ Review.where(response_id: responses.select(:id)).to_a
125
+ end
121
126
  end
122
127
 
123
128
  def avg_score
@@ -35,7 +35,7 @@
35
35
  <section class="ck-card--spaced">
36
36
  <div class="ck-prompt-preview__header">
37
37
  <p class="ck-kicker">Prompt</p>
38
- <% judged_run = @runs.select { |r| r.prompt_id == @prompt.id && r.status == "completed" }.find { |r| r.responses.joins(:reviews).exists? } %>
38
+ <% judged_run = @runs.select { |r| r.prompt_id == @prompt.id && r.status == "completed" }.find { |r| r.responses.any? { |resp| resp.reviews.any? } } %>
39
39
  <% if judged_run %>
40
40
  <%= button_to suggest_run_path(judged_run), method: :post, class: ck_button_classes(:light, variant: :outline) + " ck-button--sm", form_class: "inline-block" do %>
41
41
  <%= heroicon_tag "sparkles", variant: :outline, class: "ck-magic-icon", "aria-hidden": "true" %>
@@ -48,7 +48,8 @@
48
48
  <pre class="ck-code ck-code--dark ck-code--prompt"><%= @prompt.template %></pre>
49
49
  </section>
50
50
 
51
- <% versions = @prompt.family_versions.includes(runs: { responses: :reviews }).to_a %>
51
+ <% versions = @prompt.family_versions.to_a %>
52
+ <% runs_by_version = @runs.group_by(&:prompt_id) %>
52
53
  <% predecessor_of = versions.index_with { |v| versions.detect { |o| o.version_number < v.version_number } } %>
53
54
  <% version_changed = ->(v, pred) { pred && (pred.template != v.template || pred.llm_model != v.llm_model) } %>
54
55
  <% if versions.size > 1 %>
@@ -65,7 +66,7 @@
65
66
  </thead>
66
67
  <tbody>
67
68
  <% versions.each do |v| %>
68
- <% scoped_runs = v.runs.display_scoped %>
69
+ <% scoped_runs = runs_by_version[v.id] || [] %>
69
70
  <% best_score = scoped_runs.map(&:avg_score).compact.max %>
70
71
  <% best_pass_rate = scoped_runs.map(&:check_pass_rate).compact.max %>
71
72
  <% pred = predecessor_of[v] %>
@@ -16,8 +16,8 @@
16
16
  <% end %>
17
17
 
18
18
  <div class="ck-suggest-reasoning">
19
- <p class="ck-kicker">Why these changes</p>
20
- <div class="ck-suggest-reasoning__body"><%= simple_format(suggestion.reasoning) %></div>
19
+ <p class="ck-kicker">Reasons for suggested changes</p>
20
+ <div class="ck-suggest-reasoning__body"><%= ck_markdown(suggestion.reasoning) %></div>
21
21
  </div>
22
22
 
23
23
  <div class="ck-suggest-diff">
@@ -41,6 +41,14 @@
41
41
  <pre class="ck-code ck-code--dark"><%= suggestion.suggested_template %></pre>
42
42
  </div>
43
43
 
44
+ <% unless suggestion.applied_at? %>
45
+ <% if !suggestion.validated? %>
46
+ <p class="ck-suggest-caveat">Couldn't be re-scored against this run's responses, so applying it is unvalidated.</p>
47
+ <% elsif suggestion.net_negative? %>
48
+ <% vs = suggestion.validation_summary %>
49
+ <p class="ck-suggest-caveat">Scored <%= vs["after_avg"] %> on the held-out responses, below your original's <%= vs["before_avg"] %>.</p>
50
+ <% end %>
51
+ <% end %>
44
52
  <div class="ck-actions">
45
53
  <% if suggestion.applied_at? %>
46
54
  <span class="ck-chip" style="background: var(--ck-success-soft); color: var(--ck-success);">Applied</span>
@@ -1,3 +1,3 @@
1
1
  module CompletionKit
2
- VERSION = "0.28.14"
2
+ VERSION = "0.28.16"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: completion-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.14
4
+ version: 0.28.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Bastin