You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python: Add step03 getting started with processes samples. (microsoft#9427)
### Motivation and Context
Add step03 getting started with processes samples to show how to create
kernel processes related to food preparation and food ordering tasks.
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
### Description
Add step03 getting started with processes samples.
- Make `emit_event` async
- Simplify how one can create an event to emit by allowing the
process_event to be a string, along with kwargs:
```
await context.emit_event(process_event=CommonEvents.StartBRequested.value, data="Get Going B")
```
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
Copy file name to clipboardexpand all lines: python/samples/getting_started_with_processes/README.md
+184-1
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,9 @@ The getting started with agents examples include:
20
20
21
21
Example|Description
22
22
---|---
23
-
[step01_processes](../getting_started_with_processes/step01_processes.py)|How to create a simple process with a loop and a conditional exit
23
+
[step01_processes](../getting_started_with_processes/step01/step01_processes.py)|How to create a simple process with a loop and a conditional exit|
24
+
[step03a_food_preparation](../getting_started_with_processes/step03/step03a_food_preparation.py)|Showcasing reuse of steps, creation of processes, spawning of multiple events, use of stateful steps with food preparation samples.
25
+
[step03b_food_ordering](../getting_started_with_processes/step03/step03b_food_ordering.py)|Showcasing use of subprocesses as steps, spawning of multiple events conditionally reusing the food preparation samples.
24
26
25
27
### step01_processes
26
28
@@ -32,6 +34,187 @@ flowchart LR
32
34
AssistantResponse--> UserInput
33
35
```
34
36
37
+
### step03a_food_preparation
38
+
39
+
This tutorial contains a set of food recipes associated with the Food Preparation Processes of a restaurant.
40
+
41
+
The following recipes for preparation of Order Items are defined as SK Processes:
The processes in this subsection contain the following modifications/additions to previously used food preparation processes:
110
+
111
+
- The `Gather Ingredients Step` is now stateful and has a predefined number of initial ingredients that are used as orders are prepared. When there are no ingredients left, it emits the `Out of Stock Event`.
112
+
- The `Cut Food Step` is now a stateful component which has a `Knife Sharpness State` that tracks the Knife Sharpness.
113
+
- As the `Slice Food` and `Chop Food` Functions get invoked, the Knife Sharpness deteriorates.
114
+
- The `Cut Food Step` has an additional input function `Sharpen Knife Function`.
115
+
- The new `Sharpen Knife Function` sharpens the knife and increases the Knife Sharpness - Knife Sharpness State.
116
+
- From time to time, the `Cut Food Step`'s functions `SliceFood` and `ChopFood` will fail and emit a `Knife Needs Sharpening Event` that then triggers the `Sharpen Knife Function`.
117
+
118
+
119
+
###### Potato Fries Preparation With Knife Sharpening and Ingredient Stock Process
120
+
121
+
The following processes is a modification on the process [Potato Fries Preparation](#potato-fries-preparation-process)
GatherIngredientsStep -->| Chop Fish <br/> _Ingredients Gathered_ | CutStep
186
+
PrepareFriedFishEvent --> GatherIngredientsStep
187
+
```
188
+
189
+
### step03b_food_ordering
190
+
191
+
#### Single Order Preparation Process
192
+
193
+
Now with the existing product preparation processes, they can be used to create an even more complex process that can decide what product order to dispatch.
194
+
195
+
```mermaid
196
+
graph TD
197
+
PrepareSingleOrderEvent([Prepare Single Order <br/> Event])
198
+
SingleOrderReadyEvent([Single Order <br/> Ready Event])
199
+
OrderPackedEvent([Order Packed <br/> Event])
200
+
201
+
DispatchOrderStep{{Dispatch <br/> Order Step}}
202
+
FriedFishStep[[Fried Fish <br/> Process Step]]
203
+
PotatoFriesStep[[Potato Fries <br/> Process Step]]
204
+
FishSandwichStep[[Fish Sandwich <br/> Process Step]]
205
+
FishAndChipsStep[[Fish & Chips <br/> Process Step]]
0 commit comments