forked from friuns2/BlackFriday-GPTs-Prompts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.mjs
100 lines (75 loc) · 3.35 KB
/
update.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { promises as fs } from 'fs';
const jsonContents = await fs.readFile("data/gpts.json", 'utf8');
const flow = JSON.parse(jsonContents)
.filter(data => data.categoryId != 1 && data.category.name != "Models" || data.subCategory.uri == "jailbreak")
.sort((a, b) => b.popularity - a.popularity);
let i =0;
for (let data of flow) {
continue;
if(data.subCategory.uri=="jailbreak" )
{
data.categoryId=666
data.category.name="Jailbreaks"
}
data.uri = data.uri.substring(0, 200);
let url = `https://gptcall.net/chat.html?data=${encodeURIComponent(JSON.stringify({"contact":{ "id": data.id, "flow": true}}))}`;
const markdown = `
[![${data.title}](${data.thumbnailURL})](${url})
# ${data.title} | [Start Chat](${url})
${data.description.replace(/\n/g, '\n\n')}
# Prompt
\`\`\`
${data.initPrompt}
\`\`\`
## Welcome Message
${data.welcomeMessage.replace(/\n/g, '\n\n')}
## Conversation
${data.Conversation.messages.map(message => `**${message.role.toUpperCase()}**: ${message.content.replace(/\n/g, '\n\n')}`).join('\n')}
`;
await fs.writeFile(`gpts/${data.uri}.md`, markdown);
}
const groups = groupBy(flow, "categoryId", "subCategoryId");
let header = ``;
for (let categoryId in groups) {
const category = groups[categoryId];
let tableOfContents = ``;
for (let subCategoryId in category)
{
const subCategory = category[subCategoryId];
if(tableOfContents=="") tableOfContents += `## ${subCategory[0].category.name} Prompts\n\n`;
let subCategoryName = subCategory[0].subCategory.name.slice(2).trim();
tableOfContents += `* [${subCategoryName}](#${subCategoryName.toLowerCase().replace(/\s+/g, '-')})\n`;
}
for (let subCategoryId in category) {
const subCategory = category[subCategoryId];
let categoryName = subCategory[0].category.name;
let subCategoryName = subCategory[0].subCategory.name.slice(2).trim();
console.log(categoryName, subCategoryName);
header += `- [${categoryName}/${subCategoryName}](#${sanitizeFileName(categoryName)}-${sanitizeFileName(subCategoryName)})\n`;
tableOfContents += `## ${subCategoryName}\n\n`;
for (let item of subCategory) {
if (item.title.includes("WormGPT") || item.title.includes("Neo DAN")) continue;
let desc = item.description.replace(/[\r\n]+/g, ' ').trim().substring(0, 250);
tableOfContents += `- [${item.title}](./gpts/${item.uri}.md) ${desc}\n`;
}
fs.writeFile(`${sanitizeFileName(categoryName)}.md`, tableOfContents);
}
}
function sanitizeFileName(input) {
return input.replace(/[\s\\\/:*?"<>|]+/g, '-');
}
//fs.writeFile(`README.md`, `# GPTs Prompts And Jailbreaks\n\n`+header);
function groupBy(array, groupKey1, groupKey2) {
return array.reduce((result, currentItem) => {
const groupKey1Value = currentItem[groupKey1];
const groupKey2Value = currentItem[groupKey2];
if (!result[groupKey1Value]) {
result[groupKey1Value] = {};
}
if (!result[groupKey1Value][groupKey2Value]) {
result[groupKey1Value][groupKey2Value] = [];
}
result[groupKey1Value][groupKey2Value].push(currentItem);
return result;
}, {});
}