This commit is contained in:
Your a
2023-12-04 14:43:39 +02:00
parent e4d34d4435
commit 5852006608
651 changed files with 84911 additions and 7169 deletions
+64 -46
View File
@@ -1,20 +1,24 @@
import { promises as fs } from 'fs';
const jsonContents = await fs.readFile("data/gpts.json", 'utf8');
const flow = JSON.parse(jsonContents).filter(data => !data.nsfw && data.categoryId!=1 && data.category.name!="Models" );
//files
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 = ``;
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}
# ${data.title} | [Start Chat](${url})
${data.description.replace(/\n/g, '\n\n')}
# Prompt
@@ -23,6 +27,9 @@ ${data.description.replace(/\n/g, '\n\n')}
${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')}
@@ -32,51 +39,62 @@ ${data.Conversation.messages.map(message => `**${message.role.toUpperCase()}**:
await fs.writeFile(`gpts/${data.uri}.md`, markdown);
}
//categories
const groups = groupBy(flow, "categoryId");
const groups = groupBy(flow, "categoryId", "subCategoryId");
let header = ``;
for (let groupId of Object.getOwnPropertyNames(groups)) {
let name = groups[groupId][0].category.name;
console.log(name);
// Append category links to readmeContent, renaming 'Others' to 'readme'
header += `- [${name}](./${name.replace(/\s+/g, '-')}.md)\n`;
}
await fs.writeFile(`README.md`, '+header);
for (let groupId of Object.getOwnPropertyNames(groups)) {
let name = groups[groupId][0].category.name;
let readmeContent = `${header}\n\n# ${name}\n\n`;
for (let item of groups[groupId]) {
let desc = item.description.replace(/[\r\n]+/g, ' ').trim().substring(0, 250);
readmeContent += `- [${item.title}](./gpts/${item.uri}.md) ${desc}\n`;
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;
tableOfContents += `* [${subCategoryName}](#${sanitizeFileName(subCategoryName)})\n`;
}
await fs.writeFile(`${name.replace(/\s+/g, '-')}.md`, readmeContent);
for (let subCategoryId in category) {
const subCategory = category[subCategoryId];
let categoryName = subCategory[0].category.name;
let subCategoryName = subCategory[0].subCategory.name;
}
function groupBy(array, key) {
return array.reduce((result, currentItem) => {
const groupKey = currentItem[key];
if (!result[groupKey]) {
result[groupKey] = [];
console.log(categoryName, subCategoryName);
header += `- [${categoryName}/${subCategoryName}](#${sanitizeFileName(categoryName)}-${sanitizeFileName(subCategoryName)})\n`;
tableOfContents += `## ${categoryName}/${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`;
}
result[groupKey].push(currentItem);
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;
}, {});
}