core.response_executor

Orchestration helper for prompt execution with conditions and structured output.

Orchestration helper for prompt execution with conditions and structured output.

class ResponseExecutor(prompt_builder, condition_evaluator_fn, results_by_name_fn)[source]

Bases: object

Orchestrates prompt resolution, condition evaluation, and LLM dispatch.

Constructed once in FFAI.__init__ with callables bound to the FFAI instance. The execute method handles the synchronous path used by generate_response; execute_async handles the async path used by execute_graph.

Parameters:
  • prompt_builder (Callable[..., tuple[str, set[str]]]) – Bound PromptBuilder.build_prompt method.

  • condition_evaluator_fn (Callable[[str, dict[str, dict[str, Any]]], tuple[bool, str | None, str | None]]) – Callable taking (condition_str, results_by_name) and returning (should_execute, error, trace).

  • results_by_name_fn (Callable[[], dict[str, dict[str, Any]]]) – Callable returning dict[str, dict[str, Any]] mapping prompt names to their results.

execute(generate_fn, prompt, prompt_name, options, default_model, skip_condition=False)[source]

Synchronous execution path (used by generate_response).

Parameters:
Return type:

ExecutionResult

async execute_async(generate_fn, prompt, prompt_name, options, default_model, skip_condition=False)[source]

Async execution path (used by execute_graph).

Parameters:
Return type:

ExecutionResult

Classes

class ResponseExecutor(prompt_builder, condition_evaluator_fn, results_by_name_fn)[source]

Bases: object

Orchestrates prompt resolution, condition evaluation, and LLM dispatch.

Constructed once in FFAI.__init__ with callables bound to the FFAI instance. The execute method handles the synchronous path used by generate_response; execute_async handles the async path used by execute_graph.

Parameters:
  • prompt_builder (Callable[..., tuple[str, set[str]]]) – Bound PromptBuilder.build_prompt method.

  • condition_evaluator_fn (Callable[[str, dict[str, dict[str, Any]]], tuple[bool, str | None, str | None]]) – Callable taking (condition_str, results_by_name) and returning (should_execute, error, trace).

  • results_by_name_fn (Callable[[], dict[str, dict[str, Any]]]) – Callable returning dict[str, dict[str, Any]] mapping prompt names to their results.

execute(generate_fn, prompt, prompt_name, options, default_model, skip_condition=False)[source]

Synchronous execution path (used by generate_response).

Parameters:
Return type:

ExecutionResult

async execute_async(generate_fn, prompt, prompt_name, options, default_model, skip_condition=False)[source]

Async execution path (used by execute_graph).

Parameters:
Return type:

ExecutionResult