Skip to content

parallel node execution #228

@genatin

Description

@genatin

I want to create a node in which a picture will be generated in parallel, how do I do this?

async def handle_generate_image(
    args: FlowArgs, flow_manager: FlowManager
) -> tuple[None, NodeConfig]:
    """Handler for start_interview function"""
    logger.info("----> Generating image...")
    async with aiohttp.ClientSession() as session:
        image_gen_service = OpenAIImageGenService(
            api_key=config.openai_api_key,
            aiohttp_session=session,
            image_size="1024x1024",
        )
        async for i in image_gen_service.run_image_gen(
            "draw gnomes having fun in the forest"
        ):  
            await flow_manager.task.queue_frame(i)
    return None, None


generate_image_func = FlowsFunctionSchema(
    handler=handle_generate_image,
    name="generate_image",
    description="Generate an image based on a context story",
    properties={},
    required=[],
)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions