Files
ubicloud/views/inference/endpoint/index.erb
Jeremy Evans cb389c5144 Use Roda part plugin to simplify render calls with locals
This uses the new part plugin to simplify and optimize render
calls with locals.

```ruby
render(:template, locals: {foo: 'bar'})

part(:template, foo: 'bar')
```

This simplifies a large number of calls in Clover, since
rendering with locals is one of the most common method
calls in the templates.

The main advantage of this is simplicity, but the part method
is also more optimized, and will be even more optimized when
we upgrade to Ruby 3.4.

Diff best reviewed with:

```
git diff -b --color-words --word-diff-regex='\\w+|[^[:space:]]'
```
2025-01-31 09:47:06 -08:00

79 lines
2.9 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">
<%== part("components/icon", 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"><%== part("components/copyable_content", 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>