Skip to content

Commit e85dcde

Browse files
cosmiccrispPaige LeePaige Lee
authored
Fixing typing warnings and errors and enabling npm run lint (#17)
* fixing type issues * more updates to text only and docs * pass tests and enable lint * fix dedup * fix tests and eslint for tests * new type for pid * fix agent test --------- Co-authored-by: Paige Lee <[email protected]> Co-authored-by: Paige Lee <[email protected]>
1 parent dfc9ee0 commit e85dcde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1274
-943
lines changed

.eslintrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ module.exports = {
1111
sourceType: 'module',
1212
},
1313
rules: {
14-
'@typescript-eslint/no-unused-vars': 'warn',
14+
'no-unused-vars': 'off',
15+
'@typescript-eslint/no-unused-vars': ['warn', { 'varsIgnorePattern': '^_', 'argsIgnorePattern': '^_' }],
1516
'@typescript-eslint/explicit-function-return-type': 'off',
1617
'@typescript-eslint/explicit-module-boundary-types': 'off',
1718
'@typescript-eslint/no-explicit-any': 'warn',
19+
'no-redeclare': 'off',
20+
'@typescript-eslint/no-redeclare': 'off',
1821
},
1922
};

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,5 @@ jobs:
3030
- name: Run tests
3131
run: npm run test -- --run
3232

33-
# TODO: enable this once all checks are set
34-
# - name: Lint
35-
# run: npm run lint
33+
- name: Lint
34+
run: npm run lint

docs/agents_sdk_integration.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import { GuardrailAgent } from '@openai/guardrails';
2323
import { Runner } from '@openai/agents';
2424

2525
// Create agent with guardrails automatically configured
26-
const agent = new GuardrailAgent({
27-
config: {
26+
const agent = await GuardrailAgent.create(
27+
{
2828
version: 1,
2929
input: {
3030
version: 1,
@@ -39,9 +39,9 @@ const agent = new GuardrailAgent({
3939
]
4040
}
4141
},
42-
name: "Customer support agent",
43-
instructions: "You are a customer support agent. You help customers with their questions."
44-
});
42+
"Customer support agent",
43+
"You are a customer support agent. You help customers with their questions."
44+
);
4545

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

8080
```typescript
8181
// Object configuration (recommended)
82-
const agent = new GuardrailAgent({
83-
config: {
82+
const agent = await GuardrailAgent.create(
83+
{
8484
version: 1,
8585
input: { version: 1, guardrails: [...] },
8686
output: { version: 1, guardrails: [...] }
8787
},
88-
// ... other agent options
89-
});
90-
91-
// Dynamic configuration
92-
const configDict = {
93-
version: 1,
94-
input: { version: 1, guardrails: [...] },
95-
output: { version: 1, guardrails: [...] }
96-
};
97-
const agent = new GuardrailAgent({ config: configDict, ... });
88+
"Agent name",
89+
"Agent instructions"
90+
);
91+
92+
// File path configuration
93+
const agent = await GuardrailAgent.create(
94+
'./guardrails_config.json',
95+
"Agent name",
96+
"Agent instructions"
97+
);
98+
99+
// With additional agent options
100+
const agent = await GuardrailAgent.create(
101+
configDict,
102+
"Agent name",
103+
"Agent instructions",
104+
{ /* additional agent options */ }
105+
);
98106
```
99107

100108
## Next Steps

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
## How It Works
1515

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

docs/ref/checks/competitors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Flags mentions of competitors from a configurable list. Scans text for mentions
66

77
```json
88
{
9-
"name": "Competitor Detection",
9+
"name": "Competitors",
1010
"config": {
1111
"competitors": ["competitor1", "rival-company.com", "alternative-provider"]
1212
}

docs/ref/checks/llm_base.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ Base configuration for LLM-based guardrails. Provides common configuration optio
55
## Configuration
66

77
```json
8+
// This is a base configuration class, not a standalone guardrail
9+
// Use one of the LLM-based guardrails instead:
810
{
9-
"name": "LLM Base",
11+
"name": "NSFW Text", // or "Jailbreak", "Hallucination Detection", etc.
1012
"config": {
1113
"model": "gpt-5",
1214
"confidence_threshold": 0.7

docs/ref/types-typescript.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ export interface GuardrailResult {
3131
originalException?: Error;
3232
info: {
3333
checked_text: string;
34-
[key: string]: any;
34+
media_type?: string;
35+
detected_content_type?: string;
36+
stage_name?: string;
37+
guardrail_name?: string;
38+
[key: string]: unknown;
3539
};
3640
}
3741
```
@@ -41,7 +45,7 @@ Standard result returned by every guardrail check. The `executionFailed` field i
4145
## CheckFn
4246

4347
```typescript
44-
export type CheckFn<TContext = object, TIn = unknown, TCfg = object> =
48+
export type CheckFn<TContext = object, TIn = TextInput, TCfg = object> =
4549
(ctx: TContext, input: TIn, config: TCfg) => GuardrailResult | Promise<GuardrailResult>;
4650
```
4751

@@ -52,7 +56,7 @@ Callable signature implemented by all guardrails. May be sync or async.
5256
```typescript
5357
export type MaybeAwaitableResult = GuardrailResult | Promise<GuardrailResult>;
5458
export type TContext = object;
55-
export type TIn = unknown;
59+
export type TIn = TextInput;
5660
export type TCfg = object;
5761
```
5862

0 commit comments

Comments
 (0)