Skip to content

Commit 8527a84

Browse files
authored
Add Guardrails safety identifier header to LLM calls (#15)
* add safety header to LLM calls * Update tests with safety_identifier
1 parent d75cfb3 commit 8527a84

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/__tests__/unit/chat-resources.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ describe('Chat resource', () => {
9494
messages,
9595
model: 'gpt-4',
9696
stream: false,
97+
safety_identifier: 'oai-guardrails-ts',
9798
});
9899
expect(client.handleLlmResponse).toHaveBeenCalledWith(
99100
{ id: 'chat-response' },
@@ -153,6 +154,7 @@ describe('Responses resource', () => {
153154
model: 'gpt-4o',
154155
stream: false,
155156
tools: undefined,
157+
safety_identifier: 'oai-guardrails-ts',
156158
});
157159
expect(client.handleLlmResponse).toHaveBeenCalledWith(
158160
{ id: 'responses-api' },

src/resources/chat/chat.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ export class ChatCompletions {
8989
model,
9090
stream,
9191
...kwargs,
92+
// @ts-ignore - safety_identifier is not defined in OpenAI types yet
93+
safety_identifier: 'oai-guardrails-ts',
9294
}),
9395
]);
9496

src/resources/responses/responses.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export class Responses {
8585
stream,
8686
tools,
8787
...kwargs,
88+
// @ts-ignore - safety_identifier is not defined in OpenAI types yet
89+
safety_identifier: 'oai-guardrails-ts',
8890
}),
8991
]);
9092

0 commit comments

Comments
 (0)