File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -762,18 +762,22 @@ def parse_ollama_modelfile(model_text):
762762 return data
763763
764764
765- def convert_logit_bias_input_to_json (user_input ) -> Optional [str ]:
766- if user_input :
767- logit_bias_pairs = user_input .split ("," )
768- logit_bias_json = {}
769- for pair in logit_bias_pairs :
770- token , bias = pair .split (":" )
771- token = str (token .strip ())
772- bias = int (bias .strip ())
773- bias = 100 if bias > 100 else - 100 if bias < - 100 else bias
774- logit_bias_json [token ] = bias
775- return json .dumps (logit_bias_json )
776- return None
765+ def convert_logit_bias_input_to_json (logit_bias_input ) -> Optional [str ]:
766+ if not logit_bias_input :
767+ return None
768+
769+ if isinstance (logit_bias_input , dict ):
770+ return json .dumps (logit_bias_input )
771+
772+ logit_bias_pairs = logit_bias_input .split ("," )
773+ logit_bias_json = {}
774+ for pair in logit_bias_pairs :
775+ token , bias = pair .split (":" )
776+ token = str (token .strip ())
777+ bias = int (bias .strip ())
778+ bias = 100 if bias > 100 else - 100 if bias < - 100 else bias
779+ logit_bias_json [token ] = bias
780+ return json .dumps (logit_bias_json )
777781
778782
779783def freeze (value ):
You can’t perform that action at this time.
0 commit comments