451ad685ae
* feat: integrate DeerFlow agent runner and improve stream handling * refactor: split DeerFlow stream flow and close stale client on reset * fix: enforce max_step and correct timeout type check * fix: harden DeerFlow config parsing and session lifecycle * fix: preserve third-party runner error semantics and harden image parsing * perf: bound DeerFlow values history and seen-id cache * refactor: improve deerflow stream semantics and client lifecycle * fix: harden third-party runner error semantics and fallback aggregation * refactor: reduce deerflow image log noise and lazy-init api session * perf: avoid unnecessary iterable copies in deerflow stream utils * refactor: centralize runner error key and clarify deerflow client lifecycle * refactor: simplify third-party runner output flow * fix: defer streaming runner cleanup and unify error mapping * fix: handle id-less values messages and redact stream payload logs * fix: improve deerflow error signaling and third-party runner flow * fix: support deerflow proxy and refine runner lifecycle * fix: tighten deerflow image validation and runner lifecycle * feat: support deerflow image output components * fix: harden runner stream cleanup and refactor deerflow config * fix: preserve deerflow done hook and simplify runner lifecycle * refactor: simplify third-party runner aggregation and lifecycle closing * fix: preserve first deerflow values payload and simplify runner flow * refactor: unify runner final resolution and harden deerflow close state * refactor: share int coercion and make deerflow close best effort * refactor: extract deerflow mappers and streamline third-party lifecycle * refactor: simplify third-party flow and harden sse flush parsing * fix: make deerflow runner close path best effort * refactor: simplify third-party orchestration and centralize deerflow keys * refactor: simplify third-party chunk flow and deerflow finalization * fix: harden deerflow stream parsing and simplify runner lifecycle * refactor: remove redundant deerflow values text assignment * fix: improve deerflow timeout diagnostics and image input feedback * refactor: flatten third-party runner lifecycle and aggregation * chore: use deerflow official remote svg icon * chore: remove unused deerflow local logo asset
65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
from astrbot.core import logger
|
|
|
|
|
|
def coerce_int_config(
|
|
value: object,
|
|
*,
|
|
default: int,
|
|
min_value: int | None = None,
|
|
field_name: str | None = None,
|
|
source: str = "config",
|
|
warn: bool = True,
|
|
) -> int:
|
|
label = f"'{field_name}'" if field_name else "value"
|
|
|
|
if isinstance(value, bool):
|
|
if warn:
|
|
logger.warning(
|
|
"%s %s should be numeric, got boolean. Fallback to %s.",
|
|
source,
|
|
label,
|
|
default,
|
|
)
|
|
parsed = default
|
|
elif isinstance(value, int):
|
|
parsed = value
|
|
elif isinstance(value, str):
|
|
try:
|
|
parsed = int(value.strip())
|
|
except ValueError:
|
|
if warn:
|
|
logger.warning(
|
|
"%s %s value '%s' is not numeric. Fallback to %s.",
|
|
source,
|
|
label,
|
|
value,
|
|
default,
|
|
)
|
|
parsed = default
|
|
else:
|
|
try:
|
|
parsed = int(value)
|
|
except (TypeError, ValueError):
|
|
if warn:
|
|
logger.warning(
|
|
"%s %s has unsupported type %s. Fallback to %s.",
|
|
source,
|
|
label,
|
|
type(value).__name__,
|
|
default,
|
|
)
|
|
parsed = default
|
|
|
|
if min_value is not None and parsed < min_value:
|
|
if warn:
|
|
logger.warning(
|
|
"%s %s=%s is below minimum %s. Fallback to %s.",
|
|
source,
|
|
label,
|
|
parsed,
|
|
min_value,
|
|
min_value,
|
|
)
|
|
parsed = min_value
|
|
return parsed
|