Add apiUrl, assistantId to props

This commit is contained in:
Tat Dat Duong
2025-03-06 17:04:59 +01:00
parent c9ffd753f5
commit b73b34ddd5
+6 -2
View File
@@ -63,10 +63,14 @@ const EXT_STORE_SYMBOL = Symbol.for("LGUI_EXT_STORE");
const REQUIRE_SYMBOL = Symbol.for("LGUI_REQUIRE");
export function LoadExternalComponent({
apiUrl = "http://localhost:2024",
assistantId,
stream,
message,
className,
}: {
apiUrl?: string;
assistantId: string;
stream: ReturnType<typeof useStream>;
message: UIMessage;
className?: string;
@@ -82,7 +86,7 @@ export function LoadExternalComponent({
const state = React.useSyncExternalStore(store.subscribe, store.getSnapshot);
React.useEffect(() => {
fetch("http://localhost:3123", {
fetch(`${apiUrl}/ui/${assistantId}`, {
headers: { "Content-Type": "application/json" },
method: "POST",
body: JSON.stringify({ name: message.name, shadowRootId }),
@@ -95,7 +99,7 @@ export function LoadExternalComponent({
const fragment = document.createRange().createContextualFragment(html);
root.appendChild(fragment);
});
}, [message.name, shadowRootId]);
}, [apiUrl, assistantId, message.name, shadowRootId]);
return (
<>