Skip to content

Commit 20cdc2f

Browse files
committed
update integration test, update docs
1 parent d45499d commit 20cdc2f

26 files changed

+305
-321
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
dist
3-
*.tgz
3+
*.tgz
4+
coverage

README.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ console.log(response);
4646
## Caveats and Oddities
4747
The current version of the library uses a IO bridge so both javascript and python3 must be available in the environment.
4848

49-
The bridge implementation we use doesn't always work well with multi-processing. For this reason it is best to set the `GUARDRAILS_PROCESS_COUNT` environment variable to `1` when starting the node process:
50-
```sh
51-
GUARDRAILS_PROCESS_COUNT="1" node ./my-script-or-app.js
52-
```
53-
5449
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.
5550

5651

@@ -99,5 +94,5 @@ await main();
9994

10095
We run this with the following command:
10196
```sh
102-
GUARDRAILS_PROCESS_COUNT="1" node e2e.test.js
97+
node e2e.test.js
10398
```

docs/README.md

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
guardrails-ai / [Exports](modules.md)
1+
@guardrails-ai/core / [Exports](modules.md)
22

33
# guardrails-js
44
A Javascript wrapper for guardrails-ai.
@@ -18,18 +18,18 @@ The key differences between this wrapper and the python library are as follows:
1818
1. No support for re-asking (though you can perform reasks yourself outside of the library using `ValidationOutcome.reask` or `guard.history.at(#).reask_prompts` when defined)
1919
1. LLM calls must be made by the user and the text response passed into parse
2020

21-
In addition to above, this library also supports the readonly properties on the [ValidationOutcome class](https://www.guardrailsai.com/docs/api_reference_markdown/validation_outcome) as well as readonly versions of the History & Logs related classes like [Call](https://www.guardrailsai.com/docs/api_reference_markdown/history_and_logs#call-objects), [Iteration](https://www.guardrailsai.com/docs/api_reference_markdown/history_and_logs#iteration-objects), etc..
21+
In addition to above, this library also supports the readonly properties on the [ValidationOutcome class](https://www.guardrailsai.com/docs/hub/api_reference_markdown/validation_outcome) as well as readonly versions of the History & Logs related classes like [Call](https://www.guardrailsai.com/docs/api_reference_markdown/history_and_logs#call-objects), [Iteration](https://www.guardrailsai.com/docs/api_reference_markdown/history_and_logs#iteration-objects), etc..
2222

2323
See the JS docs [here](/docs/modules.md)
2424

2525
## Installation
2626
```sh
27-
npm i git+https://github.com/guardrails-ai/guardrails-js.git
27+
npm i @guardrails-ai/core
2828
```
2929

3030
## Example
3131
```js
32-
import { Guard, Validators } from 'guardrails-ai';
32+
import { Guard, Validators } from '@guardrails-ai/core';
3333

3434
const guard = await Guard.fromRail('./my-railspec.rail');
3535

@@ -48,19 +48,14 @@ console.log(response);
4848
## Caveats and Oddities
4949
The current version of the library uses a IO bridge so both javascript and python3 must be available in the environment.
5050

51-
The bridge implementation we use doesn't always work well with multi-processing. For this reason it is best to set the `GUARDRAILS_PROCESS_COUNT` environment variable to `1` when starting the node process:
52-
```sh
53-
GUARDRAILS_PROCESS_COUNT="1" node ./my-script-or-app.js
54-
```
55-
5651
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.
5752

5853
Below is a simple end-to-end test we use that demonstrates the concepts above:
5954

6055
```js
6156
import assert from 'node:assert';
6257
import process from 'node:process';
63-
import { Guard, Validators, exit } from './dist/index.js';
58+
import { Guard, Validators, exit } from '@guardrails-ai/core';
6459

6560
process.on('exit', (code) => {
6661
console.log(`About to exit with code: ${code}`);
@@ -100,5 +95,5 @@ await main();
10095

10196
We run this with the following command:
10297
```sh
103-
GUARDRAILS_PROCESS_COUNT="1" node e2e.test.js
98+
node e2e.test.js
10499
```

docs/classes/Guard.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[guardrails-ai](../README.md) / [Exports](../modules.md) / Guard
1+
[@guardrails-ai/core](../README.md) / [Exports](../modules.md) / Guard
22

33
# Class: Guard\<T\>
44

@@ -56,7 +56,7 @@
5656

5757
#### Defined in
5858

59-
[src/guard.ts:16](https://github.com/guardrails-ai/guardrails-js/blob/d37ad09/src/guard.ts#L16)
59+
[src/guard.ts:16](https://github.com/guardrails-ai/guardrails-js/blob/d45499d/src/guard.ts#L16)
6060

6161
## Properties
6262

@@ -66,7 +66,7 @@
6666

6767
#### Defined in
6868

69-
[src/guard.ts:14](https://github.com/guardrails-ai/guardrails-js/blob/d37ad09/src/guard.ts#L14)
69+
[src/guard.ts:14](https://github.com/guardrails-ai/guardrails-js/blob/d45499d/src/guard.ts#L14)
7070

7171
___
7272

@@ -76,7 +76,7 @@ ___
7676

7777
#### Defined in
7878

79-
[src/guard.ts:13](https://github.com/guardrails-ai/guardrails-js/blob/d37ad09/src/guard.ts#L13)
79+
[src/guard.ts:13](https://github.com/guardrails-ai/guardrails-js/blob/d45499d/src/guard.ts#L13)
8080

8181
## Accessors
8282

@@ -90,7 +90,7 @@ ___
9090

9191
#### Defined in
9292

93-
[src/guard.ts:117](https://github.com/guardrails-ai/guardrails-js/blob/d37ad09/src/guard.ts#L117)
93+
[src/guard.ts:117](https://github.com/guardrails-ai/guardrails-js/blob/d45499d/src/guard.ts#L117)
9494

9595
## Methods
9696

@@ -104,7 +104,7 @@ ___
104104

105105
#### Defined in
106106

107-
[src/guard.ts:110](https://github.com/guardrails-ai/guardrails-js/blob/d37ad09/src/guard.ts#L110)
107+
[src/guard.ts:110](https://github.com/guardrails-ai/guardrails-js/blob/d45499d/src/guard.ts#L110)
108108

109109
___
110110

@@ -118,7 +118,7 @@ ___
118118

119119
#### Defined in
120120

121-
[src/guard.ts:105](https://github.com/guardrails-ai/guardrails-js/blob/d37ad09/src/guard.ts#L105)
121+
[src/guard.ts:105](https://github.com/guardrails-ai/guardrails-js/blob/d45499d/src/guard.ts#L105)
122122

123123
___
124124

@@ -139,7 +139,7 @@ ___
139139

140140
#### Defined in
141141

142-
[src/guard.ts:69](https://github.com/guardrails-ai/guardrails-js/blob/d37ad09/src/guard.ts#L69)
142+
[src/guard.ts:69](https://github.com/guardrails-ai/guardrails-js/blob/d45499d/src/guard.ts#L69)
143143

144144
___
145145

@@ -160,7 +160,7 @@ ___
160160

161161
#### Defined in
162162

163-
[src/guard.ts:21](https://github.com/guardrails-ai/guardrails-js/blob/d37ad09/src/guard.ts#L21)
163+
[src/guard.ts:21](https://github.com/guardrails-ai/guardrails-js/blob/d45499d/src/guard.ts#L21)
164164

165165
___
166166

@@ -181,7 +181,7 @@ ___
181181

182182
#### Defined in
183183

184-
[src/guard.ts:33](https://github.com/guardrails-ai/guardrails-js/blob/d37ad09/src/guard.ts#L33)
184+
[src/guard.ts:33](https://github.com/guardrails-ai/guardrails-js/blob/d45499d/src/guard.ts#L33)
185185

186186
___
187187

@@ -202,4 +202,4 @@ ___
202202

203203
#### Defined in
204204

205-
[src/guard.ts:47](https://github.com/guardrails-ai/guardrails-js/blob/d37ad09/src/guard.ts#L47)
205+
[src/guard.ts:47](https://github.com/guardrails-ai/guardrails-js/blob/d45499d/src/guard.ts#L47)

0 commit comments

Comments
 (0)