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
d258523a
Commit
d258523a
authored
Jul 15, 2024
by
Timothy J. Baek
Browse files
refac
parent
dbc352f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
backend/main.py
backend/main.py
+18
-10
src/lib/components/chat/Chat.svelte
src/lib/components/chat/Chat.svelte
+2
-0
No files found.
backend/main.py
View file @
d258523a
...
@@ -618,6 +618,12 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
...
@@ -618,6 +618,12 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
content
=
{
"detail"
:
str
(
e
)},
content
=
{
"detail"
:
str
(
e
)},
)
)
# Extract valves from the request body
valves
=
None
if
"valves"
in
body
:
valves
=
body
[
"valves"
]
del
body
[
"valves"
]
# Extract session_id, chat_id and message_id from the request body
# Extract session_id, chat_id and message_id from the request body
session_id
=
None
session_id
=
None
if
"session_id"
in
body
:
if
"session_id"
in
body
:
...
@@ -695,6 +701,7 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
...
@@ -695,6 +701,7 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
"session_id"
:
session_id
,
"session_id"
:
session_id
,
"chat_id"
:
chat_id
,
"chat_id"
:
chat_id
,
"message_id"
:
message_id
,
"message_id"
:
message_id
,
"valves"
:
valves
,
}
}
modified_body_bytes
=
json
.
dumps
(
body
).
encode
(
"utf-8"
)
modified_body_bytes
=
json
.
dumps
(
body
).
encode
(
"utf-8"
)
...
@@ -982,16 +989,17 @@ async def get_all_models():
...
@@ -982,16 +989,17 @@ async def get_all_models():
if
action_id
in
enabled_action_ids
if
action_id
in
enabled_action_ids
]
]
model
[
"actions"
]
=
[
model
[
"actions"
]
=
[]
{
for
action_id
in
action_ids
:
"id"
:
action_id
,
action
=
Functions
.
get_function_by_id
(
action_id
)
"name"
:
Functions
.
get_function_by_id
(
action_id
).
name
,
model
[
"actions"
].
append
(
"description"
:
Functions
.
get_function_by_id
(
{
action_id
"id"
:
action_id
,
).
meta
.
description
,
"name"
:
action
.
name
,
}
"description"
:
action
.
meta
.
description
,
for
action_id
in
action_ids
"icon_url"
:
action
.
meta
.
manifest
.
get
(
"icon_url"
,
None
),
]
}
)
else
:
else
:
owned_by
=
"openai"
owned_by
=
"openai"
...
...
src/lib/components/chat/Chat.svelte
View file @
d258523a
...
@@ -804,6 +804,7 @@
...
@@ -804,6 +804,7 @@
keep_alive: $settings.keepAlive ?? undefined,
keep_alive: $settings.keepAlive ?? undefined,
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
files: files.length > 0 ? files : undefined,
files: files.length > 0 ? files : undefined,
...(Object.keys(valves).length ? { valves } : {}),
session_id: $socket?.id,
session_id: $socket?.id,
chat_id: $chatId,
chat_id: $chatId,
id: responseMessageId
id: responseMessageId
...
@@ -1108,6 +1109,7 @@
...
@@ -1108,6 +1109,7 @@
max_tokens: params?.max_tokens ?? $settings?.params?.max_tokens ?? undefined,
max_tokens: params?.max_tokens ?? $settings?.params?.max_tokens ?? undefined,
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
tool_ids: selectedToolIds.length > 0 ? selectedToolIds : undefined,
files: files.length > 0 ? files : undefined,
files: files.length > 0 ? files : undefined,
...(Object.keys(valves).length ? { valves } : {}),
session_id: $socket?.id,
session_id: $socket?.id,
chat_id: $chatId,
chat_id: $chatId,
id: responseMessageId
id: responseMessageId
...
...
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