feat(ai-moderation): add conflict instigation, offensive username, and discrimination moderation flags and prompt rules
This commit is contained in:
@@ -84,17 +84,19 @@ export async function llmChat(
|
|||||||
retries = DEFAULT_RETRIES,
|
retries = DEFAULT_RETRIES,
|
||||||
} = opts;
|
} = opts;
|
||||||
|
|
||||||
const params: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming = {
|
const params: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming =
|
||||||
model,
|
{
|
||||||
messages,
|
model,
|
||||||
temperature,
|
messages,
|
||||||
top_p,
|
temperature,
|
||||||
max_tokens,
|
top_p,
|
||||||
stream: false,
|
max_tokens,
|
||||||
};
|
stream: false,
|
||||||
|
};
|
||||||
|
|
||||||
if (jsonResponse) {
|
if (jsonResponse) {
|
||||||
(params as unknown as Record<string, unknown>).response_format = jsonResponse;
|
(params as unknown as Record<string, unknown>).response_format =
|
||||||
|
jsonResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retryWithBackoff(
|
return retryWithBackoff(
|
||||||
@@ -198,10 +200,15 @@ const VALID_PRIMARY_AI_FLAGS = new Set([
|
|||||||
"financial_scam",
|
"financial_scam",
|
||||||
"religious_insult",
|
"religious_insult",
|
||||||
"self_promo",
|
"self_promo",
|
||||||
|
"conflict_instigation",
|
||||||
|
"offensive_username",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function normalizeFlag(value: string): string | null {
|
function normalizeFlag(value: string): string | null {
|
||||||
const lower = value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
const lower = value
|
||||||
|
.trim()
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/[\s-]+/g, "_");
|
||||||
if (!lower) return null;
|
if (!lower) return null;
|
||||||
if (VALID_PRIMARY_AI_FLAGS.has(lower)) return lower;
|
if (VALID_PRIMARY_AI_FLAGS.has(lower)) return lower;
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user