Select raw mono PCM16LE at 24 kHz, at most 10 seconds. Each start provisions a new paid provider session. No local PCM playback. No persistent avatar continuity.
-
Live calls are disabled unless the server has AVATAR_LIVE=1 and credentials. Generation, lip-sync, acoustics, account permissions and TURN remain unverified without credentials.
-
-
-
Connect controls to begin. No provider call is made on connection.
-
+
+
+
+
+ AudioFlow avatar viewer
+
+
+
+
+ AudioFlow
+
+
LiveAvatar finite utterance viewer
+
Select raw mono PCM16LE at 24 kHz, at most 10 seconds. Each start provisions a new paid provider session. No local PCM playback. No persistent avatar continuity.
+
Live calls are disabled unless the server has AVATAR_LIVE=1 and credentials. Generation, lip-sync, acoustics, account permissions and TURN remain unverified without credentials.
+
+
+
+
+
+
+
+
+
+
+
Connect controls to begin. No provider call is made on connection.
+ """
+ end
+
+ @doc "The `alert-title` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def alert_title(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `alert-description` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def alert_description(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `alert-action` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def alert_action(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ defp variant_class(table, group, value),
+ do: get_in(@variant_classes, [table, group, value])
+end
diff --git a/examples/chat/lib/chat_web/components/ui/card.ex b/examples/chat/lib/chat_web/components/ui/card.ex
new file mode 100644
index 0000000..b42628d
--- /dev/null
+++ b/examples/chat/lib/chat_web/components/ui/card.ex
@@ -0,0 +1,158 @@
+# live_shadcn: card @ 0.1.0 (efea03012dd4)
+# Generated from the shadcn registry. Regenerate upstream, never here.
+# `mix ui.sync` reports what changed upstream and skips files you edited.
+
+defmodule ChatWeb.Components.UI.Card do
+ @moduledoc """
+ Card.
+
+ Reviewed from upstream. The marked upstream fact block is synchronized.
+ The HEEx body is maintained as a LiveView port.
+ """
+
+ use Phoenix.Component
+
+ # live-shadcn: upstream facts start
+ @upstream_facts %{
+ "jsx/Card/class/0" => "cn-card group/card flex flex-col",
+ "jsx/CardAction/class/0" =>
+ "cn-card-action col-start-2 row-span-2 row-start-1 self-start justify-self-end",
+ "jsx/CardContent/class/0" => "cn-card-content",
+ "jsx/CardDescription/class/0" => "cn-card-description",
+ "jsx/CardFooter/class/0" => "cn-card-footer flex items-center",
+ "jsx/CardHeader/class/0" =>
+ "cn-card-header group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",
+ "jsx/CardTitle/class/0" => "cn-card-title cn-font-heading"
+ }
+ # live-shadcn: upstream facts end
+ Module.get_attribute(__MODULE__, :upstream_facts)
+
+ defp upstream_fact(key), do: Map.fetch!(@upstream_facts, key)
+
+ @doc "The `card` part."
+ attr(:size, :string, default: "default", values: ["default", "sm"])
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def card(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `card-header` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def card_header(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `card-footer` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def card_footer(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `card-title` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def card_title(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `card-action` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def card_action(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `card-description` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def card_description(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `card-content` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def card_content(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+end
diff --git a/examples/chat/lib/chat_web/components/ui/collapsible.ex b/examples/chat/lib/chat_web/components/ui/collapsible.ex
new file mode 100644
index 0000000..5ba2dae
--- /dev/null
+++ b/examples/chat/lib/chat_web/components/ui/collapsible.ex
@@ -0,0 +1,196 @@
+# live_shadcn: collapsible @ 0.1.0 (f426fb14dbc2)
+# Generated from the shadcn registry. Regenerate upstream, never here.
+# `mix ui.sync` reports what changed upstream and skips files you edited.
+
+defmodule ChatWeb.Components.UI.Collapsible do
+ @moduledoc """
+ Collapsible. Groups all parts of the collapsible.
+
+ Reviewed from upstream. The marked upstream fact block is synchronized.
+ The HEEx body is maintained as a LiveView port.
+
+ | Upstream | Digest |
+ |---|---|
+ | `shadcn/ui/collapsible.tsx` | `ead4349ff7b0` |
+ """
+
+ use Phoenix.Component
+
+ # live-shadcn: upstream facts start
+ @upstream_facts %{}
+ # live-shadcn: upstream facts end
+ Module.get_attribute(__MODULE__, :upstream_facts)
+
+ alias LiveBase.Disclosure
+ alias Phoenix.LiveView.JS
+
+ @doc """
+ Groups all parts of the collapsible.
+
+ <.collapsible id="details" title="Show details">
+ The panel body.
+
+
+ The local toggle runs on the client. Set `phx-click` on the trigger to send
+ a server event or run a caller JS command after the toggle. `trigger_attrs`
+ accepts the same command on the grouped component.
+ """
+ attr(:id, :string, required: true, doc: "Every id inside the component derives from it.")
+ attr(:title, :any, default: nil, doc: "The trigger content when no trigger slot is given.")
+ attr(:composed, :boolean, default: false, doc: "Render caller-owned trigger and content parts.")
+
+ attr(:controlled, :boolean, default: false, doc: "Let server assigns own the disclosure state.")
+ attr(:open, :boolean,
+ default: false,
+ doc:
+ "Whether the collapsible panel is initially open. To render a controlled collapsible, use the `open` prop instead."
+ )
+
+ attr(:disabled, :boolean,
+ default: false,
+ doc: "Whether the component should ignore user interaction."
+ )
+
+ attr(:orientation, :string, default: "vertical", doc: "")
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:content_class, :any, default: nil, doc: "Appended to the content class string.")
+ attr(:trigger_class, :any, default: nil, doc: "Appended to the trigger class string.")
+ attr(:trigger_attrs, :map, default: %{}, doc: "Attributes merged onto the trigger button.")
+
+ attr(:wrapper_tag, :string,
+ default: nil,
+ doc: "An optional element around the trigger and panel."
+ )
+
+ attr(:wrapper_attrs, :map, default: %{}, doc: "Attributes for the optional wrapper.")
+ attr(:rest, :global)
+
+ slot(:trigger, doc: "Rich trigger content.")
+ slot(:inner_block, required: true, doc: "The panel body.")
+
+ def collapsible(assigns) do
+ ~H"""
+
<%= if @composed do %>{render_slot(@inner_block)}<% else %>
+ <.dynamic_tag :if={@wrapper_tag} tag_name={@wrapper_tag} {@wrapper_attrs}>
+ <.collapsible_parts {assigns} />
+
+ <.collapsible_parts :if={is_nil(@wrapper_tag)} {assigns} />
+ <% end %>
+ """
+ end
+
+ defp collapsible_parts(assigns) do
+ ~H"""
+ <.collapsible_trigger
+ for={@id}
+ open={@open}
+ controlled={@controlled}
+ disabled={@disabled}
+ class={@trigger_class}
+ {@trigger_attrs}
+ >
+ {if(@trigger == [], do: @title, else: render_slot(@trigger))}
+
+ <.collapsible_content
+ for={@id}
+ open={@open}
+ controlled={@controlled}
+ class={@content_class}
+ >
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The button that opens or closes a composed collapsible."
+ attr(:for, :string, required: true, doc: "The id of the collapsible root.")
+ attr(:controlled, :boolean, default: false, doc: "Let server assigns own the disclosure state.")
+ attr(:open, :boolean, default: false)
+ attr(:disabled, :boolean, default: false)
+ attr(:class, :any, default: nil)
+ attr(:rest, :global, include: ["data-slot", "type"])
+ slot(:inner_block, required: true)
+
+ def collapsible_trigger(assigns) do
+ ~H"""
+
+ """
+ end
+
+ @doc "The panel that a composed collapsible shows or hides."
+ attr(:for, :string, required: true, doc: "The id of the collapsible root.")
+ attr(:controlled, :boolean, default: false, doc: "Let server assigns own the disclosure state.")
+ attr(:open, :boolean, default: false)
+ attr(:class, :any, default: nil)
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block, required: true)
+
+ def collapsible_content(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ defp caller_click(command, nil), do: command
+ defp caller_click(command, ""), do: command
+ defp caller_click(command, %JS{} = caller), do: JS.concat(command, caller)
+ defp caller_click(command, event) when is_binary(event), do: JS.push(command, event)
+
+ # A disabled disclosure ignores interaction. `aria-disabled` and
+ # `pointer-events-none` say so to a reader and to a mouse, but a keypress
+ # on a focused trigger reaches neither, so the command itself is withheld.
+ defp interactive(false, command), do: command
+ defp interactive(_disabled, _command), do: nil
+
+ # An HTML attribute with no value, or no attribute at all. Base UI marks
+ # state by presence, so `data-open=""` and a missing `data-open` are the
+ # two states a shadcn class string distinguishes.
+ defp flag(true), do: ""
+ defp flag(_state), do: nil
+end
diff --git a/examples/chat/lib/chat_web/components/ui/empty.ex b/examples/chat/lib/chat_web/components/ui/empty.ex
new file mode 100644
index 0000000..b56751b
--- /dev/null
+++ b/examples/chat/lib/chat_web/components/ui/empty.ex
@@ -0,0 +1,173 @@
+# live_shadcn: empty @ 0.1.0 (74738014de7c)
+# Generated from the shadcn registry. Regenerate upstream, never here.
+# `mix ui.sync` reports what changed upstream and skips files you edited.
+
+defmodule ChatWeb.Components.UI.Empty do
+ @moduledoc """
+ Empty.
+
+ Reviewed from upstream. The marked upstream fact block is synchronized.
+ The HEEx body is maintained as a LiveView port.
+ """
+
+ use Phoenix.Component
+
+ # live-shadcn: upstream facts start
+ @upstream_facts %{
+ "cva/emptyMediaVariants/base" =>
+ "cn-empty-media flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
+ "cva/emptyMediaVariants/default/variant" => "default",
+ "cva/emptyMediaVariants/variant/variant/default" => "cn-empty-media-default",
+ "cva/emptyMediaVariants/variant/variant/icon" => "cn-empty-media-icon",
+ "jsx/Empty/class/0" =>
+ "cn-empty flex w-full min-w-0 flex-1 flex-col items-center justify-center text-center text-balance",
+ "jsx/EmptyContent/class/0" =>
+ "cn-empty-content flex w-full max-w-sm min-w-0 flex-col items-center text-balance",
+ "jsx/EmptyDescription/class/0" =>
+ "cn-empty-description text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
+ "jsx/EmptyHeader/class/0" => "cn-empty-header flex max-w-sm flex-col items-center",
+ "jsx/EmptyTitle/class/0" => "cn-empty-title cn-font-heading"
+ }
+ # live-shadcn: upstream facts end
+ Module.get_attribute(__MODULE__, :upstream_facts)
+
+ defp upstream_fact(key), do: Map.fetch!(@upstream_facts, key)
+
+ @variant_classes (for {"cva/" <> path, value} <- @upstream_facts,
+ [table, "variant", group, choice] <- [String.split(path, "/")],
+ reduce: %{} do
+ variants ->
+ put_in(
+ variants,
+ [
+ Access.key(table, %{}),
+ Access.key(group, %{}),
+ Access.key(choice, nil)
+ ],
+ value
+ )
+ end)
+
+ @doc "The `empty` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def empty(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `empty-header` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def empty_header(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `empty-title` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def empty_title(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `empty-description` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def empty_description(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `empty-content` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def empty_content(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `empty-icon` part."
+ attr(:variant, :string,
+ default: @upstream_facts["cva/emptyMediaVariants/default/variant"],
+ values:
+ @variant_classes |> get_in(["emptyMediaVariants", "variant"]) |> Map.keys() |> Enum.sort()
+ )
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def empty_media(assigns) do
+ ~H"""
+
+ """
+ end
+
+ @doc "The `item-content` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def item_content(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `item-actions` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def item_actions(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `item-group` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def item_group(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `item-separator` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def item_separator(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `item-title` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def item_title(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `item-description` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def item_description(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `item-header` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def item_header(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ @doc "The `item-footer` part."
+
+ attr(:class, :any, default: nil, doc: "Appended to the class string upstream renders.")
+ attr(:rest, :global, include: ["data-slot"])
+ slot(:inner_block)
+
+ def item_footer(assigns) do
+ ~H"""
+
+ {render_slot(@inner_block)}
+
+ """
+ end
+
+ defp variant_class(table, group, value),
+ do: get_in(@variant_classes, [table, group, value])
+
+ defp item_title_class(nil), do: upstream_fact("jsx/ItemTitle/class/0")
+
+ defp item_title_class(class),
+ do: LiveShadcn.Cn.merge([upstream_fact("jsx/ItemTitle/class/0"), class])
+end
diff --git a/examples/chat/lib/chat_web/layouts.ex b/examples/chat/lib/chat_web/layouts.ex
index 6c94961..e33c803 100644
--- a/examples/chat/lib/chat_web/layouts.ex
+++ b/examples/chat/lib/chat_web/layouts.ex
@@ -4,12 +4,21 @@ defmodule ChatWeb.Layouts do
def root(assigns) do
~H"""
-
+
AudioFlow chat
+ <%!-- Follow the system color scheme, as the docs do. --%>
+
+
+
+
diff --git a/examples/chat/lib/chat_web/live/chat_live.ex b/examples/chat/lib/chat_web/live/chat_live.ex
index 99ea642..318a33b 100644
--- a/examples/chat/lib/chat_web/live/chat_live.ex
+++ b/examples/chat/lib/chat_web/live/chat_live.ex
@@ -26,8 +26,14 @@ defmodule ChatWeb.ChatLive do
alias AudioFlow.Text
alias Chat.Catalog
alias Chat.Setup
+ alias ChatWeb.Components.UI.Alert
alias ChatWeb.Components.UI.Badge
alias ChatWeb.Components.UI.Button
+ alias ChatWeb.Components.UI.Card
+ alias ChatWeb.Components.UI.Collapsible
+ alias ChatWeb.Components.UI.Empty
+ alias ChatWeb.Components.UI.Field
+ alias ChatWeb.Components.UI.Item
alias ChatWeb.Components.UI.NativeSelect
alias ChatWeb.Components.UI.Spinner
alias LiveAiElements.Components.AudioPlayer
@@ -252,6 +258,13 @@ defmodule ChatWeb.ChatLive do
def handle_event("call_failed", %{"message" => message}, socket) when is_binary(message),
do: {:noreply, call_error(socket, "Microphone error: " <> String.slice(message, 0, 200))}
+ # The voice applies at the next call start, so it needs no new chat and no Apply.
+ def handle_event("select_voice", %{"voice" => voice}, socket) do
+ if voice in Setup.voices() and is_nil(socket.assigns.call),
+ do: {:noreply, assign(socket, settings: Map.put(socket.assigns.settings, "voice", voice))},
+ else: {:noreply, socket}
+ end
+
def handle_event("select_model", %{"_target" => [field]} = params, socket)
when field in ["stt", "llm", "voice"] do
result = Chat.Engine.select(String.to_existing_atom(field), params[field])
@@ -943,16 +956,24 @@ defmodule ChatWeb.ChatLive do
~H"""
-
AudioFlow
+
+
+ AudioFlow
+
{if @duplex, do: "Clear text", else: "New chat"}
-
≈ {gb(@models.memory_gb)} GB of model weights{if @system_memory_gb,
do: " · #{gb(@system_memory_gb)} GB memory"}. {fit_text(@system_memory_gb)}
@@ -1089,21 +1116,35 @@ defmodule ChatWeb.ChatLive do
Text only, with all words replaced by [REDACTED]. Deleted when you leave.
-
- {id}
-
- Download
-
-
- Delete
-
-
+
+
+ {id}
+
+
+
+ Download
+
+
+ Delete
+
+
+
-
+
-
- No messages yet.
-
+
+
+
+
+
+ No messages yet.
+
+ {if @duplex,
+ do: "Start the conversation and speak.",
+ else: "Type a message, or record one with the microphone."}
+
+
+
@@ -1132,9 +1173,8 @@ defmodule ChatWeb.ChatLive do
-
- Diagnostics
-