
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@plsr/blaze
Advanced tools
Note: right now this lib is only compatible with openai LLMs.
# bun
bun i openai @plsr/blaze
# npm
npm i openai @plsr/blaze
# yarn
yarn add openai @plsr/blaze
Translator.result()
null
fieldsindex.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);
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"
}
translator
.translate(
"Just sold 2 resistors and one capacitor to Jean Michel Frey, he's a really good guy!",
)
.then((x) => x.middleware((res) => console.log(res)))
.then((x) => x.addContext("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"
}
Bad example, just to demonstrate method usage.
translator
.addExample('Jean paul mars lives in Paris', {
isCompany: false,
firstName: "Jean-Paul",
lastName: "Mars",
address: "Paris"
})
.translate(
"Just sold 2 resistors and one capacitor to Jean Michel Frey, he's a really good guy!",
)
.then((x) => console.log(x.result));
{
"isCompany": false,
"firstName": "Jean Michel",
"lastName": "Frey",
"address": "Avenue Montaigne, Paris"
}
To enable javascript or typescript parsing, you can set translator.insecureParsing = true
.
Under the hood this will detect and eval
uate javascript or typescript to return JSON.
You could use this lib json-schema-to-typescript
to generate typings for your inputs.
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
**Note: right now this lib is only compatible with openai LLMs.**
We found that @plsr/blaze demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.