semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Python: Bug: The provided example is incorrect

Open qqq694637644 opened this issue 10 months ago • 5 comments

https://github.com/microsoft/semantic-kernel/blob/main/python/samples/getting_started_with_processes/step03/step03a_food_preparation.py

The shared and non - shared stateful ones you provided All are non - shared and stateful The two functions are exactly the same. You made a mistake. I almost thought I was seeing things. This is the result of the comparison by Beyond Compare

function async def use_prepare_stateful_fried_fish_process_no_shared_state():

function async def use_prepare_stateful_fried_fish_process_shared_state():

function async def use_prepare_stateful_potato_fries_process_shared_state(): Image

qqq694637644 avatar Apr 09 '25 04:04 qqq694637644

I guess the correct example should be like this


    process_builder = PotatoFriesProcess.create_process_with_stateful_steps()
    external_trigger_event = PotatoFriesProcess.ProcessEvents.PreparePotatoFries

    kernel = _create_kernel_with_chat_completion("sample")
    process_instance = process_builder.build()

    print(f"=== Start SK Process '{process_builder.name}' ===")
    await execute_process_with_state(
        process_instance, kernel, external_trigger_event, "Order 1"
    )
    await execute_process_with_state(
        process_instance, kernel, external_trigger_event, "Order 2"
    )
    await execute_process_with_state(
        process_instance, kernel, external_trigger_event, "Order 3"
    )
    print(f"=== End SK Process '{process_builder.name}' ===")

qqq694637644 avatar Apr 09 '25 04:04 qqq694637644

Feel free to make a PR with a fix, @qqq694637644. We haven't completed the actual work to handle state with processes (where they can be serialized and deserialized), which is why you'll probably see some "thin" handling of state right now. But if there are other actual fixes, please do go ahead and make a PR. We'd appreciate the contributions. Thanks.

moonbox3 avatar Apr 09 '25 10:04 moonbox3

Feel free to make a PR with a fix, @qqq694637644. We haven't completed the actual work to handle state with processes (where they can be serialized and deserialized), which is why you'll probably see some "thin" handling of state right now. But if there are other actual fixes, please do go ahead and make a PR. We'd appreciate the contributions. Thanks.

Okay, I'll submit a PR later. May I ask if you'll consider adding a flowchart feature similar to LangGraph in processBuild in the future? Writing the ProcessBuild process is too mentally taxing.

qqq694637644 avatar Apr 09 '25 10:04 qqq694637644

Thank you for the feedback. We are working on a declarative spec that will allow one to create a process in a “no code/low code” way, potentially similar to what you referenced for LG.

moonbox3 avatar Apr 09 '25 11:04 moonbox3

This is further handled in #11637.

moonbox3 avatar Apr 22 '25 02:04 moonbox3