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

@nebuly-ai/nebuly-js-sdk

v0.1.16

Published

Nebuly-AI server side SDK for JavaScript

Downloads

1,228

Readme

Nebuly SDK for Node.js

This is the nebuly SDK for Node JS. Currently, the node JS is a preview features and only supports the integration with langchain-js and openai-node.

Installation

npm install @nebuly-ai/nebuly-js-sdk

Usage

Langchain-js

import { NebulyCallbackHandler } from '@nebuly-ai/nebuly-js-sdk';

let handler = new NebulyCallbackHandler('endUser', 'apiKey');
// Here add the handler to the call of your langchain chains or agents
handler.sendData();

The handler accepts as input parameters the endUser and nebuly's apiKey. If the apiKey is not given, the handler will use the default apiKey from the environment variable NEBULY_API_KEY. The endUser parameter should contain a unique identifier for the end-user. We usually suggest to use the hashed version of the username or email as unique identifier for the user.

OpenAI

import { NebulySdk } from "@nebuly-ai/nebuly-js-sdk"
import { OpenAI } from "openai";

const openai = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

async function main() {
    const nebulySdk = new NebulySdk('NEBULY_API_KEY');
    const modelInputs: OpenAI.Chat.ChatCompletionCreateParams = {
        messages: [{ role: 'user', content: 'Say this is a test' }],
        model: 'gpt-3.5-turbo',
    }
    const startTime = new Date();
    const chatCompletion = await openai.chat.completions.create(modelInputs);
    const endTime = new Date();
    
    nebulySdk.sendOpenAIInteraction(
        modelInputs['messages'],
        chatCompletion.choices[0].message.content as string,
        modelInputs['model'] as string,
        startTime,
        endTime,
        'testUser'
    );
}

main();

The parameters needed for the sendOpenAIInteraction are the following:

  • messages: The inputs that were given to the model
  • modelOutput: The output of the model
  • model: The model that was used
  • startTime: The start time of the call to the model
  • endTime: The end time of the call to the model
  • endUser: The unique identifier of the end user

Feedback actions

You can send to the nebuly platform feedbacks actions like: thumbs_up, thumbs_down, copy_input and copy_output. The feedback actions are sent to the nebuly platform using the sendFeedbackAction method.

nebulySdk.sendFeedbackAction(
    {
        slug: "thumbs_up",
        text: "Comment for a thumbs up"
    },
    {
        input: 'The input of the LLM system',
        output: 'The output of the LLM system',
        end_user: 'testUser'
    },
);

Development

To initialize the development environment you can use the following command:

tsc --init

To continuously compile the typescript code:

tsc -w

Generate Types and Endpoints

We currently use openapi-fetch and openapi-typescript to generate the types and endpoints. To generate the types and endpoints you can use the following command:

npx openapi-typescript https://backend.nebuly.com/api/external/openapi.json -o ./src/generated/schemas.d.ts

Then you can modify directly the endpoint and types in the src/endpoint_types.ts file.