🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@plsr/blaze

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@plsr/blaze

**Note: right now this lib is only compatible with openai LLMs.**

Source
npmnpm
Version
0.0.1-beta2
Version published
Maintainers
1
Created
Source

@plsr/blaze

Note: right now this lib is only compatible with openai LLMs.

To install the lib externally (Not available yet!)

# bun
bun i openai @plsr/blaze

# npm
npm i openai @plsr/blaze

# yarn
yarn add openai @plsr/blaze

Examples

Example setup

index.mjs:

import OpenAI from "openai";
import { Translator } from "@plsr/blaze";

const openai = new OpenAI(); // Requires api key in environment
const schema = {
    $schema: "http://json-schema.org/draft-07/schema#",
    title: "Client",
    description: "Schema representing a client.",
    type: "object",
    properties: {
        isCompany: {
            default: false,
            type: "boolean",
            description: "true if the client is a company.",
        },
        firstName: {
            type: "string",
            description: "First name of the client.",
        },
        lastName: {
            type: "string",
            description: "Last name of the client.",
        },
        companyName: {
            type: "string",
            description: "Name of the company.",
        },
        address: {
            type: "string",
            description: "Client's address.",
        },
        email: {
            type: "string",
            format: "email",
            description: "Client's email address.",
        },
        phone: {
            type: "string",
            description: "Client's telephone number.",
        },
    },
};

const translator = new Translator(openai, schema);

Basic example:

translator
    .translate(
        "Just sold 2 resistors and one capacitor to Jean Michel Frey, he's a really good guy! He lives just next to my house in the Avenue Montaigne in Paris",
    )
    .then((x) => console.log(x.result));
{
    "isCompany": false,
    "firstName": "Jean Michel",
    "lastName": "Frey",
    "address": "Avenue Montaigne, Paris"
}

Completion example:

translator
    .translate(
        "Just sold 2 resistors and one capacitor to Jean Michel Frey, he's a really good guy!",
    )
    .then((x) => x.processResult((res) => console.log(res)))
    .then((x) => x.complete("He lives just next to my house in the Avenue Montaigne in Paris"))
    .then((x) => console.log(x.result));

First log

{
    "isCompany": false,
    "firstName": "Jean Michel",
    "lastName": "Frey"
}

Second log

{
    "isCompany": false,
    "firstName": "Jean Michel",
    "lastName": "Frey",
    "address": "Avenue Montaigne, Paris"
}

Ideas

You could use this lib json-schema-to-typescript to generate typings for your inputs.

Dev

To install dependencies:

bun install

To run:

bun run index.ts

This project was created using bun init in bun v1.0.3. Bun is a fast all-in-one JavaScript runtime.

FAQs

Package last updated on 02 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts