mirror of
https://github.com/Mintplex-Labs/anything-llm
synced 2026-05-05 06:41:57 +02:00
570 document api return object (#608)
* Add support for fetching single document in documents folder * Add document object to upload + support link scraping via API * hotfixes for documentation * update api docs
This commit is contained in:
@@ -31,6 +31,7 @@ async function asAudio({ fullFilePath = "", filename = "" }) {
|
||||
return {
|
||||
success: false,
|
||||
reason: `Failed to parse content from ${filename}.`,
|
||||
documents: [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -43,7 +44,11 @@ async function asAudio({ fullFilePath = "", filename = "" }) {
|
||||
if (!content.length) {
|
||||
console.error(`Resulting text content was empty for ${filename}.`);
|
||||
trashFile(fullFilePath);
|
||||
return { success: false, reason: `No text content found in ${filename}.` };
|
||||
return {
|
||||
success: false,
|
||||
reason: `No text content found in ${filename}.`,
|
||||
documents: [],
|
||||
};
|
||||
}
|
||||
|
||||
const data = {
|
||||
@@ -60,12 +65,15 @@ async function asAudio({ fullFilePath = "", filename = "" }) {
|
||||
token_count_estimate: tokenizeString(content).length,
|
||||
};
|
||||
|
||||
writeToServerDocuments(data, `${slugify(filename)}-${data.id}`);
|
||||
const document = writeToServerDocuments(
|
||||
data,
|
||||
`${slugify(filename)}-${data.id}`
|
||||
);
|
||||
trashFile(fullFilePath);
|
||||
console.log(
|
||||
`[SUCCESS]: ${filename} transcribed, converted & ready for embedding.\n`
|
||||
);
|
||||
return { success: true, reason: null };
|
||||
return { success: true, reason: null, documents: [document] };
|
||||
}
|
||||
|
||||
async function convertToWavAudioData(sourcePath) {
|
||||
|
||||
Reference in New Issue
Block a user