mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-09 19:27:54 +02:00
feat(sdk-js): cleanup types for ui payloads (#3773)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@langchain/langgraph-sdk",
|
||||
"version": "0.0.52",
|
||||
"version": "0.0.53",
|
||||
"description": "Client library for interacting with the LangGraph API",
|
||||
"type": "module",
|
||||
"packageManager": "yarn@1.22.19",
|
||||
|
||||
@@ -175,7 +175,7 @@ export function LoadExternalComponent({
|
||||
]);
|
||||
|
||||
if (hasClientComponent) {
|
||||
return React.createElement(clientComponent, message.content);
|
||||
return React.createElement(clientComponent, message.props);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -185,7 +185,7 @@ export function LoadExternalComponent({
|
||||
<UseStreamContext.Provider value={{ stream, meta }}>
|
||||
{state?.target != null
|
||||
? ReactDOM.createPortal(
|
||||
React.createElement(state.comp, message.content),
|
||||
React.createElement(state.comp, message.props),
|
||||
state.target,
|
||||
)
|
||||
: fallback}
|
||||
|
||||
@@ -30,8 +30,8 @@ export const typedUi = <Decl extends Record<string, ElementType>>(config: {
|
||||
message: {
|
||||
id?: string;
|
||||
name: K;
|
||||
content: PropMap[K];
|
||||
additional_kwargs?: Record<string, unknown>;
|
||||
props: PropMap[K];
|
||||
metadata?: Record<string, unknown>;
|
||||
},
|
||||
options?: { message?: MessageLike },
|
||||
): UIMessage => {
|
||||
@@ -39,10 +39,10 @@ export const typedUi = <Decl extends Record<string, ElementType>>(config: {
|
||||
type: "ui" as const,
|
||||
id: message?.id ?? uuidv4(),
|
||||
name: message?.name,
|
||||
content: message?.content,
|
||||
additional_kwargs: {
|
||||
props: message?.props,
|
||||
metadata: {
|
||||
...metadata,
|
||||
...message?.additional_kwargs,
|
||||
...message?.metadata,
|
||||
...(options?.message ? { message_id: options.message.id } : null),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -3,8 +3,8 @@ export interface UIMessage {
|
||||
|
||||
id: string;
|
||||
name: string;
|
||||
content: Record<string, unknown>;
|
||||
additional_kwargs: {
|
||||
props: Record<string, unknown>;
|
||||
metadata: {
|
||||
run_id: string;
|
||||
message_id?: string;
|
||||
[key: string]: unknown;
|
||||
|
||||
Reference in New Issue
Block a user