Fix LLM validation and dashboard health hot paths
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
# [SECTION: IMPORTS]
|
||||
# [SECTION: IMPORTS]
|
||||
from typing import Dict, Any, Callable
|
||||
from typing import Dict, Any, Callable, Optional
|
||||
from .task_logger import TaskLogger
|
||||
from ..logger import belief_scope
|
||||
# [/SECTION]
|
||||
@@ -58,11 +58,13 @@ class TaskContext:
|
||||
task_id: str,
|
||||
add_log_fn: Callable,
|
||||
params: Dict[str, Any],
|
||||
default_source: str = "plugin"
|
||||
default_source: str = "plugin",
|
||||
background_tasks: Optional[Any] = None,
|
||||
):
|
||||
with belief_scope("__init__"):
|
||||
self._task_id = task_id
|
||||
self._params = params
|
||||
self._background_tasks = background_tasks
|
||||
self._logger = TaskLogger(
|
||||
task_id=task_id,
|
||||
add_log_fn=add_log_fn,
|
||||
@@ -102,6 +104,16 @@ class TaskContext:
|
||||
with belief_scope("params"):
|
||||
return self._params
|
||||
# [/DEF:params:Function]
|
||||
|
||||
# [DEF:background_tasks:Function]
|
||||
# @PURPOSE: Expose optional background task scheduler for plugins that dispatch deferred side effects.
|
||||
# @PRE: TaskContext must be initialized.
|
||||
# @POST: Returns BackgroundTasks-like object or None.
|
||||
@property
|
||||
def background_tasks(self) -> Optional[Any]:
|
||||
with belief_scope("background_tasks"):
|
||||
return self._background_tasks
|
||||
# [/DEF:background_tasks:Function]
|
||||
|
||||
# [DEF:get_param:Function]
|
||||
# @PURPOSE: Get a specific parameter value with optional default.
|
||||
@@ -128,7 +140,8 @@ class TaskContext:
|
||||
task_id=self._task_id,
|
||||
add_log_fn=self._logger._add_log,
|
||||
params=self._params,
|
||||
default_source=source
|
||||
default_source=source,
|
||||
background_tasks=self._background_tasks,
|
||||
)
|
||||
# [/DEF:create_sub_context:Function]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user