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
540b50e1
Commit
540b50e1
authored
Dec 25, 2023
by
Timothy J. Baek
Browse files
feat: wip chat route
parent
91743310
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
backend/apps/web/models/chats.py
backend/apps/web/models/chats.py
+4
-1
backend/apps/web/routers/chats.py
backend/apps/web/routers/chats.py
+9
-2
No files found.
backend/apps/web/models/chats.py
View file @
540b50e1
...
...
@@ -88,7 +88,10 @@ class ChatTable:
)
->
List
[
ChatModel
]:
return
[
ChatModel
(
**
model_to_dict
(
chat
))
for
chat
in
Chat
.
select
(
Chat
.
user_id
==
user_id
).
limit
(
limit
).
offset
(
skip
)
for
chat
in
Chat
.
select
(
Chat
.
id
,
Chat
.
title
)
.
where
(
Chat
.
user_id
==
user_id
)
.
limit
(
limit
)
.
offset
(
skip
)
]
def
get_chat_by_id_and_user_id
(
self
,
id
:
str
,
user_id
:
str
)
->
Optional
[
ChatModel
]:
...
...
backend/apps/web/routers/chats.py
View file @
540b50e1
...
...
@@ -33,7 +33,7 @@ async def get_user_chats(skip: int = 0, limit: int = 50, cred=Depends(bearer_sch
user
=
Users
.
get_user_by_token
(
token
)
if
user
:
return
Chats
.
get_chat_
titles_and_id
s_by_user_id
(
user
.
id
,
skip
,
limit
)
return
Chats
.
get_chat_
list
s_by_user_id
(
user
.
id
,
skip
,
limit
)
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
...
...
@@ -92,7 +92,14 @@ async def update_chat_by_id(
user
=
Users
.
get_user_by_token
(
token
)
if
user
:
return
Chats
.
update_chat_by_id_and_user_id
(
id
,
user
.
id
,
form_data
.
chat
)
chat
=
Chats
.
get_chat_by_id_and_user_id
(
id
,
user
.
id
)
if
chat
:
return
Chats
.
update_chat_by_id
(
id
,
form_data
.
chat
)
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
detail
=
ERROR_MESSAGES
.
ACCESS_PROHIBITED
,
)
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
...
...
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