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 SelfHarm = 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['hate'] || object['hate/threatening']) Hate = 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['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 = {
"Sexual": Sexual,
"Hate": Hate,
"Harassment": Harassment,
"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");
@ -86,8 +104,8 @@ module.exports = {
const messagesTokens = messagesTokenCounts.reduce((a, b) => a + b, 0) + 2;
let maxTokens;
if (model === 'gpt-3.5') maxTokens = 4097
else if (model === 'gpt-4') maxTokens = 8192
if (model === 'gpt-4') maxTokens = 4097;
else if (model === 'gpt-3.5') maxTokens = 8192;
return {
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');
});