Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test on language model settings page #584

Merged
merged 15 commits into from
Dec 24, 2024
Merged
Prev Previous commit
Next Next commit
Cleanup. Still WIP.
mattlindsey committed Dec 13, 2024
commit f02d7669913f85d390313f549a26afe56f9bafe1
8 changes: 4 additions & 4 deletions app/views/settings/language_models/_form.html.erb
Original file line number Diff line number Diff line change
@@ -16,18 +16,18 @@
<%= form.text_field :name, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full dark:text-black" %>
</div>

<div data-controller="testing" class="my-5">
<div data-controller="testing" class="my-5 inline-block">
<%= form.label :api_name %>
<div class="inline-block">
<span>
<% if language_model.persisted? %>
<% link_url = settings_language_models_path + "/" + language_model.id.to_s + "/test" %>
<%= link_to "(Test)", link_url,
id: "test_result",
data: { turbo_stream: true, action: "click->testing#update_link" },
class: "inline-block ml-5"
class: "underline text-blue-600"
%>
<% end %>
</div>
</span>
<%= form.text_field :api_name,
data: { testing_target: "input" },
class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full dark:text-black"
15 changes: 9 additions & 6 deletions app/views/settings/language_models/test.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<turbo-stream action="replace" target="test_result">
<template>
<div id="test_result" class="inline-block font-bold">
<div id="test_result" class="inline-block">
<span>
<%= link_to "(Test)",
settings_language_model_test_path(@language_model),
id: "test_result",
data: { turbo_stream: true, action: "click->testing#update_link" },
class: "underline text-blue-600"
%>
</span>
<% if @answer.start_with?("Error:") %>
<span class="text-red-700"><%= @answer %></span>
<% else %>
<span class="text-green-700">Result: <%= @answer %></span>
<% end %>
<%= link_to "(Re-Test)",
settings_language_model_test_path(@language_model),
id: "test_result",
data: { turbo_stream: true, action: "click->testing#update_link" }
%>
</div>
</template>
</turbo-stream>