#1954 Remove backtick wrapping for inserted files
This commit is contained in:
parent
ab5b497562
commit
4665db62f4
|
@ -385,7 +385,7 @@ export async function appendFileContent(message, messageText) {
|
||||||
const fileText = message.extra.file.text || (await getFileAttachment(message.extra.file.url));
|
const fileText = message.extra.file.text || (await getFileAttachment(message.extra.file.url));
|
||||||
|
|
||||||
if (fileText) {
|
if (fileText) {
|
||||||
const fileWrapped = `\`\`\`\n${fileText}\n\`\`\`\n\n`;
|
const fileWrapped = `${fileText}\n\n`;
|
||||||
message.extra.fileLength = fileWrapped.length;
|
message.extra.fileLength = fileWrapped.length;
|
||||||
messageText = fileWrapped + messageText;
|
messageText = fileWrapped + messageText;
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,8 +222,7 @@ async function processFiles(chat) {
|
||||||
|
|
||||||
// Trim file inserted by the script
|
// Trim file inserted by the script
|
||||||
const fileText = String(message.mes)
|
const fileText = String(message.mes)
|
||||||
.substring(0, message.extra.fileLength).trim()
|
.substring(0, message.extra.fileLength).trim();
|
||||||
.replace(/^```/, '').replace(/```$/, '').trim();
|
|
||||||
|
|
||||||
// Convert kilobytes to string length
|
// Convert kilobytes to string length
|
||||||
const thresholdLength = settings.size_threshold * 1024;
|
const thresholdLength = settings.size_threshold * 1024;
|
||||||
|
@ -247,8 +246,7 @@ async function processFiles(chat) {
|
||||||
const queryText = getQueryText(chat);
|
const queryText = getQueryText(chat);
|
||||||
const fileChunks = await retrieveFileChunks(queryText, collectionId);
|
const fileChunks = await retrieveFileChunks(queryText, collectionId);
|
||||||
|
|
||||||
// Wrap it back in a code block
|
message.mes = `${fileChunks}\n\n${message.mes}`;
|
||||||
message.mes = `\`\`\`\n${fileChunks}\n\`\`\`\n\n${message.mes}`;
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Vectors: Failed to retrieve files', error);
|
console.error('Vectors: Failed to retrieve files', error);
|
||||||
|
|
Loading…
Reference in New Issue