Can copy a chat message
This commit is contained in:
@@ -245,9 +245,19 @@ defmodule MusicLibraryWeb.Components.Chat do
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<p :if={message.role == "user"} class="whitespace-pre-wrap">{message.content}</p>
|
<p :if={message.role == "user"} class="whitespace-pre-wrap">{message.content}</p>
|
||||||
<div :if={message.role == "assistant"} class="dark:prose-invert prose prose-sm">
|
<div
|
||||||
|
:if={message.role == "assistant"}
|
||||||
|
id={"chat-msg-#{message.id}"}
|
||||||
|
class="dark:prose-invert prose prose-sm"
|
||||||
|
>
|
||||||
{raw(Markdown.to_html(message.content, link_target: "_blank"))}
|
{raw(Markdown.to_html(message.content, link_target: "_blank"))}
|
||||||
</div>
|
</div>
|
||||||
|
<div :if={message.role == "assistant"} class="flex justify-end -mb-1 -mr-2">
|
||||||
|
<.copy_to_clipboard
|
||||||
|
target_id={"chat-msg-#{message.id}"}
|
||||||
|
label={gettext("Copy message")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -342,12 +352,11 @@ defmodule MusicLibraryWeb.Components.Chat do
|
|||||||
|
|
||||||
def handle_event("select_chat", %{"id" => id}, socket) do
|
def handle_event("select_chat", %{"id" => id}, socket) do
|
||||||
chat = Chats.get_chat!(id)
|
chat = Chats.get_chat!(id)
|
||||||
messages = Enum.map(chat.messages, &%{role: &1.role, content: &1.content})
|
|
||||||
|
|
||||||
{:noreply,
|
{:noreply,
|
||||||
socket
|
socket
|
||||||
|> assign(:chat, chat)
|
|> assign(:chat, chat)
|
||||||
|> assign(:messages, messages)
|
|> assign(:messages, chat.messages)
|
||||||
|> assign(:current_response, "")
|
|> assign(:current_response, "")
|
||||||
|> assign(:streaming_doc, nil)
|
|> assign(:streaming_doc, nil)
|
||||||
|> assign(:error, nil)
|
|> assign(:error, nil)
|
||||||
|
|||||||
@@ -2402,3 +2402,8 @@ msgid "Importing %{count} record in the background..."
|
|||||||
msgid_plural "Importing %{count} records in the background..."
|
msgid_plural "Importing %{count} records in the background..."
|
||||||
msgstr[0] ""
|
msgstr[0] ""
|
||||||
msgstr[1] ""
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#: lib/music_library_web/components/chat.ex
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
msgid "Copy message"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -2402,3 +2402,8 @@ msgid "Importing %{count} record in the background..."
|
|||||||
msgid_plural "Importing %{count} records in the background..."
|
msgid_plural "Importing %{count} records in the background..."
|
||||||
msgstr[0] ""
|
msgstr[0] ""
|
||||||
msgstr[1] ""
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#: lib/music_library_web/components/chat.ex
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
msgid "Copy message"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
Reference in New Issue
Block a user