npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

superluminal-react

v1.1.0

Published

The official front-end React component for the Superluminal API.

Downloads

25

Readme

superluminal-react

The official front-end React component for the Superluminal API.

For more information visit the full documentation.

Example App

For a full example app, see https://github.com/superluminalengineering/superluminal-react-example.

Tutorial

The Superluminal React component is the easiest way to add conversational data interaction similar to ChatGPT + CodeInterpreter to your dashboard. The layout of the component is customizable and should be sufficient to let you style it according to your branding. That said, if you need even deeper customization we recommend you take a look at the Direct API Usage Tutorial.

Integrating the Superluminal React component consists of four steps. Three that you'll need to take from your back-end, and one that you'll need to take from your front-end:

From your back-end:

Step 1: Creating the session

To get started, hit the POST /sessions endpoint from your server when your user enters their dashboard. This starts a new session for the given user_id / project_id combination. Usually, the user_id will be the ID you maintain internally for your user, and project_id will just be "main". If you set transient to true, all data associated with the session will be deleted after you're done.

Hold on to the token returned by POST /sessions as you'll need it later.

Step 2: Specifying the schema

Before you upload your data in the final step, you'll need to specify the schema (i.e. format/structure) of your data. You do this by supplying a JSON schema to PUT /users/:user_id/projects/:project_id/schema, where user_id and project_id are the values you previously used while establishing the session.

Supplying a good schema is key to getting great results from the AI assistant. You can read about available schema options in more detail here, but an example request might look like the snippet shown. If a column is marked as required, it cannot contain empty values.

{
    "columns": [ "ID", "Product", "Date", … ],
    "schema": {
        "type": "object",
        "description": "A single order",
        "properties": {
            "ID": { "type": "integer" },
            "Product": { "type": "string" },
            "Date": {
                "type": "string",
                "format": "date-time",
                "description": "The date the order was placed"
            },
            …
        },
        "required": [ "ID", "Product", … ]
    }
}

Need help with your schema? Contact us.

Step 3: Supplying the data

The final step is to supply the data. You do this by sending the user's dashboard data in CSV format from your server to PUT /users/:user_id/projects/:project_id/data, where user_id and project_id are the values you previously used while establishing the session, as in the previous step.

From your front-end:

To add the React component to your dashboard, all you need to do is install the package using npm install superluminal-react (or yarn add superluminal-react) and add the following code. The superluminalAuthToken is the auth token you received when you created the session from your back-end.

import Superluminal from 'superluminal-react'

// Use the various `style` props to customize the look and feel
<Superluminal ref={superluminalRef} authToken={superluminalAuthToken} style={ ... } />

// Optionally use the `setUser` method to set user info when available. The user's 
// name will default to 'User' in the chat if left blank.
superluminalRef.current?.setUser({ id: $USER_ID, name: $USER_NAME })

And that's it! You should now have a working AI copilot in your data dashboard, including full support for plotting, filtering and pivoting!