completion-kit 0.28.16 → 0.28.17

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: 73425cba956dc09f3a16e93b78cd3d64ca5f840ccf0c9dbd86bdf99adfafe1a3
4
- data.tar.gz: 480da4d4bb8491e780bbe81f97031259f50148efbbd29c8e1ae1ae1d0878fca8
3
+ metadata.gz: a06bbc49a6b929962197f8ff7fe9cd5e1fa4561fe2a7074e4028ac867472cf61
4
+ data.tar.gz: 6615270452a2c991cce7ef84aa5267e22f014e3039dd59cd7ebeb1f0ba8cb90c
5
5
  SHA512:
6
- metadata.gz: e26ab2bc7b435f18d89d6a68799c4b7f24ae8d8733e7db89ed309bf79ae4785b2e82d31ab94fc8b838c7a257e62909c5b4ab7ed303d10019c423577fdb4f8d58
7
- data.tar.gz: 82a4cffb2ebf3205cba3b09756c6d3e753ab28777f578be0e08cc092e00fa661ec7109ce567e451e2945e8b651a86c593e556afd219f328051dfddbf2894915d
6
+ metadata.gz: 9be6cc2b9f3522f622c9b6d503e391b3007d70e156ea12f862e4cd8fd91a20a3a9c01691a8910a48bdaedd2d9dea86766051ea8bf8172aac7f0882f5368e257c
7
+ data.tar.gz: b87f4a046822e9b52b2edd823f443894d5f106cc81f1e6470fb5f7d4d4764a497ac23f3795201e63819971d3890c235eb3a297e9b689d2781479cdfc005f89b1
@@ -4039,11 +4039,12 @@ select.ck-input {
4039
4039
  .ck-source-chip--past {
4040
4040
  color: var(--ck-dim);
4041
4041
  }
4042
- .ck-suggestions-table th:nth-child(1), .ck-suggestions-table td:nth-child(1) { width: 16rem; white-space: nowrap; }
4043
- .ck-suggestions-table th:nth-child(2), .ck-suggestions-table td:nth-child(2) { width: auto; }
4044
- .ck-suggestions-table th:nth-child(3), .ck-suggestions-table td:nth-child(3) { width: 6rem; white-space: nowrap; }
4045
- .ck-suggestions-table th:nth-child(4), .ck-suggestions-table td:nth-child(4) { width: 9rem; white-space: nowrap; }
4046
- .ck-suggestions-table th:nth-child(5), .ck-suggestions-table td:nth-child(5) { width: 3rem; }
4042
+ .ck-suggestions-table th:nth-child(1), .ck-suggestions-table td:nth-child(1) { width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
4043
+ .ck-suggestions-table th:nth-child(2), .ck-suggestions-table td:nth-child(2) { width: 5rem; white-space: nowrap; }
4044
+ .ck-suggestions-table th:nth-child(3), .ck-suggestions-table td:nth-child(3) { width: auto; }
4045
+ .ck-suggestions-table th:nth-child(4), .ck-suggestions-table td:nth-child(4) { width: 6rem; white-space: nowrap; }
4046
+ .ck-suggestions-table th:nth-child(5), .ck-suggestions-table td:nth-child(5) { width: 8rem; white-space: nowrap; }
4047
+ .ck-suggestions-table th:nth-child(6), .ck-suggestions-table td:nth-child(6) { width: 3rem; }
4047
4048
 
4048
4049
  .ck-metrics-table__groups {
4049
4050
  display: flex;
@@ -4560,6 +4561,37 @@ table.ck-runs-table {
4560
4561
  font-size: 0.85rem;
4561
4562
  }
4562
4563
 
4564
+ .ck-suggest-untested {
4565
+ margin-bottom: 16px;
4566
+ padding-bottom: 14px;
4567
+ border-bottom: 1px solid var(--ck-line);
4568
+ }
4569
+
4570
+ .ck-suggest-untested__headline {
4571
+ margin: 0 0 6px;
4572
+ font-size: 0.95rem;
4573
+ color: var(--ck-text);
4574
+ }
4575
+
4576
+ .ck-suggest-untested__copy {
4577
+ margin: 0;
4578
+ font-size: 0.85rem;
4579
+ line-height: 1.6;
4580
+ color: var(--ck-muted);
4581
+ max-width: 66ch;
4582
+ }
4583
+
4584
+ .ck-suggest-decision {
4585
+ margin-top: 1.5rem;
4586
+ }
4587
+
4588
+ .ck-suggest-decision__note {
4589
+ margin: 0 0 0.9rem;
4590
+ font-size: 0.8rem;
4591
+ color: var(--ck-muted);
4592
+ max-width: 66ch;
4593
+ }
4594
+
4563
4595
  .ck-suggest-reasoning .ck-kicker {
4564
4596
  margin-bottom: 0.5rem;
4565
4597
  }
@@ -9,6 +9,16 @@ module CompletionKit
9
9
  simple_format(inline)
10
10
  end
11
11
 
12
+ def ck_strip_markdown(text)
13
+ text.to_s
14
+ .gsub(/\*\*(.+?)\*\*/, '\1')
15
+ .gsub(/`([^`]+)`/, '\1')
16
+ .gsub(/[#>]+/, " ")
17
+ .gsub(/(?:^|\s)[-*•]\s+/, " ")
18
+ .gsub(/\s+/, " ")
19
+ .strip
20
+ end
21
+
12
22
  def ck_runs_display_footer(runs)
13
23
  partial = CompletionKit.config.runs_display_footer_partial
14
24
  return unless partial
@@ -153,14 +153,15 @@
153
153
 
154
154
  <%= ck_runs_display_footer(@runs) %>
155
155
 
156
- <% suggestions = CompletionKit::Suggestion.where(prompt_id: @prompt.family_versions.select(:id)).order(created_at: :desc) %>
156
+ <% suggestions = CompletionKit::Suggestion.where(prompt_id: @prompt.family_versions.select(:id)).includes(:run, :prompt).order(created_at: :desc) %>
157
157
  <% if suggestions.any? %>
158
158
  <section class="ck-card--spaced">
159
- <p class="ck-kicker">Suggestions</p>
159
+ <p class="ck-kicker">Suggested improvements</p>
160
160
  <table class="ck-results-table ck-suggestions-table" style="margin-top: 0.5rem;">
161
161
  <thead>
162
162
  <tr>
163
163
  <th>Run</th>
164
+ <th>Version</th>
164
165
  <th>Reasoning</th>
165
166
  <th>Applied</th>
166
167
  <th>When</th>
@@ -171,7 +172,8 @@
171
172
  <% suggestions.each do |s| %>
172
173
  <tr onclick="window.location='<%= suggestion_path(s, from: "prompt") %>'" style="cursor: pointer;">
173
174
  <td><%= link_to suggestion_path(s, from: "prompt"), class: "ck-record-name" do %><strong><%= s.run.name %></strong><% end %></td>
174
- <td class="ck-meta-copy"><%= truncate(s.reasoning.to_s, length: 100) %></td>
175
+ <td class="ck-meta-copy"><%= s.prompt.version_label %></td>
176
+ <td class="ck-meta-copy"><%= truncate(ck_strip_markdown(s.reasoning), length: 100) %></td>
175
177
  <td><%= s.applied_at? ? content_tag(:span, "Applied", class: "ck-chip", style: "background: var(--ck-success-soft); color: var(--ck-success);") : "&mdash;".html_safe %></td>
176
178
  <td class="ck-meta-copy"><time data-relative-time datetime="<%= s.created_at.utc.iso8601 %>"><%= time_ago_in_words(s.created_at) %> ago</time></td>
177
179
  <td class="ck-results-table__arrow" aria-hidden="true">&rarr;</td>
@@ -1,16 +1,12 @@
1
1
  <% s = summary %>
2
2
  <div class="ck-scoreboard">
3
- <% if s["after_avg"] && s["before_avg"] %>
4
- <p class="ck-scoreboard__headline">Scored <strong><%= s["after_avg"] %></strong> across <%= pluralize(s["tested"], "held-out response") %> <span class="ck-scoreboard__was">was <%= s["before_avg"] %></span></p>
5
- <ul class="ck-scoreboard__tally">
6
- <li class="ck-scoreboard__stat ck-scoreboard__stat--fix">Improved <strong><%= s["improved"] %></strong></li>
7
- <li class="ck-scoreboard__stat ck-scoreboard__stat--keep">Held <strong><%= s["unchanged"] %></strong></li>
8
- <li class="ck-scoreboard__stat ck-scoreboard__stat--break">Regressed <strong><%= s["regressed"] %></strong></li>
9
- </ul>
10
- <% else %>
11
- <p class="ck-scoreboard__headline">Couldn't re-score this rewrite against the run's responses.</p>
12
- <% end %>
3
+ <p class="ck-scoreboard__headline">We re-ran this wording on <strong><%= s["tested"] %></strong> of the run's responses. It scored <strong><%= s["after_avg"] %></strong> now, <span class="ck-scoreboard__was"><%= s["before_avg"] %> before</span></p>
4
+ <ul class="ck-scoreboard__tally">
5
+ <li class="ck-scoreboard__stat ck-scoreboard__stat--fix">Better on <strong><%= s["improved"] %></strong></li>
6
+ <li class="ck-scoreboard__stat ck-scoreboard__stat--keep">Same on <strong><%= s["unchanged"] %></strong></li>
7
+ <li class="ck-scoreboard__stat ck-scoreboard__stat--break">Worse on <strong><%= s["regressed"] %></strong></li>
8
+ </ul>
13
9
  <% if s["capped"] %>
14
- <p class="ck-scoreboard__note">Tested against this run's 30 most recent responses.</p>
10
+ <p class="ck-scoreboard__note">Based on this run's 30 most recent responses.</p>
15
11
  <% end %>
16
12
  </div>
@@ -11,15 +11,15 @@
11
11
  <%= button_to "Try again", suggest_run_path(run), method: :post, class: ck_button_classes(:light, variant: :outline), form_class: "inline-block" %>
12
12
  </div>
13
13
  <% else %>
14
- <% if suggestion.validation_summary.present? %>
14
+ <% if suggestion.validated? %>
15
15
  <%= render "completion_kit/suggestions/scoreboard", summary: suggestion.validation_summary %>
16
+ <% else %>
17
+ <div class="ck-suggest-untested">
18
+ <p class="ck-suggest-untested__headline">We couldn't test this rewrite</p>
19
+ <p class="ck-suggest-untested__copy">Testing a rewrite means re-running it on this run's responses and scoring the results. That didn't return a score this time, usually because the run has no AI-judge scores to compare against. So there's no evidence yet that it beats your current prompt.</p>
20
+ </div>
16
21
  <% end %>
17
22
 
18
- <div class="ck-suggest-reasoning">
19
- <p class="ck-kicker">Reasons for suggested changes</p>
20
- <div class="ck-suggest-reasoning__body"><%= ck_markdown(suggestion.reasoning) %></div>
21
- </div>
22
-
23
23
  <div class="ck-suggest-diff">
24
24
  <div class="ck-suggest-diff__pane">
25
25
  <div class="ck-suggest-diff__header">
@@ -36,28 +36,30 @@
36
36
  </div>
37
37
  </div>
38
38
 
39
- <div class="ck-suggest-full">
40
- <p class="ck-kicker">Full suggested prompt</p>
41
- <pre class="ck-code ck-code--dark"><%= suggestion.suggested_template %></pre>
39
+ <div class="ck-suggest-reasoning">
40
+ <p class="ck-kicker">Reasons for suggested changes</p>
41
+ <div class="ck-suggest-reasoning__body"><%= ck_markdown(suggestion.reasoning) %></div>
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 %>
52
- <div class="ck-actions">
44
+ <div class="ck-suggest-decision">
53
45
  <% if suggestion.applied_at? %>
54
- <span class="ck-chip" style="background: var(--ck-success-soft); color: var(--ck-success);">Applied</span>
55
- <% elsif !suggestion.validated? %>
56
- <%= button_to "Apply anyway", apply_suggestion_path(suggestion), method: :post, class: ck_button_classes(:light, variant: :outline), form: { class: "inline-block", data: { turbo_confirm: "This rewrite couldn't be re-scored against the run's responses. Apply it anyway?" } } %>
57
- <% elsif suggestion.net_negative? %>
58
- <%= button_to "Apply anyway", apply_suggestion_path(suggestion), method: :post, class: ck_button_classes(:light, variant: :outline), form: { class: "inline-block", data: { turbo_confirm: "This rewrite scored lower than the original on the held-out responses. Apply it anyway?" } } %>
46
+ <div class="ck-actions">
47
+ <span class="ck-chip" style="background: var(--ck-success-soft); color: var(--ck-success);">Applied</span>
48
+ </div>
59
49
  <% else %>
60
- <%= button_to "Apply suggestion", apply_suggestion_path(suggestion), method: :post, class: ck_button_classes(:dark), form_class: "inline-block" %>
50
+ <% if suggestion.validated? && suggestion.net_negative? %>
51
+ <p class="ck-suggest-caveat">This wording scored lower than your current prompt on the responses we tested. Applying it will most likely make results worse.</p>
52
+ <% end %>
53
+ <p class="ck-suggest-decision__note">Applying publishes this wording as a new version of your prompt. Your current version stays exactly as it is.</p>
54
+ <div class="ck-actions">
55
+ <% if !suggestion.validated? %>
56
+ <%= button_to "Apply anyway", apply_suggestion_path(suggestion), method: :post, class: ck_button_classes(:light, variant: :outline), form: { class: "inline-block", data: { turbo_confirm: "We couldn't test this rewrite, so there's no evidence it beats your current prompt. Apply it anyway?" } } %>
57
+ <% elsif suggestion.net_negative? %>
58
+ <%= button_to "Apply anyway", apply_suggestion_path(suggestion), method: :post, class: ck_button_classes(:light, variant: :outline), form: { class: "inline-block", data: { turbo_confirm: "This rewrite scored lower than your current prompt on the responses we tested. Apply it anyway?" } } %>
59
+ <% else %>
60
+ <%= button_to "Apply suggestion", apply_suggestion_path(suggestion), method: :post, class: ck_button_classes(:dark), form_class: "inline-block" %>
61
+ <% end %>
62
+ </div>
61
63
  <% end %>
62
64
  </div>
63
65
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module CompletionKit
2
- VERSION = "0.28.16"
2
+ VERSION = "0.28.17"
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.16
4
+ version: 0.28.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Bastin