The one non-streaming facade dispatch path.
dispatch
async
dispatch(kernel: Any, prepare: Callable[[str, type[BaseModel] | None], InvocationPlan], request: TurnRequest, output_type: type[BaseModel] | None, capabilities: tuple[Any, ...]) -> AgentResult[Any]
Prepare once and send every non-streaming request through the kernel.
Source code in src/symfonic/agent/facade_dispatch.py
| async def dispatch(
kernel: Any,
prepare: Callable[[str, type[BaseModel] | None], InvocationPlan],
request: TurnRequest,
output_type: type[BaseModel] | None,
capabilities: tuple[Any, ...],
) -> AgentResult[Any]:
"""Prepare once and send every non-streaming request through the kernel."""
from symfonic.agent.facade_args import receipt_capability
_refuse_fenced_history(request, capabilities)
memory = receipt_capability(capabilities)
plan = prepare(request.prompt, output_type)
if memory is not None:
from symfonic.agent.receipt_dispatch import run
return await run(plan, request, memory)
return await kernel.run(plan, request)
|
stream
stream(kernel: Any, prepare: Callable[[str, type[BaseModel] | None], InvocationPlan], request: TurnRequest, output_type: type[BaseModel] | None, capabilities: tuple[Any, ...]) -> AsyncIterator[AgentEvent]
Prepare once and hand the request to the shared streaming kernel.
Source code in src/symfonic/agent/facade_dispatch.py
| def stream(
kernel: Any,
prepare: Callable[[str, type[BaseModel] | None], InvocationPlan],
request: TurnRequest,
output_type: type[BaseModel] | None,
capabilities: tuple[Any, ...],
) -> AsyncIterator[AgentEvent]:
"""Prepare once and hand the request to the shared streaming kernel."""
from symfonic.agent.facade_args import receipt_capability
_refuse_fenced_history(request, capabilities)
memory = receipt_capability(capabilities)
plan = prepare(request.prompt, output_type)
if memory is not None:
from symfonic.agent.receipt_dispatch import stream as receipt_stream
return receipt_stream(plan, request, memory)
return kernel.stream(plan, request)
|