chore: import upstream snapshot with attribution
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
# Conditional Workflow Sample
|
||||
|
||||
This sample demonstrates control flow with conditions:
|
||||
- If/else branching
|
||||
- Nested conditions
|
||||
|
||||
## Files
|
||||
|
||||
- `workflow.yaml` - The workflow definition
|
||||
- `main.py` - Python code to execute the workflow
|
||||
|
||||
## Running
|
||||
|
||||
```bash
|
||||
python main.py
|
||||
```
|
||||
|
||||
## What It Does
|
||||
|
||||
1. Takes a user's age as input
|
||||
2. Uses conditions to determine an age category
|
||||
3. Sends appropriate messages based on the category
|
||||
@@ -0,0 +1,52 @@
|
||||
# Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
"""
|
||||
Run the conditional workflow sample.
|
||||
|
||||
Usage:
|
||||
python main.py
|
||||
|
||||
Demonstrates conditional branching based on age input.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from agent_framework.declarative import WorkflowFactory
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
"""Run the conditional workflow with various age inputs."""
|
||||
# Create a workflow factory
|
||||
factory = WorkflowFactory()
|
||||
|
||||
# Load the workflow from YAML
|
||||
workflow_path = Path(__file__).parent / "workflow.yaml"
|
||||
workflow = factory.create_workflow_from_yaml_path(workflow_path)
|
||||
|
||||
print(f"Loaded workflow: {workflow.name}")
|
||||
print("-" * 40)
|
||||
|
||||
# Print out the executors in this workflow
|
||||
print("\nExecutors in workflow:")
|
||||
for executor_id, executor in workflow.executors.items():
|
||||
print(f" - {executor_id}: {type(executor).__name__}")
|
||||
print("-" * 40)
|
||||
|
||||
# Test with different ages
|
||||
test_ages = [8, 15, 35, 70]
|
||||
|
||||
for age in test_ages:
|
||||
print(f"\n--- Testing with age: {age} ---")
|
||||
|
||||
# Run the workflow with age input
|
||||
result = await workflow.run({"age": age})
|
||||
for output in result.get_outputs():
|
||||
print(f" Output: {output}")
|
||||
|
||||
print("\n" + "-" * 40)
|
||||
print("Workflow completed for all test cases!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -0,0 +1,69 @@
|
||||
name: conditional-workflow
|
||||
description: Demonstrates conditional branching based on user input
|
||||
|
||||
# Declare expected inputs with their types
|
||||
inputs:
|
||||
age:
|
||||
type: integer
|
||||
description: The user's age in years
|
||||
|
||||
actions:
|
||||
# Get the age from input
|
||||
- kind: SetValue
|
||||
id: get_age
|
||||
displayName: Get user age
|
||||
path: Local.age
|
||||
value: =inputs.age
|
||||
|
||||
# Determine age category using nested conditions
|
||||
- kind: If
|
||||
id: check_age
|
||||
displayName: Check age category
|
||||
condition: =Local.age < 13
|
||||
then:
|
||||
- kind: SetValue
|
||||
path: Local.category
|
||||
value: child
|
||||
- kind: SendActivity
|
||||
activity:
|
||||
text: "Welcome, young one! Here are some fun activities for kids."
|
||||
else:
|
||||
- kind: If
|
||||
condition: =Local.age < 20
|
||||
then:
|
||||
- kind: SetValue
|
||||
path: Local.category
|
||||
value: teenager
|
||||
- kind: SendActivity
|
||||
activity:
|
||||
text: "Hey there! Check out these cool things for teens."
|
||||
else:
|
||||
- kind: If
|
||||
condition: =Local.age < 65
|
||||
then:
|
||||
- kind: SetValue
|
||||
path: Local.category
|
||||
value: adult
|
||||
- kind: SendActivity
|
||||
activity:
|
||||
text: "Welcome! Here are our professional services."
|
||||
else:
|
||||
- kind: SetValue
|
||||
path: Local.category
|
||||
value: senior
|
||||
- kind: SendActivity
|
||||
activity:
|
||||
text: "Welcome! Enjoy our senior member benefits."
|
||||
|
||||
# Send a summary
|
||||
- kind: SendActivity
|
||||
id: summary
|
||||
displayName: Send category summary
|
||||
activity:
|
||||
text: '=Concat("You have been categorized as: ", Local.category)'
|
||||
|
||||
# Store result
|
||||
- kind: SetValue
|
||||
id: set_output
|
||||
path: Workflow.Outputs.category
|
||||
value: =Local.category
|
||||
Reference in New Issue
Block a user