mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac
This commit is contained in:
parent
677c36c3aa
commit
6afc686e17
@ -319,7 +319,7 @@ def get_rag_context(
|
|||||||
for file in files:
|
for file in files:
|
||||||
if file.get("context") == "full":
|
if file.get("context") == "full":
|
||||||
context = {
|
context = {
|
||||||
"documents": [[file["content"]]],
|
"documents": [[file.get("file").get("content")]],
|
||||||
"metadatas": [[{"file_id": file.get("id"), "name": file.get("name")}]],
|
"metadatas": [[{"file_id": file.get("id"), "name": file.get("name")}]],
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
|
@ -150,7 +150,10 @@
|
|||||||
if (res) {
|
if (res) {
|
||||||
fileItem.status = 'processed';
|
fileItem.status = 'processed';
|
||||||
fileItem.collection_name = res.collection_name;
|
fileItem.collection_name = res.collection_name;
|
||||||
fileItem.content = res.content;
|
fileItem.file = {
|
||||||
|
...fileItem.file,
|
||||||
|
content: res.content
|
||||||
|
};
|
||||||
|
|
||||||
files = files;
|
files = files;
|
||||||
}
|
}
|
||||||
|
@ -46,14 +46,17 @@
|
|||||||
if (res) {
|
if (res) {
|
||||||
fileItem.status = 'processed';
|
fileItem.status = 'processed';
|
||||||
fileItem.collection_name = res.collection_name;
|
fileItem.collection_name = res.collection_name;
|
||||||
fileItem.content = res.content;
|
fileItem.file = {
|
||||||
|
content: res.content,
|
||||||
|
...fileItem.file
|
||||||
|
};
|
||||||
|
|
||||||
files = files;
|
files = files;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Remove the failed doc from the files array
|
// Remove the failed doc from the files array
|
||||||
files = files.filter((f) => f.name !== url);
|
files = files.filter((f) => f.name !== url);
|
||||||
toast.error(e);
|
toast.error(JSON.stringify(e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,7 +79,10 @@
|
|||||||
if (res) {
|
if (res) {
|
||||||
fileItem.status = 'processed';
|
fileItem.status = 'processed';
|
||||||
fileItem.collection_name = res.collection_name;
|
fileItem.collection_name = res.collection_name;
|
||||||
fileItem.content = res.content;
|
fileItem.file = {
|
||||||
|
content: res.content,
|
||||||
|
...fileItem.file
|
||||||
|
};
|
||||||
files = files;
|
files = files;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
class="h-14 {className} flex items-center space-x-3 {colorClassName} rounded-xl border border-gray-100 dark:border-gray-800 text-left"
|
class="h-14 {className} flex items-center space-x-3 {colorClassName} rounded-xl border border-gray-100 dark:border-gray-800 text-left"
|
||||||
type="button"
|
type="button"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
if (file.content) {
|
if (file?.file?.content) {
|
||||||
showModal = !showModal;
|
showModal = !showModal;
|
||||||
} else {
|
} else {
|
||||||
if (url) {
|
if (url) {
|
||||||
|
@ -61,8 +61,10 @@
|
|||||||
•
|
•
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if file.content}
|
{#if file?.file?.content}
|
||||||
<div class="capitalize shrink-0">{getLineCount(file.content)} extracted lines</div>
|
<div class="capitalize shrink-0">
|
||||||
|
{getLineCount(file?.file?.content ?? '')} extracted lines
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-1 shrink-0">
|
<div class="flex items-center gap-1 shrink-0">
|
||||||
<Info />
|
<Info />
|
||||||
@ -100,7 +102,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="max-h-96 overflow-scroll scrollbar-hidden text-xs whitespace-pre-wrap">
|
<div class="max-h-96 overflow-scroll scrollbar-hidden text-xs whitespace-pre-wrap">
|
||||||
{file?.content ?? 'No content'}
|
{file?.file?.content ?? 'No content'}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
@ -889,5 +889,6 @@ export const formatFileSize = (size) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getLineCount = (text) => {
|
export const getLineCount = (text) => {
|
||||||
return text.split('\n').length;
|
console.log(typeof text);
|
||||||
|
return text ? text.split('\n').length : 0;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user