mirror of
https://github.com/open-webui/open-webui
synced 2025-06-14 10:20:52 +00:00
enh: better custom param handling
This commit is contained in:
parent
9be22cb637
commit
4371d2c5a5
@ -671,6 +671,16 @@ def apply_params_to_form_data(form_data, model):
|
|||||||
del params[key]
|
del params[key]
|
||||||
|
|
||||||
if custom_params:
|
if custom_params:
|
||||||
|
# Attempt to parse custom_params if they are strings
|
||||||
|
for key, value in custom_params.items():
|
||||||
|
if isinstance(value, str):
|
||||||
|
try:
|
||||||
|
# Attempt to parse the string as JSON
|
||||||
|
custom_params[key] = json.loads(value)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
# If it fails, keep the original string
|
||||||
|
pass
|
||||||
|
|
||||||
# If custom_params are provided, merge them into params
|
# If custom_params are provided, merge them into params
|
||||||
params = deep_update(params, custom_params)
|
params = deep_update(params, custom_params)
|
||||||
|
|
||||||
|
@ -86,6 +86,16 @@ def apply_model_params_to_body_openai(params: dict, form_data: dict) -> dict:
|
|||||||
|
|
||||||
custom_params = params.pop("custom_params", {})
|
custom_params = params.pop("custom_params", {})
|
||||||
if custom_params:
|
if custom_params:
|
||||||
|
# Attempt to parse custom_params if they are strings
|
||||||
|
for key, value in custom_params.items():
|
||||||
|
if isinstance(value, str):
|
||||||
|
try:
|
||||||
|
# Attempt to parse the string as JSON
|
||||||
|
custom_params[key] = json.loads(value)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
# If it fails, keep the original string
|
||||||
|
pass
|
||||||
|
|
||||||
# If there are custom parameters, we need to apply them first
|
# If there are custom parameters, we need to apply them first
|
||||||
params = deep_update(params, custom_params)
|
params = deep_update(params, custom_params)
|
||||||
|
|
||||||
@ -110,6 +120,16 @@ def apply_model_params_to_body_ollama(params: dict, form_data: dict) -> dict:
|
|||||||
|
|
||||||
custom_params = params.pop("custom_params", {})
|
custom_params = params.pop("custom_params", {})
|
||||||
if custom_params:
|
if custom_params:
|
||||||
|
# Attempt to parse custom_params if they are strings
|
||||||
|
for key, value in custom_params.items():
|
||||||
|
if isinstance(value, str):
|
||||||
|
try:
|
||||||
|
# Attempt to parse the string as JSON
|
||||||
|
custom_params[key] = json.loads(value)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
# If it fails, keep the original string
|
||||||
|
pass
|
||||||
|
|
||||||
# If there are custom parameters, we need to apply them first
|
# If there are custom parameters, we need to apply them first
|
||||||
params = deep_update(params, custom_params)
|
params = deep_update(params, custom_params)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user