fixed null stop

This commit is contained in:
Concedo 2025-05-01 17:07:17 +08:00
parent ed938a2fc6
commit fc255cf50c

View file

@ -2042,6 +2042,7 @@ def transform_genparams(genparams, api_format):
presence_penalty = genparams.get('presence_penalty', genparams.get('frequency_penalty', 0.0))
genparams["presence_penalty"] = tryparsefloat(presence_penalty,0.0)
# openai allows either a string or a list as a stop sequence
if genparams.get('stop',[]) is not None:
if isinstance(genparams.get('stop',[]), list):
genparams["stop_sequence"] = genparams.get('stop', [])
else:
@ -2240,6 +2241,7 @@ ws ::= | " " | "\n" [ \t]{0,20}
ollamasysprompt = genparams.get('system', "")
ollamabodyprompt = f"{detokstr}{user_message_start}{genparams.get('prompt', '')}{assistant_message_start}"
ollamaopts = genparams.get('options', {})
if genparams.get('stop',[]) is not None:
genparams["stop_sequence"] = genparams.get('stop', [])
if "num_predict" in ollamaopts:
genparams["max_length"] = ollamaopts.get('num_predict', args.defaultgenamt)