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
Copy file name to clipboardExpand all lines: learn-pr/wwl-data-ai/build-agent-with-custom-tools/includes/3-custom-tool-options.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
Azure AI Agent Service offers various custom tools that enhance the capabilities and efficiency of your AI agents. These tools allow for scalable interoperability with various applications, making it easier to integrate with existing infrastructure or web services.
2
2
3
-
## Custom tool options available in Azure AI services
3
+
## Custom tool options available in Azure AI Agent Service
4
4
5
5
Azure AI services provide several custom tool options, including OpenAPI specified tools, Azure Functions, and function calling. These tools enable seamless integration with external APIs, event-driven applications, and custom functions.
Custom tools in an agent can be defined in a handful of ways, depending on what works best for your scenario. You may find that your company already has Azure Functions implemented for your agent to use, or a public OpenAPI specification gives your agent the functionality you're looking for.
2
2
3
-
## Agents function calling
3
+
## Function Calling
4
4
5
5
Function calling allows agents to execute predefined functions dynamically based on user input. This feature is ideal for scenarios where agents need to perform specific tasks, such as retrieving data or processing user queries, and can be done in code from within the agent. Your function may call out to other APIs to get additional information or initiate a program.
The agent can now call `recent_snowfall` dynamically when it determines that the prompt requires information that can be retrieved by the function.
46
+
The agent can now call *recent_snowfall* dynamically when it determines that the prompt requires information that can be retrieved by the function.
47
47
48
-
## OpenAPI defined tools
48
+
## Azure Functions
49
+
50
+
Azure Functions provide serverless computing capabilities for real-time processing. This integration is ideal for event-driven workflows, enabling agents to respond to triggers such as HTTP requests or queue messages.
51
+
52
+
### Example: Using Azure Functions with a queue trigger
53
+
54
+
First, develop and deploy your Azure Function. In this example, imagine we have a function in our Azure subscription to fetch the snowfall for a given location.
55
+
56
+
When your Azure Function is in place, integrate add it to the agent definition as an Azure Function tool:
instructions="You are a snowfall tracking agent. Use the provided Azure Function to fetch snowfall based on location.",
85
+
tools=azure_function_tool.definitions,
86
+
)
87
+
```
88
+
89
+
The agent can now send requests to the Azure Function via a storage queue and process the results.
90
+
91
+
## OpenAPI Specification
49
92
50
93
OpenAPI defined tools allow agents to interact with external APIs using standardized specifications. This approach simplifies API integration and ensures compatibility with various services. Azure AI Agent Service uses OpenAPI 3.0 specified tools.
51
94
52
95
> [!TIP]
53
-
> Currently, three authentication types are supported with OpenAPI 3.0 tools: `anonymous`, `API key`, and `managed identity`.
96
+
> Currently, three authentication types are supported with OpenAPI 3.0 tools: *anonymous*, *API key*, and *managed identity*.
54
97
55
98
### Example: Using an OpenAPI specification
56
99
57
-
1.**Prepare the OpenAPI spec**: Create a JSON file (`snowfall_openapi.json`) describing the API.
58
-
59
-
```json
60
-
{
61
-
"openapi": "3.0.0",
62
-
"info": {
63
-
"title": "Snowfall API",
64
-
"version": "1.0.0"
65
-
},
66
-
"paths": {
67
-
"/snow": {
68
-
"get": {
69
-
"summary": "Get snowfall information",
70
-
"parameters": [
71
-
{
72
-
"name": "location",
73
-
"in": "query",
74
-
"required": true,
75
-
"schema": {
76
-
"type": "string"
77
-
}
100
+
First, create a JSON file ( in this example, called *snowfall_openapi.json*) describing the API.
101
+
102
+
```json
103
+
{
104
+
"openapi": "3.0.0",
105
+
"info": {
106
+
"title": "Snowfall API",
107
+
"version": "1.0.0"
108
+
},
109
+
"paths": {
110
+
"/snow": {
111
+
"get": {
112
+
"summary": "Get snowfall information",
113
+
"parameters": [
114
+
{
115
+
"name": "location",
116
+
"in": "query",
117
+
"required": true,
118
+
"schema": {
119
+
"type": "string"
78
120
}
79
-
],
80
-
"responses": {
81
-
"200": {
82
-
"description": "Successful response",
83
-
"content": {
84
-
"application/json": {
85
-
"schema": {
86
-
"type": "object",
87
-
"properties": {
88
-
"location": {"type": "string"},
89
-
"snow": {"type": "string"}
90
-
}
121
+
}
122
+
],
123
+
"responses": {
124
+
"200": {
125
+
"description": "Successful response",
126
+
"content": {
127
+
"application/json": {
128
+
"schema": {
129
+
"type": "object",
130
+
"properties": {
131
+
"location": {"type": "string"},
132
+
"snow": {"type": "string"}
91
133
}
92
134
}
93
135
}
@@ -97,72 +139,30 @@ OpenAPI defined tools allow agents to interact with external APIs using standard
97
139
}
98
140
}
99
141
}
100
-
```
101
-
102
-
1. **Register the OpenAPI tool**:
103
-
104
-
```python
105
-
from azure.ai.projects.models import OpenApiTool, OpenApiAnonymousAuthDetails
instructions="You are a snowfall tracking assistant. Use the API to fetch snowfall data.",
160
+
tools=[openapi_tool]
161
+
)
162
+
```
120
163
121
164
The agent can now use the OpenAPI tool to fetch snowfall data dynamically.
122
165
123
-
## Azure Functions integration
124
-
125
-
Azure Functions provide serverless computing capabilities for real-time processing. This integration is ideal for event-driven workflows, enabling agents to respond to triggers such as HTTP requests or queue messages.
126
-
127
-
### Example: Using Azure Functions with a queue trigger
128
-
129
-
1. **Define an Azure Function**: Develop and deploy your Azure Function. In this example, imagine we have a function in our Azure subscription to fetch the snowfall for a given location.
130
-
131
-
1. **Integrate the Azure Function with the agent**:
instructions="You are a snowfall tracking agent. Use the provided Azure Function to fetch snowfall based on location.",
160
-
tools=azure_function_tool.definitions,
161
-
)
162
-
```
163
-
164
-
The agent can now send requests to the Azure Function via a storage queue and process the results.
165
-
166
166
> [!NOTE]
167
167
> One of the concepts related to agents and custom tools that developers often have difficulty with is the *declarative* nature of the solution. You don't need to write code that explicitly *calls* your custom tool functions - the agent itself decides to call tool functions based on messages in prompts. By providing the agent with functions that have meaningful names and well-documented parameters, the agent can "figure out" when and how to call the function all by itself!
0 commit comments