Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
519375b4
Commit
519375b4
authored
Aug 01, 2024
by
Aryan Kothari
Browse files
add: skip and limit use in query
- limit default changed to -1
parent
49199819
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
backend/apps/webui/models/chats.py
backend/apps/webui/models/chats.py
+5
-4
backend/apps/webui/routers/chats.py
backend/apps/webui/routers/chats.py
+1
-1
No files found.
backend/apps/webui/models/chats.py
View file @
519375b4
...
...
@@ -250,7 +250,7 @@ class ChatTable:
user_id
:
str
,
include_archived
:
bool
=
False
,
skip
:
int
=
0
,
limit
:
int
=
50
,
limit
:
int
=
-
1
,
)
->
List
[
ChatTitleIdResponse
]:
with
get_db
()
as
db
:
query
=
db
.
query
(
Chat
).
filter_by
(
user_id
=
user_id
)
...
...
@@ -260,9 +260,10 @@ class ChatTable:
all_chats
=
(
query
.
order_by
(
Chat
.
updated_at
.
desc
())
# limit cols
.
with_entities
(
Chat
.
id
,
Chat
.
title
,
Chat
.
updated_at
,
Chat
.
created_at
).
all
()
.
with_entities
(
Chat
.
id
,
Chat
.
title
,
Chat
.
updated_at
,
Chat
.
created_at
)
.
limit
(
limit
)
.
offset
(
skip
)
.
all
()
)
# result has to be destrctured from sqlalchemy `row` and mapped to a dict since the `ChatModel`is not the returned dataclass.
return
[
...
...
backend/apps/webui/routers/chats.py
View file @
519375b4
...
...
@@ -43,7 +43,7 @@ router = APIRouter()
@
router
.
get
(
"/"
,
response_model
=
List
[
ChatTitleIdResponse
])
@
router
.
get
(
"/list"
,
response_model
=
List
[
ChatTitleIdResponse
])
async
def
get_session_user_chat_list
(
user
=
Depends
(
get_verified_user
),
skip
:
int
=
0
,
limit
:
int
=
50
user
=
Depends
(
get_verified_user
),
skip
:
int
=
0
,
limit
:
int
=
-
1
):
return
Chats
.
get_chat_title_id_list_by_user_id
(
user
.
id
,
skip
=
skip
,
limit
=
limit
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment