mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 00:20:45 +00:00
fix: broken open ai moderation (#1714)
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user