Add ability to inject custom files into the prompt (broken ATM)

This commit is contained in:
SillyLossy
2023-05-22 00:56:12 +03:00
parent 0e7289d878
commit a4b2b68620
6 changed files with 84 additions and 6 deletions

View File

@ -35,6 +35,19 @@ export async function urlContentToDataUri(url, params) {
});
}
export function getFileText(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsText(file);
reader.onload = function () {
resolve(reader.result);
};
reader.onerror = function (error) {
reject(error);
};
});
}
export function getBase64Async(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
@ -261,7 +274,7 @@ export function splitRecursive(input, length, delimitiers = ['\n\n', '\n', ' ',
let currentChunk = '';
for (let i = 0; i < flatParts.length;) {
currentChunk = flatParts[i];
let j = i + 1;
let j = i + 1;
while (j < flatParts.length) {
const nextChunk = flatParts[j];
if (currentChunk.length + nextChunk.length + delim.length <= length) {