A TypeScript library for dynamic, accurate product recommendations.
Project details
rudra-js is an open-source TypeScript library designed to create tailored product-recommendation blocks for e-commerce sites. By ensuring that language models only generate valid content based on existing product data, it enhances accuracy while integrating seamlessly with React. Explore better ways to engage your customers without compromising on authenticity.
rudra-js is an open-source TypeScript library designed to streamline product recommendations for e-commerce applications. With its innovative approach, rudra-js utilizes a language model to create a product-recommendation block tailored for each page within a shop. This library performs robust checks against your product catalog and leverages React for rendering, ensuring that the output is both accurate and reliable.
Key Features:
Packages Included:
| Package | Functionality |
|---|---|
@rudra-js/core | Contains the schemas and logic for transforming tracking input into valid specifications for rendering. |
@rudra-js/react | Renders specifications using React, compatible with both server-side and client-side rendering paradigms. |
@rudra-js/anthropic | Facilitates communication with the Anthropic API for advanced language modeling capabilities. |
@rudra-js/attested | Checks the generated text against actual product data, ensuring fidelity and accuracy in recommendations. |
@rudra-js/a2ui | Integrates with A2UI agents for seamless product placement while maintaining control over product selection. |
Example Usage:
import { createComponentGenerator, parseTrackingInput } from '@rudra-js/core';
import { RudraComponent } from '@rudra-js/react';
const catalog = [
{ sku: 'A-1', title: 'Cast iron skillet', category: 'Cookware', price: 39, currency: 'USD' },
{ sku: 'A-2', title: 'Enamel dutch oven', category: 'Cookware', price: 89, currency: 'USD' },
{ sku: 'A-3', title: 'Chef knife', category: 'Knives', price: 55, currency: 'USD' },
];
async function recommendations() {
const generator = createComponentGenerator({ provider: null });
const input = parseTrackingInput({
user: { id: 'shopper-1' },
context: { surface: 'pdp', currentSku: 'A-1', currentCategory: 'Cookware' },
candidates: catalog,
signals: { cart: [{ sku: 'A-2', at: Date.now() }] },
});
const spec = await generator.generate(input);
return <RudraComponent spec={spec} products={input.candidates} locale="en-US" />;
}
For a comprehensive overview of how to implement and use rudra-js, please refer to the documentation. With its unique capabilities, rudra-js simplifies the process of creating personalized shopping experiences, making it an essential tool for modern e-commerce solutions.
Comments
0Start the conversation
Share the first comment.