You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a lot of information below, sorry if this is a bit disordered, I try to update the issue everytime it gets clearer on my mind, I'll try to split it too.
I'm currently using the streaming custom adapter (to have the writing effect) while I'm received a single (full) message of text from my API.
import{StreamResponseComponentProps}from"@nlux/react";importReactfrom"react";exportfunctionMyResponseResponseRenderer<AiMsg=string>(props: StreamResponseComponentProps<AiMsg>){console.log(props);return(<divclassName="flex flex-col"><divref={props.containerRef}/><divclassName="grid grid-cols-3"><buttononClick={()=>console.log("I like it!")}>👍</button><buttononClick={()=>console.log("I love it!")}>❤️</button><buttononClick={()=>console.log("I hate it!")}>😵</button></div></div>);}
With the response renderer defined in sample code at the beginning of this post I get no content on NextJS SSR (use client). Which means the containerRef is not defined. Which seems OK because SSR. And if i use props.content (which is a string and not an array as we saw) I got the plain markdown content.
Here are some observations / suggestions of what we might do. Or you can tell me if you have some.
1. It's okay that server/initialConversation content is considered dataTransferMode: "batch" that way we can define a different render code for server/initialConversation. But we could need the default parser, otherwise, messages are not rendered as markdown but plain text ? Or should i use my own renderer for MD ?.
2. For client/adapter message with stream or whatever what can we do ? Maybe expose primitives and/or some components for streaming message instead of using the containerRef would be better.
💡 Briefly: - Expose a DefaultStreamingRenderer component instead of containerRef to handle the streaming mode if someone use a custom renderer. (more flexibility) This component would receive content props which should be the same for streaming/batch.
- For client side (after receiving a message from the adapter), containerRef is defined but content is empty.
status: "streaming" never go complete
When using the above code, I never get status: "streaming", going to complete. for streaming messages
The text was updated successfully, but these errors were encountered:
Note
There is a lot of information below, sorry if this is a bit disordered, I try to update the issue everytime it gets clearer on my mind, I'll try to split it too.
I'm currently using the streaming custom adapter (to have the writing effect) while I'm received a single (full) message of text from my API.
Summary
content
prop. (See Custom renderercontent
prop is defined as an Array but is a string #75)complete
Code sample
Click to see my code
Attachments
initialConversation
from NextJS React server component withuse client
directive.Typing issue
content
property.Note
See #75
See the screenshot above.Custom response renderer.
containerRef
is not defined. Which seems OK because SSR. And if i useprops.content
(which is a string and not an array as we saw) I got the plain markdown content.What can we do ?
Note
See #74
Tip
Here are some observations / suggestions of what we might do. Or you can tell me if you have some.
1. It's okay that server/initialConversation content is considereddataTransferMode: "batch"
that way we can define a different render code for server/initialConversation. But we could need the default parser, otherwise, messages are not rendered as markdown but plain text ? Or should i use my own renderer for MD ?.2. For client/adapter message with stream or whatever what can we do ? Maybe expose primitives and/or some components for streaming message instead of using the
containerRef
would be better.💡 Briefly:- Expose aDefaultStreamingRenderer
component instead ofcontainerRef
to handle the streaming mode if someone use a custom renderer. (more flexibility) This component would receivecontent
props which should be the same for streaming/batch.- For client side (after receiving a message from the adapter),containerRef
is defined butcontent
is empty.status: "streaming" never go
complete
When using the above code, I never get
status: "streaming",
going to complete. for streaming messagesThe text was updated successfully, but these errors were encountered: