diff --git a/packages/react/core/src/exports/messageOptions.tsx b/packages/react/core/src/exports/messageOptions.tsx index bb95fde7..269cd86e 100644 --- a/packages/react/core/src/exports/messageOptions.tsx +++ b/packages/react/core/src/exports/messageOptions.tsx @@ -5,7 +5,7 @@ export type ResponseComponentProps = { uid: string; status: 'streaming' | 'complete'; response?: AiMsg; - containerRef: RefObject; + containerRef: RefObject; }; export type ResponseComponent = FunctionComponent>; diff --git a/packages/react/core/src/logic/MessageRenderer/MessageRenderer.tsx b/packages/react/core/src/logic/MessageRenderer/MessageRenderer.tsx index c449c5f7..5a1d89d0 100644 --- a/packages/react/core/src/logic/MessageRenderer/MessageRenderer.tsx +++ b/packages/react/core/src/logic/MessageRenderer/MessageRenderer.tsx @@ -35,7 +35,7 @@ export const createMessageRenderer: ( status, // We only pass the response to custom renderer when the status is 'complete'. response: status === 'complete' ? message as AiMsg : undefined, - containerRef: containerRefToUse, + containerRef: containerRefToUse as RefObject, }); } diff --git a/samples/aiChat/react/src/App.tsx b/samples/aiChat/react/src/App.tsx index 64d7fc66..bf89ed62 100644 --- a/samples/aiChat/react/src/App.tsx +++ b/samples/aiChat/react/src/App.tsx @@ -81,10 +81,31 @@ function App() { syntaxHighlighter: highlighter, // showCodeBlockCopyButton: false, // streamingAnimationSpeed: 100, - responseComponent: ({response}) => { + promptComponent: ({prompt}) => { return (
-
{response}
+
{prompt}
+
Custom Prompt Component +
+
+ ); + }, + responseComponent: ({ + response, + status, + containerRef, + }) => { + console.log(status); + return ( +
+ {response ?
{response}
:
}
> = ( +const CustomMessageComponent: FunctionComponent< + ResponseComponentProps +> = ( {response}, ) => { const color = useMemo(() => possibleColors[Math.floor(Math.random() * possibleColors.length)], []);