MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / resolve_timeout

Function resolve_timeout

openkb/config.py:147–176  ·  view source on GitHub ↗

Resolve the optional ``timeout:`` key to a finite positive number of seconds. Returns ``None`` (use LiteLLM's default) when absent or invalid; rejects bools and ``nan``/``inf``, warning when present but unusable.

(config: dict)

Source from the content-addressed store, hash-verified

145
146
147def resolve_timeout(config: dict) -> float | None:
148 """Resolve the optional ``timeout:`` key to a finite positive number of seconds.
149
150 Returns ``None`` (use LiteLLM's default) when absent or invalid; rejects
151 bools and ``nan``/``inf``, warning when present but unusable.
152 """
153 raw = config.get("timeout")
154 if raw is None:
155 return None
156 if isinstance(raw, bool) or not isinstance(raw, (int, float, str)):
157 logger.warning(
158 "config: 'timeout' must be a positive number of seconds, got %s — ignoring it.",
159 type(raw).__name__,
160 )
161 return None
162 try:
163 value = float(raw)
164 except (TypeError, ValueError):
165 logger.warning(
166 "config: 'timeout' must be a positive number of seconds, got %r — ignoring it.",
167 raw,
168 )
169 return None
170 if not math.isfinite(value) or value <= 0:
171 logger.warning(
172 "config: 'timeout' must be a finite positive number of seconds, got %s — ignoring it.",
173 value,
174 )
175 return None
176 return value
177
178
179def resolve_litellm_settings(config: dict) -> dict[str, Any]:

Calls 1

getMethod · 0.45