Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
private openAIApiKey = ''
private moderationErrorMessage: string = "Text was found that violates OpenAI's content policy."

constructor(openAIApiKey: string) {
this.openAIApiKey = openAIApiKey
constructor(openAIApiKey: any) {
// Handle case where openAIApiKey might be passed as an object instead of a string
if (typeof openAIApiKey === 'object' && openAIApiKey !== null) {
// If it's an object, try to extract the key from common property names
const potentialKey = openAIApiKey.openAIApiKey || openAIApiKey.apiKey || openAIApiKey.key;

Check failure on line 12 in packages/components/nodes/moderation/OpenAIModeration/OpenAIModerationRunner.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Delete `;`
this.openAIApiKey = typeof potentialKey === 'string' ? potentialKey : '';

Check failure on line 13 in packages/components/nodes/moderation/OpenAIModeration/OpenAIModerationRunner.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Delete `;`
} else {
this.openAIApiKey = openAIApiKey || ''
}
}

async checkForViolations(input: string): Promise<string> {
Expand Down
Loading