Skip to content

Commit

Permalink
Add "$" dropdown next to "Regenerate" in last message
Browse files Browse the repository at this point in the history
Add a drop-down showing the LLM API reported input/output tokens for the
ongoing conversation.


Signed-off-by: Daniel Schnell <dschnell@grammatek.com>
  • Loading branch information
lumpidu committed Jul 15, 2024
1 parent e3aca92 commit 7de810f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/views/messages/_message.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,24 @@ end
<% end %>
</menu>
</div>
<% if last_message %>
<% input_tokens = conversation.messages.sum(:input_token_count) %>
<% output_tokens = conversation.messages.sum(:output_token_count) %>

<div class="dropdown dropdown-top flex items-center ml-2">
<%= button_tag "$",
tabindex: 0,
role: :button,
class: "text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white",
data: { role: "show-token-info" }
%>

<div tabindex="0" class="dropdown-content -ml-6 z-10 p-2 shadow-xl bg-base-100 rounded-box w-52 dark:!bg-gray-700">
<p class="py-1 px-2 text-sm text-gray-700 dark:text-gray-300">Input tokens: <%= input_tokens %></p>
<p class="py-1 px-2 text-sm text-gray-700 dark:text-gray-300">Output tokens: <%= output_tokens %></p>
</div>
</div>
<% end %>
<% end %>
</div>
</turbo-frame>
Expand Down

0 comments on commit 7de810f

Please sign in to comment.