Upload 6 files
Browse files- .gitattributes +2 -0
- bluemoon_roleplay_300k_vicuna/RawData/raw.json +3 -0
- bluemoon_roleplay_300k_vicuna/bluemoon_roleplay_300k_vicuna.json +3 -0
- bluemoon_roleplay_300k_vicuna/clean_bluemoon.py +39 -0
- bluemoon_roleplay_300k_vicuna/convert-to-vicuna.js +67 -0
- bluemoon_roleplay_300k_vicuna/merge_json.js +36 -0
- bluemoon_roleplay_300k_vicuna/parsejson.js +196 -0
.gitattributes
CHANGED
|
@@ -70,3 +70,5 @@ ShareGPT_Vicuna_unfiltered/Experimental/removals.log filter=lfs diff=lfs merge=l
|
|
| 70 |
ShareGPT_Vicuna_unfiltered/Experimental/ShareGPT_2023.05.04v_NoUnicode_Edition.json filter=lfs diff=lfs merge=lfs -text
|
| 71 |
ShareGPT_Vicuna_unfiltered/Experimental/ShareGPT_2023.05.04v1_Nano_Wasteland.json filter=lfs diff=lfs merge=lfs -text
|
| 72 |
ShareGPT_Vicuna_unfiltered/ShareGPT_2023.05.08v0_Wasteland_Edition.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 70 |
ShareGPT_Vicuna_unfiltered/Experimental/ShareGPT_2023.05.04v_NoUnicode_Edition.json filter=lfs diff=lfs merge=lfs -text
|
| 71 |
ShareGPT_Vicuna_unfiltered/Experimental/ShareGPT_2023.05.04v1_Nano_Wasteland.json filter=lfs diff=lfs merge=lfs -text
|
| 72 |
ShareGPT_Vicuna_unfiltered/ShareGPT_2023.05.08v0_Wasteland_Edition.json filter=lfs diff=lfs merge=lfs -text
|
| 73 |
+
bluemoon_roleplay_300k_vicuna/bluemoon_roleplay_300k_vicuna.json filter=lfs diff=lfs merge=lfs -text
|
| 74 |
+
bluemoon_roleplay_300k_vicuna/RawData/raw.json filter=lfs diff=lfs merge=lfs -text
|
bluemoon_roleplay_300k_vicuna/RawData/raw.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d2ac077369e37f394b2158c9a100371c729811e7966a18c068cb04e7c2e45159
|
| 3 |
+
size 301734369
|
bluemoon_roleplay_300k_vicuna/bluemoon_roleplay_300k_vicuna.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a6c734071377d534373e0b2abe859de6c21e85116baa58f2bdb36fc52c3308b1
|
| 3 |
+
size 241049697
|
bluemoon_roleplay_300k_vicuna/clean_bluemoon.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import re
|
| 3 |
+
|
| 4 |
+
fname = "bluemoon_roleplay_300k_vicuna.json";
|
| 5 |
+
with open(fname,"r") as f:
|
| 6 |
+
d = json.load(f);
|
| 7 |
+
|
| 8 |
+
mr = re.compile(r'(((OOC|OCC|ooc|occ|Occ|Ooc|OoC))|(OFF)):.*?((([ \.!?](IC|DE|BIC|ic|bic)[:\. ])|((BiC[:]?)|[\.!?](on:|ON:|On:)))|$)');
|
| 9 |
+
|
| 10 |
+
#remaining implicit OOC'ing
|
| 11 |
+
manual = [
|
| 12 |
+
"OOC: Sorry for the redonculous wait. Work takes priority ",
|
| 13 |
+
"OOC: I hope you don't mind that I put a time skip in here",
|
| 14 |
+
"OOC: Give her broken english.",
|
| 15 |
+
"OoC: aww, and here I'd been hoping that something would be done with the soul edge fragments",
|
| 16 |
+
"OOC:Oh sure. It's ok ",
|
| 17 |
+
"OOC: Sorry for being gone so long...I hope you will continue rping with me",
|
| 18 |
+
];
|
| 19 |
+
|
| 20 |
+
for conv in d:
|
| 21 |
+
for m in conv["conversations"]:
|
| 22 |
+
l = mr.search(m["value"]);
|
| 23 |
+
if l != None:
|
| 24 |
+
print(m["value"]);
|
| 25 |
+
s = mr.sub("",m["value"]);
|
| 26 |
+
if len(s) > 0:
|
| 27 |
+
print("--->",s,end="\n\n");
|
| 28 |
+
m["value"] = s;
|
| 29 |
+
else:
|
| 30 |
+
print("---> MANUAL INTERVENTION REQUIRED. CHECK KEYWORDS.");
|
| 31 |
+
|
| 32 |
+
s = m["value"];
|
| 33 |
+
for e in manual:
|
| 34 |
+
s = re.sub(e,"",s);
|
| 35 |
+
m["value"] = s;
|
| 36 |
+
|
| 37 |
+
fname = "bluemoon_roleplay_300k_vicuna_filtered.json";
|
| 38 |
+
with open(fname,"w") as f:
|
| 39 |
+
json.dump(d,f,indent=2);
|
bluemoon_roleplay_300k_vicuna/convert-to-vicuna.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs = require("fs");
|
| 2 |
+
const data = JSON.parse(fs.readFileSync('two-chatter-only.json', 'utf8'));
|
| 3 |
+
let destArray = [];
|
| 4 |
+
|
| 5 |
+
// Group the contents by thread_href
|
| 6 |
+
const groupBy = (array, key) =>
|
| 7 |
+
{
|
| 8 |
+
return array.reduce((result, item) =>
|
| 9 |
+
{
|
| 10 |
+
(result[item[key]] = result[item[key]] || []).push(item);
|
| 11 |
+
return result;
|
| 12 |
+
}, {});
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
const grouped = groupBy(data, 'thread_href');
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
// Loop through each group and change the message_username field
|
| 19 |
+
for (let thread in grouped)
|
| 20 |
+
{
|
| 21 |
+
let messages = grouped[thread];
|
| 22 |
+
let destObj = {};
|
| 23 |
+
destObj.id = generateId();
|
| 24 |
+
destObj.conversations = [];
|
| 25 |
+
|
| 26 |
+
for (let i = 0; i < messages.length; i++)
|
| 27 |
+
{
|
| 28 |
+
let message = messages[i];
|
| 29 |
+
let conversation = {};
|
| 30 |
+
//console.log("Adding: " + message.message);
|
| 31 |
+
if (i % 2 == 0)
|
| 32 |
+
{
|
| 33 |
+
conversation.from = "human";
|
| 34 |
+
}
|
| 35 |
+
else
|
| 36 |
+
{
|
| 37 |
+
conversation.from = "gpt";
|
| 38 |
+
}
|
| 39 |
+
conversation.value = message.message;
|
| 40 |
+
|
| 41 |
+
destObj.conversations.push(conversation);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
destArray.push(destObj);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
fs.writeFileSync("vicuna-output.json", JSON.stringify(destArray, null, 2), "utf8");
|
| 49 |
+
|
| 50 |
+
// This is just a best guess at ID formats based on the ShareGPT format
|
| 51 |
+
function generateId()
|
| 52 |
+
{
|
| 53 |
+
let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
| 54 |
+
|
| 55 |
+
let id = "";
|
| 56 |
+
for (let i = 0; i < 6; i++)
|
| 57 |
+
{
|
| 58 |
+
// Get a random index from the possible characters
|
| 59 |
+
let index = Math.floor(Math.random() * 62);
|
| 60 |
+
// Append the character at that index to the id string
|
| 61 |
+
id += chars[index];
|
| 62 |
+
}
|
| 63 |
+
//Append a random _XX to the id.
|
| 64 |
+
id += "_" + Math.floor(Math.random() * 100);
|
| 65 |
+
|
| 66 |
+
return id;
|
| 67 |
+
}
|
bluemoon_roleplay_300k_vicuna/merge_json.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs = require('fs');
|
| 2 |
+
|
| 3 |
+
function loadAndConcatJSON(files, callback)
|
| 4 |
+
{
|
| 5 |
+
let data = [];
|
| 6 |
+
for (let file of files)
|
| 7 |
+
{
|
| 8 |
+
data.push(require(file));
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
let output = [].concat(...data);
|
| 12 |
+
output = JSON.stringify(output);
|
| 13 |
+
|
| 14 |
+
fs.writeFile('output.json', output, err =>
|
| 15 |
+
{
|
| 16 |
+
if (err)
|
| 17 |
+
{
|
| 18 |
+
callback(err);
|
| 19 |
+
} else
|
| 20 |
+
{
|
| 21 |
+
callback(null, output);
|
| 22 |
+
}
|
| 23 |
+
});
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
loadAndConcatJSON(['./filtered-vicuna-formatted.json', './filtered.json'], (err, result) => {
|
| 28 |
+
if (err)
|
| 29 |
+
{
|
| 30 |
+
console.error(err);
|
| 31 |
+
}
|
| 32 |
+
else
|
| 33 |
+
{
|
| 34 |
+
console.log("Mer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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Load the fs module to read files
|
| 2 |
+
const fs = require('fs');
|
| 3 |
+
// Define the path to the json file
|
| 4 |
+
const filePath = 'bluemoon_roleplay_300k_vicuna.json';
|
| 5 |
+
const csvPath = 'data/rawData.csv';
|
| 6 |
+
|
| 7 |
+
cleanLineEndings();
|
| 8 |
+
validate();
|
| 9 |
+
|
| 10 |
+
function cleanLineEndings()
|
| 11 |
+
{
|
| 12 |
+
fs.readFile(filePath, 'utf8', (err, data) =>
|
| 13 |
+
{
|
| 14 |
+
const json = JSON.parse(data);
|
| 15 |
+
for (const entry of json)
|
| 16 |
+
{
|
| 17 |
+
for (const conversation of entry["conversations"])
|
| 18 |
+
{
|
| 19 |
+
conversation["value"] = conversation["value"].replace("\"\r", "");
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
const output = JSON.stringify(json, null, 2);
|
| 24 |
+
fs.writeFile('./cleanedup.json', output, 'utf8', (err) =>
|
| 25 |
+
{
|
| 26 |
+
});
|
| 27 |
+
});
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
function convertToJson()
|
| 31 |
+
{
|
| 32 |
+
fs.readFile(csvPath, "utf-8", (err, data) =>
|
| 33 |
+
{
|
| 34 |
+
if (err)
|
| 35 |
+
{
|
| 36 |
+
console.error(err);
|
| 37 |
+
return;
|
| 38 |
+
}
|
| 39 |
+
// Use the csvToJson function to convert the data to json
|
| 40 |
+
const json = csvToJson(data);
|
| 41 |
+
fs.writeFile("data/rawData.json", json, (err) =>
|
| 42 |
+
{
|
| 43 |
+
if (err)
|
| 44 |
+
{
|
| 45 |
+
console.error(err);
|
| 46 |
+
return;
|
| 47 |
+
}
|
| 48 |
+
console.log("File saved successfully");
|
| 49 |
+
});
|
| 50 |
+
|
| 51 |
+
// Do something with the json
|
| 52 |
+
});
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
//Read the file asynchronously and parse it as json
|
| 56 |
+
function validate()
|
| 57 |
+
{
|
| 58 |
+
fs.readFile(filePath, 'utf8', (err, data) =>
|
| 59 |
+
{
|
| 60 |
+
if (err)
|
| 61 |
+
{
|
| 62 |
+
console.error(err);
|
| 63 |
+
return;
|
| 64 |
+
}
|
| 65 |
+
const json = JSON.parse(data);
|
| 66 |
+
|
| 67 |
+
// Create an empty object to store the results
|
| 68 |
+
const result = {};
|
| 69 |
+
|
| 70 |
+
// Loop through each entry in the json array
|
| 71 |
+
for (const entry of json)
|
| 72 |
+
{
|
| 73 |
+
// Get the url and message_username fields from the entry
|
| 74 |
+
const url = entry.thread_href;
|
| 75 |
+
const message_username = entry.message_username;
|
| 76 |
+
|
| 77 |
+
// If the url is not already in the result object, create an empty set for it
|
| 78 |
+
if (!result[url])
|
| 79 |
+
{
|
| 80 |
+
result[url] = new Set();
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
// Add the message_username to the set for the url
|
| 84 |
+
result[url].add(message_username);
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
// Loop through each url in the result object and get the size of the set
|
| 88 |
+
let foundThreads = 0;
|
| 89 |
+
for (const url in result)
|
| 90 |
+
{
|
| 91 |
+
// Get the set of message_usernames for the url
|
| 92 |
+
const usernames = result[url];
|
| 93 |
+
|
| 94 |
+
// Get the count of unique message_usernames by getting the size of the set
|
| 95 |
+
const count = usernames.size;
|
| 96 |
+
|
| 97 |
+
// Print the url and the count
|
| 98 |
+
if (count > 2)
|
| 99 |
+
{
|
| 100 |
+
foundThreads++;
|
| 101 |
+
console.log(`${url}: ${count} `);
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
console.log("Threads non-two chatters: " + foundThreads);
|
| 105 |
+
});
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
function removedNonTwoConvos()
|
| 109 |
+
{
|
| 110 |
+
let removedCount = 0;
|
| 111 |
+
fs.readFile(filePath, 'utf8', (err, data) =>
|
| 112 |
+
{
|
| 113 |
+
if (err)
|
| 114 |
+
{
|
| 115 |
+
console.error(err);
|
| 116 |
+
return;
|
| 117 |
+
}
|
| 118 |
+
const obj = JSON.parse(data);
|
| 119 |
+
|
| 120 |
+
// Group the entries by thread_href using a Map
|
| 121 |
+
const map = new Map();
|
| 122 |
+
for (const entry of obj)
|
| 123 |
+
{
|
| 124 |
+
const key = entry.thread_href;
|
| 125 |
+
const value = map.get(key) || [];
|
| 126 |
+
value.push(entry);
|
| 127 |
+
map.set(key, value);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
// Filter out the threads with more than two different message_username entries
|
| 131 |
+
const result = [];
|
| 132 |
+
for (const [key, value] of map)
|
| 133 |
+
{
|
| 134 |
+
const usernames = new Set();
|
| 135 |
+
for (const entry of value)
|
| 136 |
+
{
|
| 137 |
+
usernames.add(entry.message_username);
|
| 138 |
+
}
|
| 139 |
+
if (usernames.size == 2)
|
| 140 |
+
{
|
| 141 |
+
result.push(...value);
|
| 142 |
+
}
|
| 143 |
+
else
|
| 144 |
+
{
|
| 145 |
+
removedCount++;
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
// Stringify the result and write it to a new file
|
| 150 |
+
const output = JSON.stringify(result, null, 2);
|
| 151 |
+
fs.writeFile('./two-chatter-only.json', output, 'utf8', (err) =>
|
| 152 |
+
{
|
| 153 |
+
if (err)
|
| 154 |
+
{
|
| 155 |
+
console.error(err);
|
| 156 |
+
return;
|
| 157 |
+
}
|
| 158 |
+
console.log('Output written to output.json | Removed Threads: ' + removedCount);
|
| 159 |
+
});
|
| 160 |
+
});
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
// Define a function that takes a csv string as an argument
|
| 164 |
+
function csvToJson(csv) {
|
| 165 |
+
// Split the csv string by newline characters to get an array of rows
|
| 166 |
+
const rows = csv.split("\n");
|
| 167 |
+
// Get the first row as an array of headers
|
| 168 |
+
const headers = rows[0].replace("\r", "").split(",");
|
| 169 |
+
|
| 170 |
+
// Create an empty array to store the json objects
|
| 171 |
+
const json = [];
|
| 172 |
+
|
| 173 |
+
// Loop through the remaining rows
|
| 174 |
+
for (let i = 1; i < rows.length; i++) {
|
| 175 |
+
// Get the current row as an array of values
|
| 176 |
+
const values = rows[i].split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/);
|
| 177 |
+
|
| 178 |
+
// Create an empty object to store the key-value pairs
|
| 179 |
+
const obj = {};
|
| 180 |
+
|
| 181 |
+
// Loop through the headers and values and assign them to the object
|
| 182 |
+
for (let j = 0; j < headers.length; j++)
|
| 183 |
+
{
|
| 184 |
+
if (headers[j] !== "id" && values[j] != undefined)
|
| 185 |
+
{
|
| 186 |
+
obj[headers[j]] = values[j].replace(/^"|"$/g, "").replace(/""/g, "\"").replace("\"\r", "");
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
// Push the object to the json array
|
| 191 |
+
json.push(obj);
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
// Return the json array as a string
|
| 195 |
+
return JSON.stringify(json, null, 2);
|
| 196 |
+
}
|