Files
ubicloud/views/inference/endpoint/index.erb
Jeremy Evans b1086841bf Cover inference endpoint index view
Add nocov around unknown model capabilities, since those should
never happen, and the branch just raises an error for easier
debugging in development.

After changes:

Line Coverage: 99.82% (11703 / 11724)
Branch Coverage: 98.19% (3089 / 3146)
2025-01-14 09:04:22 -08:00

79 lines
3.0 KiB
Plaintext

<% @page_title = "Inference Endpoints" %>
<%== render("inference/tabbar") %>
<div class="grid xl:grid-cols-2 2xl:grid-cols-3 gap-4">
<% @inference_endpoints.each_with_index do | ie, index |
path, model_icon, curl_message = case ie[:tags]["capability"]
when "Text Generation"
[
"/v1/chat/completions",
"hero-chat-bubble-bottom-center-text",
<<-MSG
"messages": [{"role": "user", "content": "say something"}],
"stream": true
MSG
]
when "Embeddings"
["/v1/embeddings", "hero-document-arrow-down", "\"input\": \"embed me!\"\n"]
# :nocov:
else
fail "Unknown model capability"
# :nocov:
end
curl_snippet = <<-CURL
curl #{ie[:url]}#{path} \\
-H <span class="text-green-400">"Content-Type: application/json"</span> \\
-H <span class="text-green-400">"Authorization: Bearer <span class="text-orange-500">$INFERENCE_API_KEY</span>"</span> \\
-d <span class="text-green-400">'{
"model": "#{ie[:model_name]}",
#{curl_message} }'</span>
CURL
%>
<div class="overflow-hidden rounded-lg shadow ring-1 ring-black ring-opacity-5 bg-white p-4">
<h2 class="text-lg font-bold mb-4 text-gray-800"><%= ie[:name] %></h2>
<div class="grid sm:grid-cols-2 gap-4">
<div>
<h3 class="text-sm font-semibold text-gray-900">Capability</h3>
<div class="flex items-center gap-1 text-gray-500">
<%== render("components/icon", locals: { name: model_icon, classes: "w-5 h-5 text-gray-400" }) %>
<%= ie[:tags]["capability"] %>
</div>
</div>
<div>
<h3 class="text-sm font-semibold text-gray-900">Pricing per million tokens</h3>
<p class="text-gray-500">$<%= "%0.02f" % ie[:price_million_tokens] %></p>
</div>
<div>
<h3 class="text-sm font-semibold text-gray-900">Model card</h3>
<div class="flex items-center gap-1 text-gray-500">
<%if hf_model = ie[:tags]["hf_model"]%>
<a target="_blank" rel="noreferrer" href="https://huggingface.co/<%= hf_model %>" class="text-orange-600">🤗 <%= hf_model %></a>
<%else%>
<p class="text-gray-500">Not available</p>
<%end%>
</div>
</div>
<div>
<h3 class="text-sm font-semibold text-gray-900">Context length</h3>
<p class="text-gray-500"><%= ie[:tags].fetch("context_length", "Full") %></p>
</div>
<div class="sm:col-span-2">
<h3 class="text-sm font-semibold text-gray-900">URL</h3>
<p class="text-gray-500"><%== render("components/copyable_content", locals: { content: ie[:url], message: "Copied URL" }) %></p>
</div>
<div class="sm:col-span-2">
<h3 class="text-sm font-semibold text-gray-900">
CURL usage example
</h3>
<div class="mt-2">
<pre class="text-sm bg-gray-800 text-white p-2 rounded-lg overflow-scroll"><%== curl_snippet %></pre>
</div>
</div>
</div>
</div>
<% end %>
</div>