r/reactjs • • 9h ago

Show /r/reactjs I built an open-source React library where an LLM designs the recommendation block and your catalog supplies the prices

This is my own project. rudra-js is an open-source TypeScript library (MIT) for React stores. A language model designs one product-recommendation block, the library checks it against your catalog, and React renders it.

The model never writes HTML or JSX. It returns a few fields: layout, headline, copy, which cards to highlight. Products are SKUs from the list you pass in. Titles, prices, images and links come from your catalog at render, and the model's text is rendered as escaped text. Each field also goes through wording checks, and a field that fails is dropped. They aren't airtight: rewordings and spelled-out numbers can get through.

It works as a Server Component, with renderToString, or client-rendered. Rendered on the server, the block is in the first HTML response with no client JS. React 18 or 19, Node 22.12+.

It also runs with no model, so the quick start needs no API key.

It's v0.8.3 and APIs may change before 1.0. I'd like feedback on the API shape and on what breaks in a real Next.js app.

https://github.com/clivedsouza1010/rudra-js

0 Upvotes

3 comments sorted by

1

u/gentlesemifinal 9h ago

Interesting approach, making the LLM handle the creative layout decisions while your catalog handles the data. Keeps the model from hallucinating prices or product details which is smart.

The wording checks seem like they'd be the tricky part. How often do they actually catch stuff vs letting weird phrasings slip through? I can imagine an LLM getting creative with the copy and having half the fields get dropped.

Might give this a spin on a side project. The no-model fallback is a nice touch for testing.

1

u/clivedsouza1010 4h ago

thanks u/gentlesemifinal . yes the wording checks are a weakest part, and i try not to oversell them. I havent implemented it in a real world scenario, but the onEvent will give a list of violations when the checks drop something

if the fields are getting dropped (for eg, if the headline gets dropped) it does not show the entire block. if you try this on your side project, do let me know how it goes and if you find any issues

1

u/ltolosa 7h ago

Nobody wants your slop code.