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

messageRendered event in AiChat component's events property is not working. #106

Closed Demiourgos87 closed 4 days ago

Demiourgos87 commented 4 days ago

When trying to access the event messageRendered in AiChat component, it does not work. The messageReceived works for example.

  <AiChat
    adapter={adapter}
    events={{
      messageReceived: () => console.log('Message received.....'), // this logs
      messageRendered: () => console.log('Message rendered.....')  // this does not log
    }}
    displayOptions={{
      themeId: 'nova',
      colorScheme: 'light',
    }}
    composerOptions={{
      placeholder: 'How can I help you today?'
    }}
  />

Also noticed in the nlux-core.d.ts, line 640:

messageReceived: MessageReceivedCallback<AiMsg>;
messageRendered: MessageReceivedCallback<AiMsg>;

although the MessageRenderedCallback type exists.

ognjenAct commented 4 days ago

Hi there, same problem on my side as well, any solution for this? or workaround ?

salmenus commented 4 days ago

Hi @Demiourgos87 @ognjenAct Thanks for raising this issue. I'm investigating.

Demiourgos87 commented 4 days ago

Hello @salmenus, thank you for the quick response. I am using the chat adapter from @nlux/langchain-react package, so no custom adapters.

I forked one of the examples, here it is: https://codesandbox.io/s/priceless-poitras-q9frn7?file=/App.tsx

If you open the console, you will notice the issue I am facing, there is no log for messageRendered.

salmenus commented 4 days ago

Got it. Thanks for the reproducible example. I'm working on a fix @Demiourgos87

salmenus commented 4 days ago

Issue fixed in version 2.12.2 βœ…

Please that the full message ( event. message property ) will only be passed to the message received. The message rendered only gets the UI. But it's consistent between the 2 events.

Screenshot 2024-06-28 at 20 05 48
Demiourgos87 commented 2 days ago

Thank you for the quick update, keep up the good work!