mirror of
https://github.com/open-webui/open-webui
synced 2024-11-21 15:47:49 +00:00
fix: knowledge files issue
This commit is contained in:
parent
4156b62811
commit
2b890cf747
@ -43,6 +43,7 @@ async def get_knowledge(user=Depends(get_verified_user)):
|
|||||||
knowledge_bases = Knowledges.get_knowledge_bases_by_user_id(user.id, "read")
|
knowledge_bases = Knowledges.get_knowledge_bases_by_user_id(user.id, "read")
|
||||||
|
|
||||||
# Get files for each knowledge base
|
# Get files for each knowledge base
|
||||||
|
knowledge_with_files = []
|
||||||
for knowledge_base in knowledge_bases:
|
for knowledge_base in knowledge_bases:
|
||||||
files = []
|
files = []
|
||||||
if knowledge_base.data:
|
if knowledge_base.data:
|
||||||
@ -70,12 +71,14 @@ async def get_knowledge(user=Depends(get_verified_user)):
|
|||||||
|
|
||||||
files = Files.get_file_metadatas_by_ids(file_ids)
|
files = Files.get_file_metadatas_by_ids(file_ids)
|
||||||
|
|
||||||
knowledge_base = KnowledgeResponse(
|
knowledge_with_files.append(
|
||||||
**knowledge_base.model_dump(),
|
KnowledgeUserResponse(
|
||||||
files=files,
|
**knowledge_base.model_dump(),
|
||||||
|
files=files,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return knowledge_bases
|
return knowledge_with_files
|
||||||
|
|
||||||
|
|
||||||
@router.get("/list", response_model=list[KnowledgeUserResponse])
|
@router.get("/list", response_model=list[KnowledgeUserResponse])
|
||||||
@ -88,6 +91,7 @@ async def get_knowledge_list(user=Depends(get_verified_user)):
|
|||||||
knowledge_bases = Knowledges.get_knowledge_bases_by_user_id(user.id, "write")
|
knowledge_bases = Knowledges.get_knowledge_bases_by_user_id(user.id, "write")
|
||||||
|
|
||||||
# Get files for each knowledge base
|
# Get files for each knowledge base
|
||||||
|
knowledge_with_files = []
|
||||||
for knowledge_base in knowledge_bases:
|
for knowledge_base in knowledge_bases:
|
||||||
files = []
|
files = []
|
||||||
if knowledge_base.data:
|
if knowledge_base.data:
|
||||||
@ -115,12 +119,13 @@ async def get_knowledge_list(user=Depends(get_verified_user)):
|
|||||||
|
|
||||||
files = Files.get_file_metadatas_by_ids(file_ids)
|
files = Files.get_file_metadatas_by_ids(file_ids)
|
||||||
|
|
||||||
knowledge_base = KnowledgeResponse(
|
knowledge_with_files.append(
|
||||||
**knowledge_base.model_dump(),
|
KnowledgeUserResponse(
|
||||||
files=files,
|
**knowledge_base.model_dump(),
|
||||||
|
files=files,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
return knowledge_with_files
|
||||||
return knowledge_bases
|
|
||||||
|
|
||||||
|
|
||||||
############################
|
############################
|
||||||
|
Loading…
Reference in New Issue
Block a user