fix rendering of custom ui components

This commit is contained in:
bracesproul
2025-03-11 13:02:07 -07:00
parent 72b9ebcf04
commit a6105de7cc
3 changed files with 2136 additions and 4281 deletions

View File

@@ -18,10 +18,10 @@
"@assistant-ui/react-markdown": "^0.8.0",
"@assistant-ui/react-syntax-highlighter": "^0.7.2",
"@langchain/core": "^0.3.41",
"@langchain/langgraph": "^0.2.49",
"@langchain/langgraph-api": "^0.0.14",
"@langchain/langgraph-cli": "^0.0.14",
"@langchain/langgraph-sdk": "^0.0.52",
"@langchain/langgraph": "^0.2.54",
"@langchain/langgraph-api": "^0.0.15",
"@langchain/langgraph-cli": "^0.0.15",
"@langchain/langgraph-sdk": "^0.0.53",
"@radix-ui/react-avatar": "^1.1.3",
"@radix-ui/react-dialog": "^1.1.6",
"@radix-ui/react-label": "^2.1.2",

6398
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -20,15 +20,12 @@ function CustomComponent({
message: Message;
thread: ReturnType<typeof useStreamContext>;
}) {
const { values } = useStreamContext();
const meta = thread.getMessagesMetadata(message);
const seenState = meta?.firstSeenState;
const customComponents = seenState?.values.ui
?.slice()
.filter(({ additional_kwargs }) =>
!additional_kwargs.message_id
? additional_kwargs.run_id === seenState.metadata?.run_id
: additional_kwargs.message_id === message.id,
);
console.log("seenState?.values.ui", seenState?.values.ui)
const customComponents = values.ui
?.filter((ui) => ui.metadata?.message_id === message.id)
if (!customComponents?.length) return null;
return (