Merge remote-tracking branch 'origin/main' into open-avatar-chat-0.4.0

This commit is contained in:
bingochaos
2025-06-17 20:39:40 +08:00
142 changed files with 117010 additions and 814 deletions

View File

@@ -14,10 +14,10 @@
export let avatar_type: string = ""
export let avatar_ws_route: string = ""
export let avatar_assets_path: string = ""
import type { WebRTCValue } from "./shared/utils";
export let elem_id = "";
export let elem_classes: string[] = [];
export let visible = true;
export let value: string = "__webrtc_value__";
export let button_labels: { start: string; stop: string; waiting: string };
export let label: string;
@@ -28,6 +28,9 @@
export let width: number | undefined;
export let server: {
offer: (body: any) => Promise<any>;
turn: () => Promise<any>;
trigger_response: (body: any) => Promise<any>;
quit_output_stream: (body: any) => Promise<any>;
};
export let container = false;
@@ -44,20 +47,37 @@
export let icon_button_color: string = "var(--color-accent)";
export let pulse_color: string = "var(--color-accent)";
export let icon_radius: number = 50;
export let variant: "textbox" | "wave" = "wave";
export let value: WebRTCValue | string =
variant === "textbox" ||
((mode === "send-receive" || mode == "send") && modality === "audio")
? {
textbox: "",
webrtc_id: "__webrtc_value__",
}
: "__webrtc_value__";
const on_change_cb = (msg: "change" | "tick" | any) => {
console.log("on_change_cb in index.svelte", msg);
if (
msg?.type === "info" ||
msg?.type === "warning" ||
msg?.type === "error"
) {
gradio.dispatch(msg?.type === "error" ? "error" : "warning", msg.message);
gradio.dispatch(
msg?.type === "error" ? "error" : "warning",
msg?.data || msg?.message,
);
} else if (msg?.type === "end_stream") {
gradio.dispatch("warning", msg.data);
} else if (msg?.type === "fetch_output") {
gradio.dispatch("state_change");
} else if (msg?.type === "send_input") {
gradio.dispatch("tick");
} else if (msg?.type === "submit") {
console.log("submit in index.svelte", msg.data);
gradio.dispatch("submit", msg.data);
} else if (msg?.type === "connection_timeout") {
gradio.dispatch(
"warning",
@@ -78,6 +98,11 @@
"error",
`Too many concurrent connections. Please try again later!`,
);
} else if (
msg.status === "failed" &&
msg.meta?.error === "connection_already_exists"
) {
gradio.dispatch("error", "Connection already exists");
} else {
gradio.dispatch("error", "Unexpected server error");
}
@@ -226,6 +251,9 @@
{icon_radius}
{pulse_color}
{button_labels}
{variant}
on:start_recording={() => gradio.dispatch("start_recording")}
on:stop_recording={() => gradio.dispatch("stop_recording")}
on:tick={() => gradio.dispatch("tick")}
on:error={({ detail }) => gradio.dispatch("error", detail)}
on:warning={({ detail }) => gradio.dispatch("warning", detail)}