mirror of
https://github.com/open-webui/open-webui
synced 2025-06-23 02:16:52 +00:00
Change the opt dictionary to a mappings dictionary with appropriate casts
This is to bring consistency with apply_model_params_to_body_openai. Both now use a mapping dictionary then call and return apply_model_params_to_body directly.
This commit is contained in:
parent
fa885c3346
commit
5701d6d333
@ -77,40 +77,38 @@ def apply_model_params_to_body_ollama(params: dict, form_data: dict) -> dict:
|
|||||||
params[value] = params[key]
|
params[value] = params[key]
|
||||||
del params[key]
|
del params[key]
|
||||||
|
|
||||||
opts = [
|
# See https://github.com/ollama/ollama/blob/main/docs/api.md#request-8
|
||||||
"temperature",
|
mappings = {
|
||||||
"top_p",
|
"temperature": float,
|
||||||
"seed",
|
"top_p": float,
|
||||||
"mirostat",
|
"seed": lambda x: x,
|
||||||
"mirostat_eta",
|
"mirostat": int,
|
||||||
"mirostat_tau",
|
"mirostat_eta": float,
|
||||||
"num_ctx",
|
"mirostat_tau": float,
|
||||||
"num_batch",
|
"num_ctx": int,
|
||||||
"num_keep",
|
"num_batch": int,
|
||||||
"num_predict",
|
"num_keep": int,
|
||||||
"repeat_last_n",
|
"num_predict": int,
|
||||||
"top_k",
|
"repeat_last_n": int,
|
||||||
"min_p",
|
"top_k": int,
|
||||||
"typical_p",
|
"min_p": float,
|
||||||
"repeat_penalty",
|
"typical_p": float,
|
||||||
"presence_penalty",
|
"repeat_penalty": float,
|
||||||
"frequency_penalty",
|
"presence_penalty": float,
|
||||||
"penalize_newline",
|
"frequency_penalty": float,
|
||||||
"stop",
|
"penalize_newline": bool,
|
||||||
"numa",
|
"stop": lambda x: [bytes(s, "utf-8").decode("unicode_escape") for s in x],
|
||||||
"num_gpu",
|
"numa": bool,
|
||||||
"main_gpu",
|
"num_gpu": int,
|
||||||
"low_vram",
|
"main_gpu": int,
|
||||||
"vocab_only",
|
"low_vram": bool,
|
||||||
"use_mmap",
|
"vocab_only": bool,
|
||||||
"use_mlock",
|
"use_mmap": bool,
|
||||||
"num_thread",
|
"use_mlock": bool,
|
||||||
|
"num_thread": int,
|
||||||
|
}
|
||||||
|
|
||||||
]
|
return apply_model_params_to_body(params, form_data, mappings)
|
||||||
mappings = {i: lambda x: x for i in opts}
|
|
||||||
form_data = apply_model_params_to_body(params, form_data, mappings)
|
|
||||||
|
|
||||||
return form_data
|
|
||||||
|
|
||||||
|
|
||||||
def convert_messages_openai_to_ollama(messages: list[dict]) -> list[dict]:
|
def convert_messages_openai_to_ollama(messages: list[dict]) -> list[dict]:
|
||||||
|
Loading…
Reference in New Issue
Block a user