Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.
Plan: Fully align deep_flow content generators with ContentGeneratorProtocol
Context
The ContentGeneratorProtocol (pipelex/cogt/content_generation/content_generator_protocol.py) evolved independently from the Temporal deep_flow implementations. The deep_flow files have broken references, wrong method names/signatures, missing methods, and wrong return types. The goal is full alignment — no pyright: ignore[reportIncompatibleMethodOverride] comments needed.
Reference files (read-only)
pipelex/cogt/content_generation/content_generator_protocol.py— the protocol to matchpipelex/cogt/content_generation/content_generator.py— non-Temporal reference implementationpipelex/cogt/content_generation/generated_content_factory.py—GeneratedContentFactoryfor post-processingpipelex/cogt/content_generation/assignment_models.py—TemplatingAssignmentmodel (fields:context,template,templating_style,category)pipelex/cogt/templating/template_category.py—TemplateCategoryenumpipelex/cogt/templating/templating_style.py—TemplatingStylemodelpipelex/cogt/llm/llm_prompt_template.py—make_for_structuring_from_preliminary_text()class methodpipelex/deep_flow/tprl/workflow_caller.py—WorkflowExecutorbase class
Files to modify
pipelex/cogt/content_generation/content_generator_protocol.py— addwfidparam to all applicable methodspipelex/cogt/content_generation/content_generator.py— addwfidparam (unused, for protocol compat)pipelex/deep_flow/tprl_content_generation/content_generator_child.pypipelex/deep_flow/tprl_content_generation/content_generator_top.pypipelex/deep_flow/tprl_content_generation/content_generator_child_factory.pypipelex/deep_flow/tprl_content_generation/content_generator_top_factory.pypipelex/deep_flow/tprl_content_generation/wf_make_extract.py— rename classWfMakeOcr→WfMakeExtract
Changes
1. Add wfid to ContentGeneratorProtocol
Add wfid: str | None = None as the last parameter to all methods that the deep_flow implementations use it with:
make_llm_textmake_object_directmake_text_then_objectmake_object_list_directmake_text_then_object_listmake_single_imagemake_image_listmake_templated_textmake_extract_pagesmake_render_page_views
This keeps wfid optional (defaulting to None) so the non-Temporal ContentGenerator doesn't break.
2. Add wfid to non-Temporal ContentGenerator
Add wfid: str | None = None parameter to all the same methods in content_generator.py. The param is unused in the non-Temporal implementation but satisfies the protocol.
3. Rename WfMakeOcr → WfMakeExtract in wf_make_extract.py
The class is still named WfMakeOcr despite the file being renamed. Rename to WfMakeExtract. The @workflow.defn(name="wf_make_extract") string is already correct.
Update imports in content_generator_child.py and content_generator_top.py.
4. Add generated_content_factory to ContentGeneratorChild
Add __init__ that accepts generated_content_factory: GeneratedContentFactory and stores it as self._generated_content_factory, calling super().__init__(**kwargs).
ContentGeneratorChild inherits from WorkflowExecutor which has __init__(self, temporal_client, should_auto_connect_temporal, worker_environment, **kwargs) → WorkflowCaller.__init__(self, task_queue, workflow_execution_timeout, ...). So the child class init should be:
def __init__(self, generated_content_factory: GeneratedContentFactory, **kwargs: Any) -> None:
super().__init__(**kwargs)
self._generated_content_factory = generated_content_factory
5. Add generated_content_factory to ContentGeneratorTop
Same pattern as child.
6. Update factories to pass generated_content_factory
ContentGeneratorChildFactory.make_content_generator_child()— addgenerated_content_factory: GeneratedContentFactoryparameter and pass throughContentGeneratorTopFactory.make_content_generator_top()— addgenerated_content_factory: GeneratedContentFactoryparameter and pass through
7. Rename make_jinja2_text → make_templated_text and align signature
In both child and top, rename and update signature to match protocol:
@override
async def make_templated_text(
self,
context: dict[str, Any],
template: str,
templating_style: TemplatingStyle | None = None,
template_category: TemplateCategory | None = None,
wfid: str | None = None,
) -> str:
Update TemplatingAssignment construction:
templating_assignment = TemplatingAssignment(
context=context,
template=template,
templating_style=templating_style,
category=template_category or TemplateCategory.BASIC,
)
Remove PromptingTarget import from both files. Add TemplatingStyle import. Remove Jinja2TemplateCategory references.
8. Rename make_extract_extract_pages → make_extract_pages and change return type
Change return type to list[PageContent]. After getting ExtractOutput from the workflow, call:
return await self.make_page_contents(job_metadata=job_metadata, extract_output=extract_output)
Keep extract_job_params and extract_job_config as required params (matching protocol).
9. Change make_single_image return type to ImageContent
After getting GeneratedImageRawDetails from the workflow, convert:
return await self.make_image_content(
job_metadata=job_metadata,
generated_image_raw_details=generated_image,
img_gen_prompt=img_gen_prompt,
)
10. Change make_image_list return type to list[ImageContent]
After getting list[GeneratedImageRawDetails], convert each:
return [
await self.make_image_content(
job_metadata=job_metadata,
generated_image_raw_details=raw_details,
img_gen_prompt=img_gen_prompt,
)
for raw_details in generated_image_list
]
11. Add make_image_content method to both
Same implementation as non-Temporal ContentGenerator:
@override
async def make_image_content(
self,
job_metadata: JobMetadata,
generated_image_raw_details: GeneratedImageRawDetails,
img_gen_prompt: ImgGenPrompt | None,
) -> ImageContent:
image_content = await self._generated_content_factory.make_image_content(
primary_id=job_metadata.user_id,
secondary_id=job_metadata.pipeline_run_id,
raw_details=generated_image_raw_details,
)
if img_gen_prompt:
image_content.source_prompt = img_gen_prompt.positive_text
image_content.source_negative_prompt = img_gen_prompt.negative_text
return image_content
12. Add make_page_contents method to both
@override
async def make_page_contents(
self,
job_metadata: JobMetadata,
extract_output: ExtractOutput,
) -> list[PageContent]:
return await self._generated_content_factory.make_page_contents(
primary_id=job_metadata.user_id,
secondary_id=job_metadata.pipeline_run_id,
extract_output=extract_output,
)
13. Add make_render_page_views method to both
Same as non-Temporal version, using pypdfium2_renderer:
@override
async def make_render_page_views(
self,
job_metadata: JobMetadata,
extract_input: ExtractInput,
extract_handle: str,
extract_job_params: ExtractJobParams | None = None,
extract_job_config: ExtractJobConfig | None = None,
wfid: str | None = None,
) -> list[ImageContent]:
if not extract_input.document_uri:
msg = "PDF URI is required to render page views"
raise ValueError(msg)
job_params = extract_job_params or ExtractJobParams.make_default_extract_job_params()
page_views_dpi = job_params.page_views_dpi or get_config().cogt.extract_config.default_page_views_dpi
page_view_images = await pypdfium2_renderer.render_pdf_pages_from_uri(
pdf_uri=extract_input.document_uri, dpi=page_views_dpi
)
return [
await self.make_image_content(
job_metadata=job_metadata,
generated_image_raw_details=GeneratedImageRawDetails.make_from_pil_image(
pil_image=page_view_image,
image_format=ImageFormat.PNG,
),
img_gen_prompt=None,
)
for page_view_image in page_view_images
]
14. Fix LLMPromptTemplate method name in content_generator_top.py
Lines 138 and 217: for_structure_from_preliminary_text() → make_for_structuring_from_preliminary_text()
15. Remove all pyright: ignore[reportIncompatibleMethodOverride] comments
With full alignment, these are no longer needed.
16. Fix imports in both deep_flow files
Add:
from pipelex.cogt.content_generation.generated_content_factory import GeneratedContentFactoryfrom pipelex.cogt.templating.templating_style import TemplatingStylefrom pipelex.core.stuffs.image_content import ImageContentfrom pipelex.core.stuffs.page_content import PageContentfrom pipelex.tools.misc.image_utils import ImageFormatfrom pipelex.tools.pdf.pypdfium2_renderer import pypdfium2_renderer
Remove:
from pipelex.cogt.model_backends.prompting_target import PromptingTarget(child)from pipelex.tools.templating.templating_models import PromptingTarget(top — wrong path anyway)
Fix:
WfMakeOcr→WfMakeExtractin import fromwf_make_extract
Verification
Run make agent-check to verify no new lint/type errors are introduced.