
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@guardrails-ai/core
Advanced tools
A Javascript wrapper for guardrails-ai.
This library contains limited support for using guardrails-ai in javascript.
The following methods and properties are supported:
llm_api)The key differences between this wrapper and the python library are as follows:
camelCase instead of snake_caseValidationOutcome.reask or guard.history.at(#).reask_prompts when defined)In addition to above, this library also supports the readonly properties on the ValidationOutcome class as well as readonly versions of the History & Logs related classes like Call, Iteration, etc..
See the JS docs here
npm i @guardrails-ai/core
import { Guard, Validators } from '@guardrails-ai/core';
const guard = await Guard.fromRail('./my-railspec.rail');
const messages = ['Hello World!', 'Goodbye World!'];
const response = await guard.parse(
'Hello World!',
{
promptParams: { 'messages': messages }
}
);
console.log(response);
The current version of the library uses a IO bridge so both javascript and python3 must be available in the environment.
For the best experience, you may also need to explicitly call for the bridge to exit at the end of the node process. We export an exit function to serve this purpose.
Below is a simple end-to-end test we use that demonstrates the concepts above:
import assert from 'node:assert';
import process from 'node:process';
import { Guard, Validators, exit } from '@guardrails-ai/core';
process.on('exit', (code) => {
console.log(`About to exit with code: ${code}`);
exit();
});
async function main () {
try {
const guard = await Guard.fromString(
[await Validators.ValidLength(1, 10, 'fix')],
{
description: 'A word.',
prompt: 'Generate a single word with a length betwen 1 and 10.'
}
);
const firstResponse = await guard.parse('Hello World!');
console.log("first response: ", JSON.stringify(firstResponse, null, 2));
assert.equal(firstResponse.validationPassed, true);
assert.equal(firstResponse.validatedOutput, 'Hello Worl');
assert.equal(guard.history.at(0).status, 'pass');
const secondResponse = await guard.parse('Hello World 2!');
console.log("second response: ", JSON.stringify(secondResponse, null, 2));
assert.equal(secondResponse.validationPassed, true);
assert.equal(secondResponse.validatedOutput, 'Hello Worl');
assert.equal(guard.history.at(1).status, 'pass');
process.exit(0);
} catch (error) {
console.error(error);
process.exit(1);
}
}
await main();
We run this with the following command:
node e2e.test.js
FAQs
A Javascript wrapper for guardrails-ai
The npm package @guardrails-ai/core receives a total of 8 weekly downloads. As such, @guardrails-ai/core popularity was classified as not popular.
We found that @guardrails-ai/core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.