nlkitai / nlux

The ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ๐—ณ๐˜‚๐—น Conversational AI JavaScript Library ๐Ÿ’ฌ โ€”ย UI for any LLM, supporting LangChain / HuggingFace / Vercel AI, and more ๐Ÿงก React, Next.js, and plain JavaScript โญ๏ธ
https://docs.nlkit.com/nlux
Other
937 stars 48 forks source link

How patch/attach to the original AiMessageRenderer instead of building a new one #78

Open mstfash opened 3 weeks ago

mstfash commented 3 weeks ago

Hi, nice work as usual.

i am wondering how to just patch/attach something to already rendered AiMessageComponent from nlux instead of building a new one. is this feasible ? would be great to have something like that, for example I wanna attach feedback buttons to the message and rebuilding the whole AiMessageComponent is just a drag.

Thanks in advance!

salmenus commented 2 weeks ago

Hi @mstfash โ€”ย Sound like an easy and useful customisation to implement. Let me do that for you (original renderer + custom UI around it). I'll post an update here once it's done.

salmenus commented 1 week ago

You can look at example here @mstfash : https://docs.nlkit.com/nlux/reference/ui/markdown#with-batched-custom-renderers

import {memo} from 'react';
import {ResponseRenderer, Markdown} from '@nlux/react';

const responseRenderer: ResponseRenderer<string> = memo((props) => {
    const {content} = props;
    return (
        <div className="myCustomRenderer">
            <Markdown>{content}</Markdown>
        </div>
    );
});

That custom renderer would render markdown the same as it's being streamed. Does that solved your problem? Or you were rather looking not to build a create a new renderer at all?