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

easybeam-react

v1.0.0

Published

A React package for interacting with EasyBeam portals, reviews & workflows

Downloads

64

Readme

Easybeam SDK for React

Build and Test

Overview

The Easybeam SDK for React provides a seamless integration with the Easybeam AI platform, allowing developers to easily incorporate AI-powered chat functionality into their React applications. This SDK supports both streaming and non-streaming interactions with Easybeam's portals and workflows.

Features

  • Stream responses from Easybeam portals and workflows
  • Make non-streaming requests to portals and workflows
  • Handle user reviews for chat interactions
  • TypeScript support for improved developer experience
  • Built-in error handling and event management

Installation

npm install easybeam-react

Usage

Initializing the SDK

import { Easybeam, EasyBeamConfig } from "easybeam-react";

const config: EasyBeamConfig = {
  token: "your-api-token-here",
};

const easybeam = new Easybeam(config);

Streaming a Portal Response

const portalId = "your-portal-id";
const userId = "user-123";
const filledVariables = { key: "value" };
const messages = [
  {
    content: "Hello",
    role: "USER",
    createdAt: new Date().toISOString(),
    id: "1",
  },
];

easybeam.streamPortal(
  portalId,
  userId,
  filledVariables,
  messages,
  (response) => {
    console.log("New message:", response.newMessage);
  },
  () => {
    console.log("Stream closed");
  },
  (error) => {
    console.error("Error:", error);
  }
);

Making a Non-Streaming Portal Request

const response = await easybeam.getPortal(
  portalId,
  userId,
  filledVariables,
  messages
);
console.log("Portal response:", response);

Submitting a Review

await easybeam.review("chat-123", "user-123", 5, "Great experience!");

API Reference

Easybeam Class

The main class for interacting with the Easybeam API.

Methods

  • streamPortal: Stream responses from an Easybeam portal
  • getPortal: Make a non-streaming request to an Easybeam portal
  • streamWorkflow: Stream responses from an Easybeam workflow
  • getWorkflow: Make a non-streaming request to an Easybeam workflow
  • review: Submit a review for a chat interaction
  • cancelCurrentStream: Cancel the current streaming request

Error Handling

The SDK provides built-in error handling for network requests and SSE connections. Errors are passed to the onError callback in streaming methods and thrown as exceptions in non-streaming methods.

TypeScript Support

This SDK is written in TypeScript and provides type definitions for all exported interfaces and classes, ensuring type safety and improved developer experience.

Contributing

We welcome contributions to the Easybeam SDK for React. Please feel free to submit issues, fork the repository and send pull requests!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For any questions or support needs, please contact our support team at [email protected] or visit our documentation.