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
f531a51e
Commit
f531a51e
authored
Jul 22, 2024
by
Aryan Kothari
Browse files
chore: formatting
parent
a0667dfd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
backend/apps/webui/models/chats.py
backend/apps/webui/models/chats.py
+18
-10
No files found.
backend/apps/webui/models/chats.py
View file @
f531a51e
...
@@ -244,13 +244,14 @@ class ChatTable:
...
@@ -244,13 +244,14 @@ class ChatTable:
.
all
()
.
all
()
)
)
return
[
ChatModel
.
model_validate
(
chat
)
for
chat
in
all_chats
]
return
[
ChatModel
.
model_validate
(
chat
)
for
chat
in
all_chats
]
def
get_chat_title_id_list_by_user_id
(
def
get_chat_title_id_list_by_user_id
(
self
,
self
,
user_id
:
str
,
user_id
:
str
,
include_archived
:
bool
=
False
,
include_archived
:
bool
=
False
,
skip
:
int
=
0
,
skip
:
int
=
0
,
limit
:
int
=
50
,
limit
:
int
=
50
,
)
->
List
[
ChatTitleIdResponse
]:
)
->
List
[
ChatTitleIdResponse
]:
with
get_db
()
as
db
:
with
get_db
()
as
db
:
query
=
db
.
query
(
Chat
).
filter_by
(
user_id
=
user_id
)
query
=
db
.
query
(
Chat
).
filter_by
(
user_id
=
user_id
)
if
not
include_archived
:
if
not
include_archived
:
...
@@ -259,17 +260,24 @@ class ChatTable:
...
@@ -259,17 +260,24 @@ class ChatTable:
all_chats
=
(
all_chats
=
(
query
.
order_by
(
Chat
.
updated_at
.
desc
())
query
.
order_by
(
Chat
.
updated_at
.
desc
())
# limit cols
# limit cols
.
with_entities
(
Chat
.
id
,
Chat
.
title
,
Chat
.
updated_at
,
Chat
.
created_at
)
.
with_entities
(
.
all
()
Chat
.
id
,
Chat
.
title
,
Chat
.
updated_at
,
Chat
.
created_at
).
all
()
)
)
# result has to be destrctured from sqlalchemy `row` and mapped to a dict since the `ChatModel`is not the returned dataclass.
# result has to be destrctured from sqlalchemy `row` and mapped to a dict since the `ChatModel`is not the returned dataclass.
return
list
(
map
(
lambda
row
:
ChatTitleIdResponse
.
model_validate
({
return
list
(
"id"
:
row
[
0
],
map
(
"title"
:
row
[
1
],
lambda
row
:
ChatTitleIdResponse
.
model_validate
(
"updated_at"
:
row
[
2
],
{
"created_at"
:
row
[
3
]
"id"
:
row
[
0
],
}),
all_chats
))
"title"
:
row
[
1
],
"updated_at"
:
row
[
2
],
"created_at"
:
row
[
3
],
}
),
all_chats
,
)
)
def
get_chat_list_by_chat_ids
(
def
get_chat_list_by_chat_ids
(
self
,
chat_ids
:
List
[
str
],
skip
:
int
=
0
,
limit
:
int
=
50
self
,
chat_ids
:
List
[
str
],
skip
:
int
=
0
,
limit
:
int
=
50
...
...
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