mirror of
https://github.com/open-webui/open-webui
synced 2024-12-28 06:42:47 +00:00
npm run format
This commit is contained in:
parent
89e86f5e2e
commit
366158ff04
@ -951,7 +951,7 @@ async def get_app_config(request: Request):
|
|||||||
},
|
},
|
||||||
"google_drive": {
|
"google_drive": {
|
||||||
"client_id": GOOGLE_DRIVE_CLIENT_ID.value,
|
"client_id": GOOGLE_DRIVE_CLIENT_ID.value,
|
||||||
"api_key": GOOGLE_DRIVE_API_KEY.value
|
"api_key": GOOGLE_DRIVE_API_KEY.value,
|
||||||
},
|
},
|
||||||
**(
|
**(
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,12 @@ from open_webui.models.knowledge import (
|
|||||||
)
|
)
|
||||||
from open_webui.models.files import Files, FileModel
|
from open_webui.models.files import Files, FileModel
|
||||||
from open_webui.retrieval.vector.connector import VECTOR_DB_CLIENT
|
from open_webui.retrieval.vector.connector import VECTOR_DB_CLIENT
|
||||||
from open_webui.routers.retrieval import process_file, ProcessFileForm, process_files_batch, BatchProcessFilesForm
|
from open_webui.routers.retrieval import (
|
||||||
|
process_file,
|
||||||
|
ProcessFileForm,
|
||||||
|
process_files_batch,
|
||||||
|
BatchProcessFilesForm,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
@ -519,6 +524,7 @@ async def reset_knowledge_by_id(id: str, user=Depends(get_verified_user)):
|
|||||||
# AddFilesToKnowledge
|
# AddFilesToKnowledge
|
||||||
############################
|
############################
|
||||||
|
|
||||||
|
|
||||||
@router.post("/{id}/files/batch/add", response_model=Optional[KnowledgeFilesResponse])
|
@router.post("/{id}/files/batch/add", response_model=Optional[KnowledgeFilesResponse])
|
||||||
def add_files_to_knowledge_batch(
|
def add_files_to_knowledge_batch(
|
||||||
id: str,
|
id: str,
|
||||||
@ -555,27 +561,25 @@ def add_files_to_knowledge_batch(
|
|||||||
|
|
||||||
# Process files
|
# Process files
|
||||||
try:
|
try:
|
||||||
result = process_files_batch(BatchProcessFilesForm(
|
result = process_files_batch(
|
||||||
files=files,
|
BatchProcessFilesForm(files=files, collection_name=id)
|
||||||
collection_name=id
|
|
||||||
))
|
|
||||||
except Exception as e:
|
|
||||||
log.error(f"add_files_to_knowledge_batch: Exception occurred: {e}", exc_info=True)
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
|
||||||
detail=str(e)
|
|
||||||
)
|
)
|
||||||
|
except Exception as e:
|
||||||
|
log.error(
|
||||||
|
f"add_files_to_knowledge_batch: Exception occurred: {e}", exc_info=True
|
||||||
|
)
|
||||||
|
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e))
|
||||||
|
|
||||||
# Add successful files to knowledge base
|
# Add successful files to knowledge base
|
||||||
data = knowledge.data or {}
|
data = knowledge.data or {}
|
||||||
existing_file_ids = data.get("file_ids", [])
|
existing_file_ids = data.get("file_ids", [])
|
||||||
|
|
||||||
# Only add files that were successfully processed
|
# Only add files that were successfully processed
|
||||||
successful_file_ids = [r.file_id for r in result.results if r.status == "completed"]
|
successful_file_ids = [r.file_id for r in result.results if r.status == "completed"]
|
||||||
for file_id in successful_file_ids:
|
for file_id in successful_file_ids:
|
||||||
if file_id not in existing_file_ids:
|
if file_id not in existing_file_ids:
|
||||||
existing_file_ids.append(file_id)
|
existing_file_ids.append(file_id)
|
||||||
|
|
||||||
data["file_ids"] = existing_file_ids
|
data["file_ids"] = existing_file_ids
|
||||||
knowledge = Knowledges.update_knowledge_data_by_id(id=id, data=data)
|
knowledge = Knowledges.update_knowledge_data_by_id(id=id, data=data)
|
||||||
|
|
||||||
@ -587,11 +591,10 @@ def add_files_to_knowledge_batch(
|
|||||||
files=Files.get_files_by_ids(existing_file_ids),
|
files=Files.get_files_by_ids(existing_file_ids),
|
||||||
warnings={
|
warnings={
|
||||||
"message": "Some files failed to process",
|
"message": "Some files failed to process",
|
||||||
"errors": error_details
|
"errors": error_details,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
return KnowledgeFilesResponse(
|
return KnowledgeFilesResponse(
|
||||||
**knowledge.model_dump(),
|
**knowledge.model_dump(), files=Files.get_files_by_ids(existing_file_ids)
|
||||||
files=Files.get_files_by_ids(existing_file_ids)
|
|
||||||
)
|
)
|
||||||
|
@ -37007,16 +37007,14 @@
|
|||||||
Pe.createElement('span', { className: 'brace-close' }, '}')
|
Pe.createElement('span', { className: 'brace-close' }, '}')
|
||||||
),
|
),
|
||||||
pe.size
|
pe.size
|
||||||
? pe
|
? pe.entrySeq().map(([s, o]) =>
|
||||||
.entrySeq()
|
Pe.createElement(xe, {
|
||||||
.map(([s, o]) =>
|
key: `${s}-${o}`,
|
||||||
Pe.createElement(xe, {
|
propKey: s,
|
||||||
key: `${s}-${o}`,
|
propVal: o,
|
||||||
propKey: s,
|
propClass: 'property'
|
||||||
propVal: o,
|
})
|
||||||
propClass: 'property'
|
)
|
||||||
})
|
|
||||||
)
|
|
||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -37167,16 +37165,14 @@
|
|||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
C && z.size
|
C && z.size
|
||||||
? z
|
? z.entrySeq().map(([s, o]) =>
|
||||||
.entrySeq()
|
Pe.createElement(le, {
|
||||||
.map(([s, o]) =>
|
key: `${s}-${o}`,
|
||||||
Pe.createElement(le, {
|
propKey: s,
|
||||||
key: `${s}-${o}`,
|
propVal: o,
|
||||||
propKey: s,
|
propClass: rs
|
||||||
propVal: o,
|
})
|
||||||
propClass: rs
|
)
|
||||||
})
|
|
||||||
)
|
|
||||||
: null,
|
: null,
|
||||||
U ? Pe.createElement(ie, { source: U }) : null,
|
U ? Pe.createElement(ie, { source: U }) : null,
|
||||||
Z &&
|
Z &&
|
||||||
@ -57290,20 +57286,18 @@
|
|||||||
Pe.createElement(
|
Pe.createElement(
|
||||||
'div',
|
'div',
|
||||||
{ className: 'modal-ux-content' },
|
{ className: 'modal-ux-content' },
|
||||||
x
|
x.valueSeq().map((x, j) =>
|
||||||
.valueSeq()
|
Pe.createElement(C, {
|
||||||
.map((x, j) =>
|
key: j,
|
||||||
Pe.createElement(C, {
|
AST: w,
|
||||||
key: j,
|
definitions: x,
|
||||||
AST: w,
|
getComponent: i,
|
||||||
definitions: x,
|
errSelectors: u,
|
||||||
getComponent: i,
|
authSelectors: s,
|
||||||
errSelectors: u,
|
authActions: o,
|
||||||
authSelectors: s,
|
specSelectors: _
|
||||||
authActions: o,
|
})
|
||||||
specSelectors: _
|
)
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -630,7 +630,6 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
onClose={async () => {
|
onClose={async () => {
|
||||||
await tick();
|
await tick();
|
||||||
|
|
||||||
|
@ -161,12 +161,30 @@
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 87.3 78" class="w-5 h-5">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 87.3 78" class="w-5 h-5">
|
||||||
<path d="m6.6 66.85 3.85 6.65c.8 1.4 1.95 2.5 3.3 3.3l13.75-23.8h-27.5c0 1.55.4 3.1 1.2 4.5z" fill="#0066da"/>
|
<path
|
||||||
<path d="m43.65 25-13.75-23.8c-1.35.8-2.5 1.9-3.3 3.3l-25.4 44a9.06 9.06 0 0 0 -1.2 4.5h27.5z" fill="#00ac47"/>
|
d="m6.6 66.85 3.85 6.65c.8 1.4 1.95 2.5 3.3 3.3l13.75-23.8h-27.5c0 1.55.4 3.1 1.2 4.5z"
|
||||||
<path d="m73.55 76.8c1.35-.8 2.5-1.9 3.3-3.3l1.6-2.75 7.65-13.25c.8-1.4 1.2-2.95 1.2-4.5h-27.502l5.852 11.5z" fill="#ea4335"/>
|
fill="#0066da"
|
||||||
<path d="m43.65 25 13.75-23.8c-1.35-.8-2.9-1.2-4.5-1.2h-18.5c-1.6 0-3.15.45-4.5 1.2z" fill="#00832d"/>
|
/>
|
||||||
<path d="m59.8 53h-32.3l-13.75 23.8c1.35.8 2.9 1.2 4.5 1.2h50.8c1.6 0 3.15-.45 4.5-1.2z" fill="#2684fc"/>
|
<path
|
||||||
<path d="m73.4 26.5-12.7-22c-.8-1.4-1.95-2.5-3.3-3.3l-13.75 23.8 16.15 28h27.45c0-1.55-.4-3.1-1.2-4.5z" fill="#ffba00"/>
|
d="m43.65 25-13.75-23.8c-1.35.8-2.5 1.9-3.3 3.3l-25.4 44a9.06 9.06 0 0 0 -1.2 4.5h27.5z"
|
||||||
|
fill="#00ac47"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="m73.55 76.8c1.35-.8 2.5-1.9 3.3-3.3l1.6-2.75 7.65-13.25c.8-1.4 1.2-2.95 1.2-4.5h-27.502l5.852 11.5z"
|
||||||
|
fill="#ea4335"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="m43.65 25 13.75-23.8c-1.35-.8-2.9-1.2-4.5-1.2h-18.5c-1.6 0-3.15.45-4.5 1.2z"
|
||||||
|
fill="#00832d"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="m59.8 53h-32.3l-13.75 23.8c1.35.8 2.9 1.2 4.5 1.2h50.8c1.6 0 3.15-.45 4.5-1.2z"
|
||||||
|
fill="#2684fc"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="m73.4 26.5-12.7-22c-.8-1.4-1.95-2.5-3.3-3.3l-13.75 23.8 16.15 28h27.45c0-1.55-.4-3.1-1.2-4.5z"
|
||||||
|
fill="#ffba00"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
<div class="line-clamp-1">{$i18n.t('Google Drive')}</div>
|
<div class="line-clamp-1">{$i18n.t('Google Drive')}</div>
|
||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
|
@ -552,31 +552,33 @@ export const removeEmojis = (str: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const removeFormattings = (str: string) => {
|
export const removeFormattings = (str: string) => {
|
||||||
return str
|
return (
|
||||||
// Block elements (remove completely)
|
str
|
||||||
.replace(/(```[\s\S]*?```)/g, '') // Code blocks
|
// Block elements (remove completely)
|
||||||
.replace(/^\|.*\|$/gm, '') // Tables
|
.replace(/(```[\s\S]*?```)/g, '') // Code blocks
|
||||||
// Inline elements (preserve content)
|
.replace(/^\|.*\|$/gm, '') // Tables
|
||||||
.replace(/(?:\*\*|__)(.*?)(?:\*\*|__)/g, '$1') // Bold
|
// Inline elements (preserve content)
|
||||||
.replace(/(?:[*_])(.*?)(?:[*_])/g, '$1') // Italic
|
.replace(/(?:\*\*|__)(.*?)(?:\*\*|__)/g, '$1') // Bold
|
||||||
.replace(/~~(.*?)~~/g, '$1') // Strikethrough
|
.replace(/(?:[*_])(.*?)(?:[*_])/g, '$1') // Italic
|
||||||
.replace(/`([^`]+)`/g, '$1') // Inline code
|
.replace(/~~(.*?)~~/g, '$1') // Strikethrough
|
||||||
|
.replace(/`([^`]+)`/g, '$1') // Inline code
|
||||||
// Links and images
|
|
||||||
.replace(/!?\[([^\]]*)\](?:\([^)]+\)|\[[^\]]*\])/g, '$1') // Links & images
|
// Links and images
|
||||||
.replace(/^\[[^\]]+\]:\s*.*$/gm, '') // Reference definitions
|
.replace(/!?\[([^\]]*)\](?:\([^)]+\)|\[[^\]]*\])/g, '$1') // Links & images
|
||||||
|
.replace(/^\[[^\]]+\]:\s*.*$/gm, '') // Reference definitions
|
||||||
// Block formatting
|
|
||||||
.replace(/^#{1,6}\s+/gm, '') // Headers
|
// Block formatting
|
||||||
.replace(/^\s*[-*+]\s+/gm, '') // Lists
|
.replace(/^#{1,6}\s+/gm, '') // Headers
|
||||||
.replace(/^\s*(?:\d+\.)\s+/gm, '') // Numbered lists
|
.replace(/^\s*[-*+]\s+/gm, '') // Lists
|
||||||
.replace(/^\s*>[> ]*/gm, '') // Blockquotes
|
.replace(/^\s*(?:\d+\.)\s+/gm, '') // Numbered lists
|
||||||
.replace(/^\s*:\s+/gm, '') // Definition lists
|
.replace(/^\s*>[> ]*/gm, '') // Blockquotes
|
||||||
|
.replace(/^\s*:\s+/gm, '') // Definition lists
|
||||||
// Cleanup
|
|
||||||
.replace(/\[\^[^\]]*\]/g, '') // Footnotes
|
// Cleanup
|
||||||
.replace(/[-*_~]/g, '') // Remaining markers
|
.replace(/\[\^[^\]]*\]/g, '') // Footnotes
|
||||||
.replace(/\n{2,}/g, '\n') // Multiple newlines
|
.replace(/[-*_~]/g, '') // Remaining markers
|
||||||
|
.replace(/\n{2,}/g, '\n')
|
||||||
|
); // Multiple newlines
|
||||||
};
|
};
|
||||||
|
|
||||||
export const cleanText = (content: string) => {
|
export const cleanText = (content: string) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user