fix: broken open ai moderation (#1714)

This commit is contained in:
Daniel Salazar
2025-10-08 16:41:32 -07:00
committed by GitHub
parent e59f4e6c16
commit 3df1d31a37
2 changed files with 6 additions and 6 deletions
@@ -124,7 +124,7 @@ export class OpenAICompletionService {
* @property {boolean} flagged - Whether the content was flagged as inappropriate
* @property {Object} results - Raw moderation results from OpenAI API
*/
async #checkModeration(text) {
async checkModeration(text) {
// create moderation
const results = await this.#openAi.moderations.create({
input: text,
@@ -145,10 +145,6 @@ export class OpenAICompletionService {
};
}
async check_moderation(text) {
return await this.#checkModeration(text);
}
/**
* Completes a chat conversation using OpenAI's API
* @param {Array} messages - Array of message objects or strings representing the conversation
@@ -281,7 +277,7 @@ export class OpenAICompletionService {
},
stream,
completion,
moderate: moderation && this.#checkModeration.bind(this),
moderate: moderation && this.checkModeration.bind(this),
});
}
}
@@ -36,6 +36,10 @@ export class OpenAICompletionServiceWrapper extends BaseService {
});
}
async check_moderation(text) {
return await this.openAICompletionService.checkModeration(text);
}
static IMPLEMENTS = {
['puter-chat-completion']: Object.getOwnPropertyNames(OpenAICompletionService.prototype)
.filter(n => n !== 'constructor')