completion-kit 0.27.10 → 0.28.0
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/assets/stylesheets/completion_kit/application.css +7 -0
- data/app/controllers/completion_kit/runs_controller.rb +11 -1
- data/app/models/completion_kit/run.rb +34 -26
- data/app/views/completion_kit/runs/show.html.erb +13 -1
- data/lib/completion_kit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 49de7d9ec92e8fb633cebd08ad79baeb32158864beeb06796321b909f862dcfe
|
|
4
|
+
data.tar.gz: 47a798af3557ca3e95dc0f0897e032aa121f0014824cc71bbd71dace49437bdd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a94dae22a11aa716352e8b5f44109479ad87af5a7928ea1d98ce095beccc46468fb02c79fe5afc7c044616eba4b260931c2a309ea15bbb916aa44bbc5bc3f56
|
|
7
|
+
data.tar.gz: a9a8920af149a4aad600ce8b95635fd89abf678d76e8bd84e69a462e73ec1588c29cb71a82f4159928e058f671487fe21c109f2cf7026eebde57a41c6ea94af4
|
|
@@ -10,8 +10,18 @@ module CompletionKit
|
|
|
10
10
|
@runs = apply_tag_filter(scope)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
RESPONSES_PER_PAGE = 100
|
|
14
|
+
|
|
13
15
|
def show
|
|
14
|
-
@
|
|
16
|
+
@responses_total = @run.responses.count
|
|
17
|
+
@responses_per_page = RESPONSES_PER_PAGE
|
|
18
|
+
@responses_total_pages = [(@responses_total.to_f / RESPONSES_PER_PAGE).ceil, 1].max
|
|
19
|
+
@responses_page = params[:page].to_i.clamp(1, @responses_total_pages)
|
|
20
|
+
@responses_offset = (@responses_page - 1) * RESPONSES_PER_PAGE
|
|
21
|
+
@responses = ordered_responses_relation(@run, params[:sort])
|
|
22
|
+
.includes(:reviews)
|
|
23
|
+
.limit(RESPONSES_PER_PAGE)
|
|
24
|
+
.offset(@responses_offset)
|
|
15
25
|
end
|
|
16
26
|
|
|
17
27
|
def new
|
|
@@ -201,7 +201,6 @@ module CompletionKit
|
|
|
201
201
|
end
|
|
202
202
|
end
|
|
203
203
|
|
|
204
|
-
failed_row = nil
|
|
205
204
|
begin
|
|
206
205
|
transaction do
|
|
207
206
|
responses.destroy_all
|
|
@@ -212,37 +211,46 @@ module CompletionKit
|
|
|
212
211
|
failure_summary: nil,
|
|
213
212
|
error_message: nil
|
|
214
213
|
)
|
|
215
|
-
rows.each_with_index do |row, index|
|
|
216
|
-
failed_row = index
|
|
217
|
-
input = row.empty? ? nil : row.to_json
|
|
218
|
-
attrs = {
|
|
219
|
-
status: "pending",
|
|
220
|
-
row_index: index,
|
|
221
|
-
input_data: input,
|
|
222
|
-
expected_output: row[expected_column.presence || "expected_output"]
|
|
223
|
-
}
|
|
224
|
-
if judge_only?
|
|
225
|
-
attrs[:status] = "succeeded"
|
|
226
|
-
column = output_column.presence || "actual_output"
|
|
227
|
-
attrs[:response_text] = row[column].to_s if dataset && dataset.headers.include?(column)
|
|
228
|
-
end
|
|
229
214
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
215
|
+
now = Time.current
|
|
216
|
+
out_col = output_column.presence || "actual_output"
|
|
217
|
+
exp_col = expected_column.presence || "expected_output"
|
|
218
|
+
judge = judge_only?
|
|
219
|
+
has_output = judge && dataset && dataset.headers.include?(out_col)
|
|
220
|
+
scope_defaults = Response.all.where_values_hash.symbolize_keys
|
|
221
|
+
|
|
222
|
+
response_attrs = rows.each_with_index.map do |row, index|
|
|
223
|
+
{
|
|
224
|
+
run_id: id,
|
|
225
|
+
status: judge ? "succeeded" : "pending",
|
|
226
|
+
row_index: index,
|
|
227
|
+
input_data: row.empty? ? nil : row.to_json,
|
|
228
|
+
expected_output: row[exp_col],
|
|
229
|
+
response_text: (judge && has_output ? row[out_col].to_s : nil),
|
|
230
|
+
attempts: 0,
|
|
231
|
+
created_at: now,
|
|
232
|
+
updated_at: now
|
|
233
|
+
}.merge(scope_defaults)
|
|
234
|
+
end
|
|
235
|
+
Response.insert_all(response_attrs)
|
|
236
|
+
responses.reset
|
|
237
|
+
|
|
238
|
+
response_ids = responses.order(:row_index).pluck(:id)
|
|
239
|
+
if judge
|
|
240
|
+
judge_metrics = llm_judge_configured? ? llm_metrics.to_a : []
|
|
241
|
+
chk_metrics = check_metrics.to_a
|
|
242
|
+
response_ids.each do |rid|
|
|
243
|
+
judge_metrics.each { |m| JudgeReviewJob.perform_later(rid, m.id, id) }
|
|
244
|
+
chk_metrics.each { |m| CheckReviewJob.perform_later(rid, m.id, id) }
|
|
237
245
|
end
|
|
246
|
+
RunCompletionCheckJob.perform_later(id)
|
|
247
|
+
else
|
|
248
|
+
response_ids.each { |rid| GenerateRowJob.perform_later(id, rid) }
|
|
238
249
|
end
|
|
239
|
-
|
|
240
|
-
RunCompletionCheckJob.perform_later(id) if judge_only?
|
|
241
250
|
end
|
|
242
251
|
rescue ActiveRecord::RecordInvalid => e
|
|
243
252
|
reload
|
|
244
|
-
|
|
245
|
-
return fail_with_summary!(failed_row ? "Row #{failed_row + 1}: #{detail}" : detail)
|
|
253
|
+
return fail_with_summary!(e.record.errors.full_messages.to_sentence)
|
|
246
254
|
end
|
|
247
255
|
|
|
248
256
|
safely_broadcast do
|
|
@@ -197,11 +197,23 @@
|
|
|
197
197
|
</thead>
|
|
198
198
|
<tbody id="run_responses">
|
|
199
199
|
<% @responses.each_with_index do |response, idx| %>
|
|
200
|
-
<%= render "response_row", run: @run, response: response, index: idx + 1 %>
|
|
200
|
+
<%= render "response_row", run: @run, response: response, index: @responses_offset + idx + 1 %>
|
|
201
201
|
<% end %>
|
|
202
202
|
</tbody>
|
|
203
203
|
</table>
|
|
204
204
|
|
|
205
|
+
<% if @responses_total_pages > 1 %>
|
|
206
|
+
<nav class="ck-pagination" aria-label="Response pages">
|
|
207
|
+
<% if @responses_page > 1 %>
|
|
208
|
+
<%= link_to run_path(@run, page: @responses_page - 1, sort: params[:sort]), class: ck_button_classes(:light, variant: :outline) do %>← Prev<% end %>
|
|
209
|
+
<% end %>
|
|
210
|
+
<span class="ck-meta-copy">Page <%= @responses_page %> of <%= @responses_total_pages %> · <%= pluralize(@responses_total, "response") %></span>
|
|
211
|
+
<% if @responses_page < @responses_total_pages %>
|
|
212
|
+
<%= link_to run_path(@run, page: @responses_page + 1, sort: params[:sort]), class: ck_button_classes(:light, variant: :outline) do %>Next →<% end %>
|
|
213
|
+
<% end %>
|
|
214
|
+
</nav>
|
|
215
|
+
<% end %>
|
|
216
|
+
|
|
205
217
|
<% if @run.status.in?(%w[pending running]) %>
|
|
206
218
|
<script>
|
|
207
219
|
(function() {
|