Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ module.exports = {
sourceType: 'module',
},
rules: {
'@typescript-eslint/no-unused-vars': 'warn',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { 'varsIgnorePattern': '^_', 'argsIgnorePattern': '^_' }],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': 'off',
},
};
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ jobs:
- name: Run tests
run: npm run test -- --run

# TODO: enable this once all checks are set
# - name: Lint
# run: npm run lint
- name: Lint
run: npm run lint
42 changes: 25 additions & 17 deletions docs/agents_sdk_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { GuardrailAgent } from '@openai/guardrails';
import { Runner } from '@openai/agents';

// Create agent with guardrails automatically configured
const agent = new GuardrailAgent({
config: {
const agent = await GuardrailAgent.create(
{
version: 1,
input: {
version: 1,
Expand All @@ -39,9 +39,9 @@ const agent = new GuardrailAgent({
]
}
},
name: "Customer support agent",
instructions: "You are a customer support agent. You help customers with their questions."
});
"Customer support agent",
"You are a customer support agent. You help customers with their questions."
);

async function main() {
while (true) {
Expand Down Expand Up @@ -79,22 +79,30 @@ GuardrailAgent supports the same configuration formats as our other clients:

```typescript
// Object configuration (recommended)
const agent = new GuardrailAgent({
config: {
const agent = await GuardrailAgent.create(
{
version: 1,
input: { version: 1, guardrails: [...] },
output: { version: 1, guardrails: [...] }
},
// ... other agent options
});

// Dynamic configuration
const configDict = {
version: 1,
input: { version: 1, guardrails: [...] },
output: { version: 1, guardrails: [...] }
};
const agent = new GuardrailAgent({ config: configDict, ... });
"Agent name",
"Agent instructions"
);

// File path configuration
const agent = await GuardrailAgent.create(
'./guardrails_config.json',
"Agent name",
"Agent instructions"
);

// With additional agent options
const agent = await GuardrailAgent.create(
configDict,
"Agent name",
"Agent instructions",
{ /* additional agent options */ }
);
```

## Next Steps
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
## How It Works

1. **Configure**: Use the Wizard or define pipeline configurations
2. **Replace**: Use `GuardrailsAsyncOpenAI` instead of `AsyncOpenAI`
2. **Replace**: Use `GuardrailsOpenAI` instead of `OpenAI`
3. **Validate**: Guardrails run automatically on every API call
4. **Handle**: Access results via `response.guardrail_results`

Expand Down
2 changes: 1 addition & 1 deletion docs/ref/checks/competitors.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Flags mentions of competitors from a configurable list. Scans text for mentions

```json
{
"name": "Competitor Detection",
"name": "Competitors",
"config": {
"competitors": ["competitor1", "rival-company.com", "alternative-provider"]
}
Expand Down
4 changes: 3 additions & 1 deletion docs/ref/checks/llm_base.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ Base configuration for LLM-based guardrails. Provides common configuration optio
## Configuration

```json
// This is a base configuration class, not a standalone guardrail
// Use one of the LLM-based guardrails instead:
{
"name": "LLM Base",
"name": "NSFW Text", // or "Jailbreak", "Hallucination Detection", etc.
"config": {
"model": "gpt-5",
"confidence_threshold": 0.7
Expand Down
10 changes: 7 additions & 3 deletions docs/ref/types-typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export interface GuardrailResult {
originalException?: Error;
info: {
checked_text: string;
[key: string]: any;
media_type?: string;
detected_content_type?: string;
stage_name?: string;
guardrail_name?: string;
[key: string]: unknown;
};
}
```
Expand All @@ -41,7 +45,7 @@ Standard result returned by every guardrail check. The `executionFailed` field i
## CheckFn

```typescript
export type CheckFn<TContext = object, TIn = unknown, TCfg = object> =
export type CheckFn<TContext = object, TIn = TextInput, TCfg = object> =
(ctx: TContext, input: TIn, config: TCfg) => GuardrailResult | Promise<GuardrailResult>;
```

Expand All @@ -52,7 +56,7 @@ Callable signature implemented by all guardrails. May be sync or async.
```typescript
export type MaybeAwaitableResult = GuardrailResult | Promise<GuardrailResult>;
export type TContext = object;
export type TIn = unknown;
export type TIn = TextInput;
export type TCfg = object;
```

Expand Down
Loading