completion-kit 0.12.1 → 0.12.2

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: a39761d576cee622378682d2b920ed0540bd4cbefbda033236c2108c1676d835
4
- data.tar.gz: 7ad068f5c6a9a96513d47e689f5b0926e101aec4058e033076c9e6d87b31d003
3
+ metadata.gz: 2081bddd1c82585abdd5afce703b0b3716f13ad3b19ee31070202c2f16427309
4
+ data.tar.gz: c894759632af3ebcdd35f0fea54cad9e6a5bb687e22345cf9e77d538cb9b70ae
5
5
  SHA512:
6
- metadata.gz: 80e6c44594f02b408911390576ea7ed9c377ef4ab4d7f068341b5177277a8baa6776e09986a4afedd430d723f84e700ca85962a504f949eb17a860d53cfeba82
7
- data.tar.gz: 749da38fb1236140bc6f6cf45419d979500c671a1a8e92471c35aa79abe95fbb32a5d898286932cf4b82af0628e533b93a8ad6fc0b458c4322321efa98317c4d
6
+ metadata.gz: b59d198b85a20a2c6645467c08d786c00f7b4a32d7553b4ab4774d90e13b23dec1a05dd4b9ff6fdcd1b27afa86ea8bfed45dfe7b1b58c3023a737d3ed26ff984
7
+ data.tar.gz: 20e58399fec4f595628f25b0cec98a05c66c0003cb3f94c28f2a9ae9e411732d71e2d2a98787767789ce4654af1aef975a54bf0a9295805977df5dcaaaad49ce
@@ -131,8 +131,15 @@ function ckDiscoveringInDom() {
131
131
  return !!document.querySelector('[id^="discovery_status_"] .ck-discovery-bar:not(.ck-discovery-bar--failed):not(.ck-discovery-bar--completed)');
132
132
  }
133
133
 
134
+ function ckStatusesUrl() {
135
+ var el = document.querySelector("[data-ck-statuses-url]");
136
+ return el ? el.getAttribute("data-ck-statuses-url") : null;
137
+ }
138
+
134
139
  function ckPollDiscoveryOnce() {
135
- fetch("/completion_kit/provider_credentials/statuses", { headers: { "Accept": "text/vnd.turbo-stream.html" } })
140
+ var url = ckStatusesUrl();
141
+ if (!url) return;
142
+ fetch(url, { headers: { "Accept": "text/vnd.turbo-stream.html" } })
136
143
  .then(function(r) { return r.ok ? r.text() : null; })
137
144
  .then(function(html) {
138
145
  if (html && window.Turbo && window.Turbo.renderStreamMessage) window.Turbo.renderStreamMessage(html);
@@ -142,6 +149,7 @@ function ckPollDiscoveryOnce() {
142
149
 
143
150
  function ckStartDiscoveryPolling(graceMs) {
144
151
  if (!document.querySelector('[id^="discovery_status_"]')) return;
152
+ if (!ckStatusesUrl()) return;
145
153
  ckDiscoveryPollUntil = Date.now() + (graceMs || 0);
146
154
  if (ckDiscoveryPollTimer) return;
147
155
  ckPollDiscoveryOnce();
@@ -114,22 +114,24 @@ module CompletionKit
114
114
  end
115
115
 
116
116
  def broadcast_model_dropdowns
117
- helper = ApplicationController.helpers
118
- gen_html = helper.ck_model_options_html(:generation)
119
- judge_html = '<option value="">None</option>' + helper.ck_model_options_html(:judging)
120
-
121
- Turbo::StreamsChannel.broadcast_action_to(
122
- "completion_kit_provider_#{id}",
123
- action: :replace,
124
- target: "prompt_llm_model",
125
- html: "<select name=\"prompt[llm_model]\" id=\"prompt_llm_model\" class=\"ck-input\">#{gen_html}</select>"
126
- )
127
- Turbo::StreamsChannel.broadcast_action_to(
128
- "completion_kit_provider_#{id}",
129
- action: :replace,
130
- target: "run_judge_model",
131
- html: "<select name=\"run[judge_model]\" id=\"run_judge_model\" class=\"ck-input\">#{judge_html}</select>"
132
- )
117
+ safely_broadcast do
118
+ helper = ApplicationController.helpers
119
+ gen_html = helper.ck_model_options_html(:generation)
120
+ judge_html = '<option value="">None</option>' + helper.ck_model_options_html(:judging)
121
+
122
+ Turbo::StreamsChannel.broadcast_action_to(
123
+ "completion_kit_provider_#{id}",
124
+ action: :replace,
125
+ target: "prompt_llm_model",
126
+ html: "<select name=\"prompt[llm_model]\" id=\"prompt_llm_model\" class=\"ck-input\">#{gen_html}</select>"
127
+ )
128
+ Turbo::StreamsChannel.broadcast_action_to(
129
+ "completion_kit_provider_#{id}",
130
+ action: :replace,
131
+ target: "run_judge_model",
132
+ html: "<select name=\"run[judge_model]\" id=\"run_judge_model\" class=\"ck-input\">#{judge_html}</select>"
133
+ )
134
+ end
133
135
  end
134
136
 
135
137
  def render_partial(partial, locals)
@@ -38,5 +38,7 @@
38
38
 
39
39
  <% if provider_credential.persisted? %>
40
40
  <%= turbo_stream_from "completion_kit_provider_#{provider_credential.id}" %>
41
- <%= render "models_card", provider_credential: provider_credential %>
41
+ <div data-ck-statuses-url="<%= statuses_provider_credentials_path %>">
42
+ <%= render "models_card", provider_credential: provider_credential %>
43
+ </div>
42
44
  <% end %>
@@ -16,7 +16,7 @@
16
16
 
17
17
  <% if @provider_credentials.any? %>
18
18
  <% default_endpoints = {"openai" => "https://api.openai.com", "anthropic" => "https://api.anthropic.com"} %>
19
- <div class="ck-provider-list">
19
+ <div class="ck-provider-list" data-ck-statuses-url="<%= statuses_provider_credentials_path %>">
20
20
  <% @provider_credentials.each do |provider_credential| %>
21
21
  <% masked_key = provider_credential.api_key.present? ? "#{provider_credential.api_key[0..6]}#{'•' * 12}#{provider_credential.api_key[-4..]}" : "—" %>
22
22
  <a href="<%= edit_provider_credential_path(provider_credential) %>" class="ck-provider-card">
@@ -1,3 +1,3 @@
1
1
  module CompletionKit
2
- VERSION = "0.12.1"
2
+ VERSION = "0.12.2"
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.12.1
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Bastin