chore: import upstream snapshot with attribution
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) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:39:25 +08:00
commit db620d33df
5151 changed files with 925932 additions and 0 deletions
@@ -0,0 +1,94 @@
# Function Tools Workflow
This sample demonstrates an agent with function tools responding to user queries about a restaurant menu.
## Overview
The workflow showcases:
- **Function Tools**: Agent equipped with tools to query menu data
- **Real Foundry-backed agent**: Uses `FoundryChatClient` to create an agent with tools
- **Agent Registration**: Shows how to register agents with the `WorkflowFactory`
## Tools
The MenuAgent has access to these function tools:
| Tool | Description |
|------|-------------|
| `get_menu()` | Returns all menu items with category, name, and price |
| `get_specials()` | Returns today's special items |
| `get_item_price(name)` | Returns the price of a specific item |
## Menu Data
```
Soups:
- Clam Chowder - $4.95 (Special)
- Tomato Soup - $4.95
Salads:
- Cobb Salad - $9.99
- House Salad - $4.95
Drinks:
- Chai Tea - $2.95 (Special)
- Soda - $1.95
```
## Prerequisites
- Microsoft Foundry configured with required environment variables
- Authentication via azure-identity (run `az login` before executing)
## Usage
```bash
python main.py
```
## Example Output
```
Loaded workflow: function-tools-workflow
============================================================
Restaurant Menu Assistant
============================================================
[Bot]: Welcome to the Restaurant Menu Assistant!
[Bot]: Today's soup special is the Clam Chowder for $4.95!
============================================================
Session Complete
============================================================
```
## How It Works
1. Create a Foundry chat client
2. Create an agent with instructions and function tools
3. Register the agent with the workflow factory
4. Load the workflow YAML and run it with `run()` and `stream=True`
```python
# Create the agent with tools
client = FoundryChatClient(
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
model=os.environ["FOUNDRY_MODEL"],
credential=AzureCliCredential(),
)
menu_agent = client.as_agent(
name="MenuAgent",
instructions="You are a helpful restaurant menu assistant...",
tools=[get_menu, get_specials, get_item_price],
)
# Register with the workflow factory
factory = WorkflowFactory(execution_mode="graph")
factory.register_agent("MenuAgent", menu_agent)
# Load and run the workflow
workflow = factory.create_workflow_from_yaml_path(workflow_path)
async for event in workflow.run(inputs={"userInput": "What is the soup of the day?"}, stream=True):
...
```