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
8cdf9814
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "bc458d3ee00d02d938ec3f003c87e338f27435fb"
Commit
8cdf9814
authored
Aug 08, 2024
by
Michael Poluektov
Browse files
fix: name differences
parent
e6bbce43
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
15 deletions
+22
-15
backend/utils/misc.py
backend/utils/misc.py
+22
-15
No files found.
backend/utils/misc.py
View file @
8cdf9814
...
@@ -148,23 +148,24 @@ def apply_model_params_to_body(
...
@@ -148,23 +148,24 @@ def apply_model_params_to_body(
return
form_data
return
form_data
OPENAI_MAPPINGS
=
{
"temperature"
:
float
,
"top_p"
:
int
,
"max_tokens"
:
int
,
"frequency_penalty"
:
int
,
"seed"
:
lambda
x
:
x
,
"stop"
:
lambda
x
:
[
bytes
(
s
,
"utf-8"
).
decode
(
"unicode_escape"
)
for
s
in
x
],
}
# inplace function: form_data is modified
# inplace function: form_data is modified
def
apply_model_params_to_body_openai
(
params
:
dict
,
form_data
:
dict
)
->
dict
:
def
apply_model_params_to_body_openai
(
params
:
dict
,
form_data
:
dict
)
->
dict
:
return
apply_model_params_to_body
(
params
,
form_data
,
OPENAI_MAPPINGS
)
mappings
=
{
"temperature"
:
float
,
"top_p"
:
int
,
"max_tokens"
:
int
,
"frequency_penalty"
:
int
,
"seed"
:
lambda
x
:
x
,
"stop"
:
lambda
x
:
[
bytes
(
s
,
"utf-8"
).
decode
(
"unicode_escape"
)
for
s
in
x
],
}
return
apply_model_params_to_body
(
params
,
form_data
,
mappings
)
def
apply_model_params_to_body_ollama
(
params
:
dict
,
form_data
:
dict
)
->
dict
:
def
apply_model_params_to_body_ollama
(
params
:
dict
,
form_data
:
dict
)
->
dict
:
opts
=
[
opts
=
[
"temperature"
,
"top_p"
,
"seed"
,
"mirostat"
,
"mirostat"
,
"mirostat_eta"
,
"mirostat_eta"
,
"mirostat_tau"
,
"mirostat_tau"
,
...
@@ -180,12 +181,18 @@ def apply_model_params_to_body_ollama(params: dict, form_data: dict) -> dict:
...
@@ -180,12 +181,18 @@ def apply_model_params_to_body_ollama(params: dict, form_data: dict) -> dict:
"num_thread"
,
"num_thread"
,
]
]
mappings
=
{
i
:
lambda
x
:
x
for
i
in
opts
}
mappings
=
{
i
:
lambda
x
:
x
for
i
in
opts
}
mappings
=
{
**
mappings
,
**
OPENAI_MAPPINGS
}
form_data
=
apply_model_params_to_body
(
params
,
form_data
,
mappings
)
form_data
=
apply_model_params_to_body
(
params
,
form_data
,
mappings
)
# only param that changes name
name_differences
=
{
if
(
param
:
=
params
.
get
(
"frequency_penalty"
,
None
))
is
not
None
:
"max_tokens"
:
"num_predict"
,
form_data
[
"repeat_penalty"
]
=
param
"frequency_penalty"
:
"repeat_penalty"
,
}
for
key
,
value
in
name_differences
.
items
():
if
(
param
:
=
params
.
get
(
key
,
None
))
is
not
None
:
form_data
[
value
]
=
param
print
(
form_data
)
return
form_data
return
form_data
...
...
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