Open ScreamZ opened 3 weeks ago
The issue related to status
property passed to custom renderers not being updated:
That's now fixed β
2.4
Example here: https://codesandbox.io/p/sandbox/custom-renderer-status-9tt6zt?file=%2FApp.tsx
content
property fixed β
content
is now always an array2.5
- Issue related to
content
property fixed βcontent
is now always an array- Fixed in
2.5
- Give it a try and let me know @ScreamZ
Looks good so far, now we can implement any renderer we want.
One more item is still pending: Rendering difference between environments
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 https://github.com/nluxai/nlux/issues/75)complete
Code sample
Click to see my code
```tsx import { StreamResponseComponentProps } from "@nlux/react"; import React from "react"; export function MyResponseResponseRenderer(props: StreamResponseComponentProps) {
console.log(props);
return (
);
}
```
```ts
import type { ChatAdapter, StreamingAdapterObserver } from "@nlux/core";
import { sendMessage } from "../server/actions/sendMessage";
import { parseResponseMessageParsing } from "../utils/message-parsers";
export const MyAdapterBuilder = (characterID: string, conversationID: string): ChatAdapter => ({
streamText: async (message: string, observer: StreamingAdapterObserver) => {
const result = await sendMessage({
character: characterID,
conversation: conversationID,
userInputMessage: message,
});
const parseResult = parseResponseMessageParsing(result.data);
if (!result.serverError && parseResult.status === "success") {
observer.next(parseResult.data.message);
observer.complete();
} else {
observer.error(new Error(result.serverError || "Could not generate message"));
}
},
});
```
Attachments
initialConversation
from NextJS React server component withuse client
directive.Typing issue
content
property.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 ?
~~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 ?.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 messages