Added new flags

This commit is contained in:
ShadowVR 2024-06-10 01:51:01 -04:00
parent 4c57a66a97
commit 9269aff7a6

View file

@ -32,19 +32,37 @@ module.exports = {
let Harassment = false; let Harassment = false;
let SelfHarm = false; let SelfHarm = false;
let Violence = false; let Violence = false;
let Ignorance = false;
let Homophobia = false;
let Transphobic = false;
let Disrespect = false;
let Politics = false;
let Slurs = false;
if (object['sexual'] || object['sexual/minors']) Sexual = true; if (object['sexual'] || object['sexual/minors']) Sexual = true;
if (object['hate'] || object['hate/threatening']) Hate = true; if (object['hate'] || object['hate/threatening']) Hate = true;
if (object['harassment'] || object['harassment/threatening']) Harassment = true; if (object['harassment'] || object['harassment/threatening']) Harassment = true;
if (object['self-harm'] || object['self-harm/intent'] || object['self-harm/instructions']) SelfHarm = true; if (object['self-harm'] || object['self-harm/intent'] || object['self-harm/instructions']) SelfHarm = true;
if (object['violence'] || object['violence/graphic']) Violence = true; if (object['violence'] || object['violence/graphic']) Violence = true;
if (object['ignorance']) Ignorance = true;
if (object['homophobia']) Homophobia = true;
if (object['transphobic']) Transphobic = true;
if (object['disrespect']) Disrespect = true;
if (object['politics']) Politics = true;
if (object['slurs']) Slurs = true;
const flags = { const flags = {
"Sexual": Sexual, "Sexual": Sexual,
"Hate": Hate, "Hate": Hate,
"Harassment": Harassment, "Harassment": Harassment,
"Self-Harm": SelfHarm, "Self-Harm": SelfHarm,
"Violence": Violence "Violence": Violence,
"Ignorance": Ignorance,
"Homophobia": Homophobia,
"Transphobic": Transphobic,
"Disrespect": Disrespect,
"Politics": Politics,
"Slurs": Slurs
}; };
const allFlags = Object.keys(flags).map(key => flags[key] ? `${key}: ✅` : `${key}: ❌`).join("\n"); const allFlags = Object.keys(flags).map(key => flags[key] ? `${key}: ✅` : `${key}: ❌`).join("\n");
@ -86,8 +104,8 @@ module.exports = {
const messagesTokens = messagesTokenCounts.reduce((a, b) => a + b, 0) + 2; const messagesTokens = messagesTokenCounts.reduce((a, b) => a + b, 0) + 2;
let maxTokens; let maxTokens;
if (model === 'gpt-3.5') maxTokens = 4097 if (model === 'gpt-4') maxTokens = 4097;
else if (model === 'gpt-4') maxTokens = 8192 else if (model === 'gpt-3.5') maxTokens = 8192;
return { return {
tokens: messagesTokens, tokens: messagesTokens,
@ -114,4 +132,28 @@ module.exports = {
}, },
}; };
// Test the flagCheck function
const testCases = [
{ "sexual": true },
{ "hate": true },
{ "harassment": true },
{ "self-harm": true },
{ "violence": true },
{ "ignorance": true },
{ "homophobia": true },
{ "transphobic": true },
{ "disrespect": true },
{ "politics": true },
{ "slurs": true },
];
// Run test cases
testCases.forEach(testCase => {
const result = module.exports.flagCheck(testCase);
console.log(`Testing: ${JSON.stringify(testCase)}`);
console.log(result.allFlags);
console.log(result.trueFlags);
console.log('\n');
});