mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 12:25:20 +00:00
refac
This commit is contained in:
parent
2e1ddf823b
commit
5af5e1d3e4
1 changed files with 39 additions and 20 deletions
|
|
@ -648,8 +648,9 @@ async def clone_chat_by_id(
|
||||||
"title": form_data.title if form_data.title else f"Clone of {chat.title}",
|
"title": form_data.title if form_data.title else f"Clone of {chat.title}",
|
||||||
}
|
}
|
||||||
|
|
||||||
chat = Chats.import_chat(
|
chats = Chats.import_chats(
|
||||||
user.id,
|
user.id,
|
||||||
|
[
|
||||||
ChatImportForm(
|
ChatImportForm(
|
||||||
**{
|
**{
|
||||||
"chat": updated_chat,
|
"chat": updated_chat,
|
||||||
|
|
@ -657,10 +658,18 @@ async def clone_chat_by_id(
|
||||||
"pinned": chat.pinned,
|
"pinned": chat.pinned,
|
||||||
"folder_id": chat.folder_id,
|
"folder_id": chat.folder_id,
|
||||||
}
|
}
|
||||||
),
|
)
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if chats:
|
||||||
|
chat = chats[0]
|
||||||
return ChatResponse(**chat.model_dump())
|
return ChatResponse(**chat.model_dump())
|
||||||
|
else:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||||
|
detail=ERROR_MESSAGES.DEFAULT(),
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED, detail=ERROR_MESSAGES.DEFAULT()
|
status_code=status.HTTP_401_UNAUTHORIZED, detail=ERROR_MESSAGES.DEFAULT()
|
||||||
|
|
@ -688,8 +697,9 @@ async def clone_shared_chat_by_id(id: str, user=Depends(get_verified_user)):
|
||||||
"title": f"Clone of {chat.title}",
|
"title": f"Clone of {chat.title}",
|
||||||
}
|
}
|
||||||
|
|
||||||
chat = Chats.import_chat(
|
chats = Chats.import_chats(
|
||||||
user.id,
|
user.id,
|
||||||
|
[
|
||||||
ChatImportForm(
|
ChatImportForm(
|
||||||
**{
|
**{
|
||||||
"chat": updated_chat,
|
"chat": updated_chat,
|
||||||
|
|
@ -697,9 +707,18 @@ async def clone_shared_chat_by_id(id: str, user=Depends(get_verified_user)):
|
||||||
"pinned": chat.pinned,
|
"pinned": chat.pinned,
|
||||||
"folder_id": chat.folder_id,
|
"folder_id": chat.folder_id,
|
||||||
}
|
}
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
if chats:
|
||||||
|
chat = chats[0]
|
||||||
return ChatResponse(**chat.model_dump())
|
return ChatResponse(**chat.model_dump())
|
||||||
|
else:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||||
|
detail=ERROR_MESSAGES.DEFAULT(),
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED, detail=ERROR_MESSAGES.DEFAULT()
|
status_code=status.HTTP_401_UNAUTHORIZED, detail=ERROR_MESSAGES.DEFAULT()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue