MCPcopy
hub / github.com/mudler/LocalAI / coerce_param_value

Function coerce_param_value

backend/python/qwen-tts/backend.py:50–67  ·  view source on GitHub ↗

Coerce a string param value (from the TTSRequest.params map, which is string-typed on the wire) into the most specific Python type the model generation kwargs expect: bool, int, float, else the original string.

(value)

Source from the content-addressed store, hash-verified

48
49
50def coerce_param_value(value):
51 """Coerce a string param value (from the TTSRequest.params map, which is
52 string-typed on the wire) into the most specific Python type the model
53 generation kwargs expect: bool, int, float, else the original string."""
54 if not isinstance(value, str):
55 return value
56 lowered = value.strip().lower()
57 if lowered in ("true", "false"):
58 return lowered == "true"
59 try:
60 return int(value)
61 except ValueError:
62 pass
63 try:
64 return float(value)
65 except ValueError:
66 pass
67 return value
68
69
70_ONE_DAY_IN_SECONDS = 60 * 60 * 24

Callers 1

TTSMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected