refac/enh: include foldered chats in ref chat input menu
This commit is contained in:
parent
0e3b6b3b8f
commit
0dee15ba97
|
@ -492,11 +492,16 @@ class ChatTable:
|
|||
self,
|
||||
user_id: str,
|
||||
include_archived: bool = False,
|
||||
include_folders: bool = False,
|
||||
skip: Optional[int] = None,
|
||||
limit: Optional[int] = None,
|
||||
) -> list[ChatTitleIdResponse]:
|
||||
with get_db() as db:
|
||||
query = db.query(Chat).filter_by(user_id=user_id).filter_by(folder_id=None)
|
||||
query = db.query(Chat).filter_by(user_id=user_id)
|
||||
|
||||
if not include_folders:
|
||||
query = query.filter_by(folder_id=None)
|
||||
|
||||
query = query.filter(or_(Chat.pinned == False, Chat.pinned == None))
|
||||
|
||||
if not include_archived:
|
||||
|
|
|
@ -37,7 +37,9 @@ router = APIRouter()
|
|||
@router.get("/", response_model=list[ChatTitleIdResponse])
|
||||
@router.get("/list", response_model=list[ChatTitleIdResponse])
|
||||
def get_session_user_chat_list(
|
||||
user=Depends(get_verified_user), page: Optional[int] = None
|
||||
user=Depends(get_verified_user),
|
||||
page: Optional[int] = None,
|
||||
include_folders: Optional[bool] = False,
|
||||
):
|
||||
try:
|
||||
if page is not None:
|
||||
|
@ -45,10 +47,12 @@ def get_session_user_chat_list(
|
|||
skip = (page - 1) * limit
|
||||
|
||||
return Chats.get_chat_title_id_list_by_user_id(
|
||||
user.id, skip=skip, limit=limit
|
||||
user.id, include_folders=include_folders, skip=skip, limit=limit
|
||||
)
|
||||
else:
|
||||
return Chats.get_chat_title_id_list_by_user_id(user.id)
|
||||
return Chats.get_chat_title_id_list_by_user_id(
|
||||
user.id, include_folders=include_folders
|
||||
)
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
raise HTTPException(
|
||||
|
|
|
@ -77,7 +77,11 @@ export const importChat = async (
|
|||
return res;
|
||||
};
|
||||
|
||||
export const getChatList = async (token: string = '', page: number | null = null) => {
|
||||
export const getChatList = async (
|
||||
token: string = '',
|
||||
page: number | null = null,
|
||||
include_folders: boolean = false
|
||||
) => {
|
||||
let error = null;
|
||||
const searchParams = new URLSearchParams();
|
||||
|
||||
|
@ -85,6 +89,10 @@ export const getChatList = async (token: string = '', page: number | null = null
|
|||
searchParams.append('page', `${page}`);
|
||||
}
|
||||
|
||||
if (include_folders) {
|
||||
searchParams.append('include_folders', 'true');
|
||||
}
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/?${searchParams.toString()}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
const getItemsPage = async () => {
|
||||
itemsLoading = true;
|
||||
let res = await getChatList(localStorage.token, page).catch(() => {
|
||||
let res = await getChatList(localStorage.token, page, true).catch(() => {
|
||||
return [];
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue