Skip to content

Conversation

@steven10a
Copy link
Collaborator

  • Updated passing of safety_identifier to only be passed to clients who support it
  • Changed id value to match package name
  • Added and updated tests

@steven10a steven10a requested review from Copilot and gabor-openai and removed request for Copilot October 31, 2025 18:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the safety identifier implementation to use a centralized utility module and conditionally include the parameter only for official OpenAI API clients. The safety identifier value is updated from 'oai-guardrails-ts' to 'openai-guardrails-js' for consistency.

  • Extracts safety identifier logic into a reusable utility module with client detection
  • Updates the safety identifier string to 'openai-guardrails-js' across all API calls
  • Adds conditional logic to exclude the parameter when using Azure OpenAI or third-party providers

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/utils/safety-identifier.ts New utility module providing the safety identifier constant and client support detection function
src/utils/index.ts Exports the new safety identifier utilities
src/resources/responses/responses.ts Refactors to use centralized safety identifier with conditional inclusion
src/resources/chat/chat.ts Refactors to use centralized safety identifier with conditional inclusion
src/checks/user-defined-llm.ts Refactors to use centralized safety identifier with conditional inclusion
src/checks/moderation.ts Refactors to use centralized safety identifier with conditional inclusion and improves error handling
src/checks/llm-base.ts Refactors to use centralized safety identifier with conditional inclusion
src/tests/unit/utils/safety-identifier.test.ts Comprehensive test coverage for the new safety identifier utilities
src/tests/unit/checks/user-defined-llm.test.ts Updates test expectations for new safety identifier value
src/tests/unit/checks/moderation-secret-keys.test.ts Updates test expectations for new safety identifier value
src/tests/unit/chat-resources.test.ts Updates test expectations for new safety identifier value

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* Azure OpenAI and local/alternative providers (Ollama, vLLM, etc.) do not.
*
* @param client The OpenAI client instance to check
* @returns True if safety_identifier should be included in API calls, False otherwise
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected capitalization of 'False' to 'false' for consistency with TypeScript boolean convention.

Suggested change
* @returns True if safety_identifier should be included in API calls, False otherwise
* @returns true if safety_identifier should be included in API calls, false otherwise

Copilot uses AI. Check for mistakes.
try {
resp = await callModerationAPI(client, data);
} catch (error) {

Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Empty line inside catch block should be removed to improve code cleanliness.

Suggested change

Copilot uses AI. Check for mistakes.
@gabor-openai gabor-openai changed the title Updating safety id usage Updating safety_identifier usage Oct 31, 2025
Copy link
Collaborator

@gabor-openai gabor-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM TY

@gabor-openai gabor-openai merged commit 24da084 into main Oct 31, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants