defmodule ElixirAiWeb.Voice.VoiceConversation do use Phoenix.Component alias Phoenix.LiveView.JS import ElixirAiWeb.ChatMessage import ElixirAiWeb.Spinner attr :messages, :list, required: true attr :streaming_response, :any, default: nil attr :ai_error, :string, default: nil def voice_conversation(assigns) do ~H"""
Voice Chat
<%= if @ai_error do %> <% end %>
<%= for msg <- @messages do %> <%= cond do %> <% msg.role == :user -> %> <.user_message content={Map.get(msg, :content) || ""} /> <% msg.role == :tool -> %> <.tool_result_message content={Map.get(msg, :content) || ""} tool_call_id={Map.get(msg, :tool_call_id) || ""} /> <% true -> %> <.assistant_message content={Map.get(msg, :content) || ""} reasoning_content={Map.get(msg, :reasoning_content)} tool_calls={Map.get(msg, :tool_calls) || []} /> <% end %> <% end %> <%= if @streaming_response do %> <.streaming_assistant_message content={@streaming_response.content} reasoning_content={@streaming_response.reasoning_content} tool_calls={@streaming_response.tool_calls} /> <.spinner /> <% end %>
""" end end