-
Notifications
You must be signed in to change notification settings - Fork 6
Updating safety_identifier usage #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
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.
| * @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 |
| try { | ||
| resp = await callModerationAPI(client, data); | ||
| } catch (error) { | ||
|
|
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
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.
gabor-openai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM TY
safety_identifierto only be passed to clients who support it