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
1303407f
"git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "b80e2db1feea75dd34df4fe387c335ca8a6edfa0"
Commit
1303407f
authored
Dec 26, 2023
by
Timothy J. Baek
Browse files
feat: update chat
parent
0810a264
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
backend/apps/web/models/chats.py
backend/apps/web/models/chats.py
+18
-0
backend/apps/web/routers/chats.py
backend/apps/web/routers/chats.py
+4
-1
src/lib/components/chat/Messages.svelte
src/lib/components/chat/Messages.svelte
+1
-0
No files found.
backend/apps/web/models/chats.py
View file @
1303407f
...
@@ -44,6 +44,10 @@ class ChatForm(BaseModel):
...
@@ -44,6 +44,10 @@ class ChatForm(BaseModel):
chat
:
dict
chat
:
dict
class
ChatTitleForm
(
BaseModel
):
title
:
str
class
ChatResponse
(
BaseModel
):
class
ChatResponse
(
BaseModel
):
id
:
str
id
:
str
user_id
:
str
user_id
:
str
...
@@ -93,6 +97,20 @@ class ChatTable:
...
@@ -93,6 +97,20 @@ class ChatTable:
except
:
except
:
return
None
return
None
def
update_chat_by_id
(
self
,
id
:
str
,
chat
:
dict
)
->
Optional
[
ChatModel
]:
try
:
query
=
Chat
.
update
(
chat
=
json
.
dumps
(
chat
),
title
=
chat
[
"title"
]
if
"title"
in
chat
else
"New Chat"
,
timestamp
=
int
(
time
.
time
()),
).
where
(
Chat
.
id
==
id
)
query
.
execute
()
chat
=
Chat
.
get
(
Chat
.
id
==
id
)
return
ChatModel
(
**
model_to_dict
(
chat
))
except
:
return
None
def
get_chat_lists_by_user_id
(
def
get_chat_lists_by_user_id
(
self
,
user_id
:
str
,
skip
:
int
=
0
,
limit
:
int
=
50
self
,
user_id
:
str
,
skip
:
int
=
0
,
limit
:
int
=
50
)
->
List
[
ChatModel
]:
)
->
List
[
ChatModel
]:
...
...
backend/apps/web/routers/chats.py
View file @
1303407f
...
@@ -11,6 +11,7 @@ from apps.web.models.users import Users
...
@@ -11,6 +11,7 @@ from apps.web.models.users import Users
from
apps.web.models.chats
import
(
from
apps.web.models.chats
import
(
ChatModel
,
ChatModel
,
ChatResponse
,
ChatResponse
,
ChatTitleForm
,
ChatForm
,
ChatForm
,
ChatTitleIdResponse
,
ChatTitleIdResponse
,
Chats
,
Chats
,
...
@@ -95,7 +96,9 @@ async def update_chat_by_id(id: str, form_data: ChatForm, cred=Depends(bearer_sc
...
@@ -95,7 +96,9 @@ async def update_chat_by_id(id: str, form_data: ChatForm, cred=Depends(bearer_sc
if
user
:
if
user
:
chat
=
Chats
.
get_chat_by_id_and_user_id
(
id
,
user
.
id
)
chat
=
Chats
.
get_chat_by_id_and_user_id
(
id
,
user
.
id
)
if
chat
:
if
chat
:
chat
=
Chats
.
update_chat_by_id
(
id
,
form_data
.
chat
)
updated_chat
=
{
**
json
.
loads
(
chat
.
chat
),
**
form_data
.
chat
}
chat
=
Chats
.
update_chat_by_id
(
id
,
updated_chat
)
return
ChatResponse
(
**
{
**
chat
.
model_dump
(),
"chat"
:
json
.
loads
(
chat
.
chat
)})
return
ChatResponse
(
**
{
**
chat
.
model_dump
(),
"chat"
:
json
.
loads
(
chat
.
chat
)})
else
:
else
:
raise
HTTPException
(
raise
HTTPException
(
...
...
src/lib/components/chat/Messages.svelte
View file @
1303407f
...
@@ -254,6 +254,7 @@
...
@@ -254,6 +254,7 @@
};
};
const
rateMessage
=
async
(
messageIdx
,
rating
)
=>
{
const
rateMessage
=
async
(
messageIdx
,
rating
)
=>
{
// TODO: Move this function to parent
messages
=
messages
.
map
((
message
,
idx
)
=>
{
messages
=
messages
.
map
((
message
,
idx
)
=>
{
if
(
messageIdx
===
idx
)
{
if
(
messageIdx
===
idx
)
{
message
.
rating
=
rating
;
message
.
rating
=
rating
;
...
...
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