Skip to content

Commit b64185c

Browse files
howieleungjhakulinM-Hietalanick863glharper
authored
Feature/azure ai agents v1 (Azure#40818)
* init agents v1 with new operations * update * add samples * aio * update * update * updates * update * update * update * update * update * add create_thread_and_run * create thread and process run * add tests and update README (Azure#40760) * update README * update tests * fix sample * adding tracing (Azure#40769) * Fix unit tests (Azure#40783) * Fix unit tests * Record instrumentor tests * modifying multiagent sample (Azure#40799) * Jhakulin/azure sdk review fixes (Azure#40795) Fix static analysis, updates from azure sdk reviews. --------- Co-authored-by: nick863 <[email protected]> * run black, fix some readme update snip issue (Azure#40815) * Howie/ffix toolcall (Azure#40750) * max retry and tests * fix test * Update samples csv data (Azure#40821) * update samples csv data * add cspell * Add ew artifact to list (Azure#40833) * [AI] [Agents] tool schema updates (Azure#40841) * [AI] [Agents] tool changes for Bing tools and Azure AI Search * add implementation for abstract tool methods * Remove packages not handled in the branch from the CI (Azure#40842) * Jhakulin/agents naming changes (Azure#40845) * naming changes * update tests * Record the tests and disable azue functions for now (Azure#40852) * Nirovins/record tests (Azure#40854) * Record the tests and disable azue functions for now * Add recordings for azure functions * Record instrumentation tests --------- Co-authored-by: Jarno Hakulinen <[email protected]> --------- Co-authored-by: Nikolay Rovinskiy <[email protected]> * bring tests README back (Azure#40858) * Uncomment function tests (Azure#40855) * naming changes * update names * update * update tests * update * Record the tests and disable azue functions for now (Azure#40852) * Nirovins/record tests (Azure#40854) * Record the tests and disable azue functions for now * Add recordings for azure functions * Record instrumentation tests --------- Co-authored-by: Jarno Hakulinen <[email protected]> * Uncomment function tests * Fix --------- Co-authored-by: jhakulin <[email protected]> * Jhakulin/list op update (Azure#40871) * update list operations * update tests * update README * update * Fix the instrumentation tests (Azure#40877) * Fix the instrumentation tests * Better instrumentation handling * pylint --------- Co-authored-by: Nikolay Rovinskiy <[email protected]> * Howie/poll timeout (Azure#40825) * add timeout for polling * fix merge * fix merge * fix merge * fixed merge * enable_auto_function_calls param changes (Azure#40820) * get CI green (Azure#40884) * fix logic app sample (Azure#40883) * agent azure monitor tracing sample updates (Azure#40865) * agent azure monitor tracing sample updates * disable pylint for global statement * agent tracing runid to feature branch (Azure#40888) * omit azure-ai-agents from pypy compatibility map * [AI] [Agents] write initial CHANGELOG and add missing samples (Azure#40891) * [AI] [Agents] write initial CHANGELOG * add sample for multiple connected agents * add sample for connected agents * update snippets * try get green pipeline (Azure#40914) * resolved comments (Azure#40922) * update code owner (Azure#40933) * Howie/toolcall fix (Azure#40939) * update code owner * fix tool call for async to be same as sync * fix test * Resolved Johan comments (Azure#40943) * resolved comments * resolved comments * Resolved comments * change project label * Hide the hack to use connection string. (Azure#40945) * FIx for function name changes (Azure#40951) * Remove Key Authentication (Azure#40954) * Remove Key Authentication * Exclude samples * Fix linter * Fixed logger (Azure#40957) * clean up py (Azure#40959) --------- Co-authored-by: jhakulin <[email protected]> Co-authored-by: M-Hietala <[email protected]> Co-authored-by: Nikolay Rovinskiy <[email protected]> Co-authored-by: Glenn Harper <[email protected]> Co-authored-by: Scott Beddall <[email protected]>
1 parent d7d04c0 commit b64185c

File tree

168 files changed

+58001
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+58001
-3
lines changed

.github/CODEOWNERS

+9
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@
262262
# ServiceLabel: %AI Model Inference %Service Attention
263263
/sdk/ai/azure-ai-inference/ @dargilco @trangevi @jhakulin
264264

265+
# PRLabel: %AI Agents
266+
# ServiceLabel: %AI Agents %Service Attention
267+
/sdk/ai/azure-ai-agents/ @dargilco @jhakulin
268+
269+
# PRLabel: %AI Projects
270+
# ServiceLabel: %AI Projects %Service Attention
271+
/sdk/ai/azure-ai-projects/ @dargilco @jhakulin
272+
273+
265274
# PRLabel: %HDInsight
266275
/sdk/hdinsight/ @idear1203
267276

eng/.docsettings.yml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ omitted_paths:
1414
- sdk/**/swagger/*
1515
- sdk/ml/azure-ai-ml/tests/*
1616
- sdk/vision/azure-ai-vision-imageanalysis/tests/*
17+
- sdk/ai/azure-ai-agents/tests/*
1718
- sdk/ai/azure-ai-inference/tests/*
1819
- sdk/ai/azure-ai-projects/tests/*
1920
- sdk/storage/azure-storage-extensions/*

pylintrc

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ignore-paths=
88
azure\\mixedreality\\remoterendering\\_api_version.py,
99
azure/mixedreality/remoterendering/_api_version.py,
1010
(?:.*[/\\]|^)projects/(models/_models.py|_model_base.py|operations/_operations.py|aio/operations/_operations.py)$,
11+
(?:.*[/\\]|^)agents/(models/_models.py|_model_base.py|operations/_operations.py|aio/operations/_operations.py)$,
1112
# Exclude any path that contains the following directory names
1213
(?:.*[/\\]|^)(?:_vendor|_generated|_restclient|samples|examples|test|tests|doc|\.tox)(?:[/\\]|$)
1314

sdk/ai/azure-ai-agents/CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Release History
2+
3+
## 1.0.0b1 (2025-05-07)
4+
5+
### Breaking Changes
6+
7+
- enable_auto_function_calls supports positional arguments instead of keyword arguments.
8+
9+
### Features Added
10+
11+
- Initial version - splits off Azure AI Agents functionality from the Azure AI Projects SDK
12+
- Azure AI Search tool, Bing Grounding tool, and Bing Custom Search tool parameters updated
13+
- All polling functions now support timeout keyword parameter.
14+
15+
### Bugs Fixed
16+
17+
- During automatic function calls for streaming, when the thread run is cancelled due to too many retry, now a cancelled event will be sent out.
18+
- Add missing thread run id and message id on the process thread run span
+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# FunctionTool Specifications
2+
3+
FunctionTool is the utility allowing developers to provide functions within their code and invoke during streaming or running.
4+
5+
## Example of Function
6+
7+
Here is an example of a function:
8+
```python
9+
def fetch_weather(location: str) -> str:
10+
"""
11+
Fetches the weather information for the specified location.
12+
13+
:param location (str): The location to fetch weather for.
14+
:return: Weather information as a JSON string.
15+
:rtype: str
16+
"""
17+
# In a real-world scenario, you'd integrate with a weather API.
18+
mock_weather_data = {"New York": "Sunny, 25°C", "London": "Cloudy, 18°C", "Tokyo": "Rainy, 22°C"}
19+
weather = mock_weather_data.get(location, "Weather data not available for this location.")
20+
weather_json = json.dumps({"weather": weather})
21+
return weather_json
22+
```
23+
24+
Here is an example to attach this function definition to create_agent
25+
26+
```python
27+
functions = FunctionTool({fetch_weather})
28+
29+
agent = agents_client.create_agent(
30+
model=os.environ["MODEL_DEPLOYMENT_NAME"],
31+
name="my-assistant",
32+
instructions="You are a helpful assistant",
33+
tools=functions.definitions,
34+
)
35+
```
36+
37+
To verify that the SDK parsed the docstring properly, you can print the definition:
38+
39+
```python
40+
[print(json.dumps(tool.as_dict(), indent=4)) for tool in functions.definitions]
41+
```
42+
43+
Alternatively user can check the tools property in newly created agent:
44+
45+
```python
46+
[print(json.dumps(tool.as_dict(), indent=4)) for tool in agent.tools if tool.type == "function"]
47+
```
48+
49+
The terminal will display the definition as below:
50+
51+
```json
52+
[
53+
{
54+
"type": "function",
55+
"function": {
56+
"name": "fetch_weather",
57+
"description": "Fetches the weather information for the specified location.",
58+
"parameters": {
59+
"type": "object",
60+
"properties": {
61+
"location": {
62+
"type": "string",
63+
"description": "The location to fetch weather for."
64+
}
65+
},
66+
"required": [
67+
"location"
68+
]
69+
}
70+
}
71+
}
72+
]
73+
```
74+
75+
## Requirements for FunctionTool
76+
77+
To ensure `FunctionTool` operates correctly and generates accurate function definitions that agents can reliably call, adhere to the following standards:
78+
79+
1. **Type Annotations**
80+
- All function parameters and return types should be explicitly type-annotated using Python's type hinting.
81+
82+
2. **Structured Docstrings**
83+
- Utilize a consistent docstring format similar to the example above (see also related agent samples in this repository).
84+
- Include clear descriptions for each function and parameter.
85+
86+
3. **Supported Types**
87+
88+
`FunctionTool` maps common Python types to their JSON Schema equivalents, ensuring accurate representation without complex type details:
89+
90+
- **Strings and Numbers**
91+
- `str``string`
92+
- `int``integer`
93+
- `float``number`
94+
- `bool``boolean`
95+
96+
- **Collections**
97+
- `list``array`
98+
- `dict``object`
99+
100+
- **Nullable Types**
101+
- `Optional[type]` includes `null`

sdk/ai/azure-ai-agents/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) Microsoft Corporation.
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

sdk/ai/azure-ai-agents/MANIFEST.in

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include *.md
2+
include LICENSE
3+
include azure/ai/agents/py.typed
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
6+
include azure/__init__.py
7+
include azure/ai/__init__.py

0 commit comments

Comments
 (0)