Signed-off-by: amy-why-3459 <wuhaiyan17@huawei.com>
This commit is contained in:
1 parent
eb1abbadf8
commit
882bf8bc95
53 files changed
+3438
-633
No files matched your search
@@ -179,6 +179,7 @@ class DuplexModelPlugin(ABC):
|
||||
two halves is impossible by construction.
|
||||
"""
|
||||
|
||||
projects_intermediate_outputs: bool = False
|
||||
plugin_id: str = ""
|
||||
private_runtime_config_keys: frozenset[str] = frozenset()
|
||||
#: Samples per silence unit the runner appends to keep a model turn going.
|
||||
@@ -199,6 +200,16 @@ class DuplexModelPlugin(ABC):
|
||||
defaults: tuple[object, ...],
|
||||
) -> tuple[object, ...]: ...
|
||||
|
||||
def prepare_prompt_config(
|
||||
self, config: dict[str, object], *, state: DuplexModelSessionState, payload: dict[str, object]
|
||||
) -> dict[str, object]:
|
||||
"""Add model-owned context before planning an append on the session loop."""
|
||||
return config
|
||||
|
||||
async def prepare_append_plan(self, **kwargs) -> DuplexAppendPlan:
|
||||
"""Prepare a plan; plugins may offload expensive work on owned snapshots."""
|
||||
return self.plan_append(**kwargs)
|
||||
|
||||
@abstractmethod
|
||||
def plan_append(
|
||||
self,
|
||||
@@ -312,10 +323,16 @@ def payload_turn_id(payload: object) -> int | None:
|
||||
|
||||
|
||||
def coerce_int(value: object) -> int | None:
|
||||
try:
|
||||
return int(value) if value is not None else None
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
if isinstance(value, bool):
|
||||
return int(value)
|
||||
if isinstance(value, int):
|
||||
return value
|
||||
if isinstance(value, float | str | bytes | bytearray):
|
||||
try:
|
||||
return int(value)
|
||||
except (TypeError, ValueError, OverflowError):
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
||||
Reference in new issue
Block a user