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
from agent_framework.openai import OpenAIChatClient
32
32
33
-
@ai_tool(description="Get the current weather in a given location")
33
+
@ai_function(description="Get the current weather in a given location")
34
34
async def get_weather(location: Annotated[str, "The location as a city name"]) -> str:
35
35
"""Get the current weather in a given location."""
36
36
# Implementation of the tool to get weather
@@ -50,12 +50,12 @@ print(response)
50
50
Overall the following structure is proposed:
51
51
52
52
* agent-framework
53
-
*tier 0; components, will be exposed directly from `agent_framework`:
53
+
*core components, will be exposed directly from `agent_framework`:
54
54
* (single) agents (includes threads)
55
55
* tools (includes MCP and OpenAPI)
56
56
* models/types (name tbd, will include the equivalent of MEAI for dotnet; content types and client abstractions)
57
57
* logging
58
-
*tier 1; components, will be exposed from `agent_framework.<component>`:
58
+
*advanced components, will be exposed from `agent_framework.<component>`:
59
59
* context_providers (tbd)
60
60
* guardrails / filters
61
61
* vector_data (vector stores and other MEVD pieces)
@@ -65,12 +65,12 @@ Overall the following structure is proposed:
65
65
* utils (optional)
66
66
* telemetry (could also be observability or monitoring)
67
67
* workflows (includes multi-agent orchestration)
68
-
* tier 2; extensions
69
-
* Extensions are any additional functionality that is useful for a user, to reduce friction they will imported in a similar way as tier 1, however the code for them will be in a separate package, so that they can be installed separately, they must have everything in a folder with the same name as the package, and without a `__init__.py` file in the root, so that they can be used as a namespace package.
68
+
* connectors; subpackages
69
+
* Subpackages are any additional functionality that is useful for a user, to reduce friction they will imported in a similar way as advanced components, however the code for them will be in a separate package, so that they can be installed separately, they must expose all public items, in their main `__init__.py` file, so that they can be imported from the main package without additional import levels.
70
+
In the main package a corresponding folder will be created, with a `__init__.py` file that lazy imports the public items from the subpackage, so that they can be exposed from the main package.
70
71
* Some examples are:
71
-
* openai
72
-
* azure
73
-
* will be exposed through i.e. `agent_framework.openai` and `agent_framework.azure`
72
+
* azure (non LLM integrations)
73
+
* will be exposed through i.e. `agent_framework.azure`
74
74
* anything other then a connector that we want to expose as a separate package, for instance:
75
75
* mem0 (memory management)
76
76
* would be exposed through i.e. `agent_framework.mem0`
@@ -79,7 +79,6 @@ Overall the following structure is proposed:
79
79
* tests
80
80
* samples
81
81
* extensions
82
-
* openai
83
82
* azure
84
83
* ...
85
84
@@ -90,53 +89,48 @@ Internal imports will be done using relative imports, so that the package can be
90
89
The resulting file structure will be as follows:
91
90
92
91
```plaintext
93
-
agent_framework/
94
-
__init__.py
95
-
__init__.pyi
96
-
_agents.py
97
-
_tools.py
98
-
_models.py
99
-
_logging.py
100
-
context_providers.py
101
-
guardrails.py
102
-
exceptions.py
103
-
evaluations.py
104
-
utils.py
105
-
telemetry.py
106
-
templates.py
107
-
text_search.py
108
-
vector_data.py
109
-
workflows.py
110
-
py.typed
111
-
extensions/
112
-
mem0/
113
-
agent_framework/
114
-
mem0/
115
-
__init__.py
116
-
_mem0.py
117
-
...
118
-
redis/
119
-
...
120
-
openai/
92
+
packages/
93
+
main/
121
94
agent_framework/
122
95
openai/
123
96
__init__.py
124
-
_chat.py
125
-
_embeddings.py
126
-
...
97
+
_chat_client.py
98
+
_shared.py
99
+
exceptions.py
100
+
__init__.py
101
+
__init__.pyi
102
+
_agents.py
103
+
_tools.py
104
+
_models.py
105
+
_logging.py
106
+
context_providers.py
107
+
guardrails.py
108
+
exceptions.py
109
+
evaluations.py
110
+
utils.py
111
+
telemetry.py
112
+
templates.py
113
+
text_search.py
114
+
vector_data.py
115
+
workflows.py
116
+
py.typed
127
117
tests/
128
118
unit/
129
-
test_openai_client.py
130
-
test_openai_tools.py
131
-
...
119
+
test_types.py
132
120
integration/
133
-
test_openai_integration.py
134
-
samples/ (optional)
135
-
...
121
+
test_chat_clients.py
136
122
pyproject.toml
137
123
README.md
138
124
...
139
-
google/
125
+
mem0/
126
+
agent_framework/
127
+
mem0/
128
+
__init__.py
129
+
_mem0.py
130
+
...
131
+
redis/
132
+
...
133
+
google/
140
134
agent_framework/
141
135
google/
142
136
__init__.py
@@ -156,13 +150,6 @@ extensions/
156
150
README.md
157
151
...
158
152
...
159
-
tests/
160
-
__init__.py
161
-
unit/
162
-
conftest.py
163
-
test_agents.py
164
-
test_types.py
165
-
...
166
153
samples/
167
154
...
168
155
pyproject.toml
@@ -174,10 +161,10 @@ uv.lock
174
161
175
162
We might add a template subpackage as well, to make it easy to setup, this could be based on the first one that is added.
176
163
177
-
In the `DEV_SETUP.md` we will add instructions for how to deal with the path depth issues, especially on Windows, where the maximum path length can be a problem.
164
+
In the [`DEV_SETUP.md`](../../python/DEV_SETUP.md) we will add instructions for how to deal with the path depth issues, especially on Windows, where the maximum path length can be a problem.
178
165
179
166
#### Evolving the package structure
180
-
For each of the tier 1 components, we have two reason why we may split them into a folder, with an `__init__.py` and optionally a `_files.py`:
167
+
For each of the advanced components, we have two reason why we may split them into a folder, with an `__init__.py` and optionally a `_files.py`:
181
168
1. If the file becomes too large, we can split it into multiple `_files`, while still keeping the public interface in the `__init__.py` file, this is a non-breaking change
182
169
2. If we want to partially or fully move that code into a separate package.
183
170
In this case we do need to lazy load anything that was moved from the main package to the subpackage, so that existing code still works, and if the subpackage is not installed we can raise a meaningful error.
@@ -197,14 +184,7 @@ agent_framework/
197
184
198
185
## Coding standards
199
186
200
-
* We use google docstyles for docstrings.
201
-
* We use the following setup for ruff:
202
-
```toml
203
-
[tool.ruff]
204
-
line-length = 120
205
-
target-version = "py310"
206
-
include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
207
-
preview = true
187
+
Coding standards will be maintained in the [`DEV_SETUP.md`](../../python/DEV_SETUP.md) file.
208
188
209
189
[tool.ruff.lint]
210
190
fixable = ["ALL"]
@@ -281,16 +261,16 @@ The logging will be simplified, there will be one logger in the base package:
281
261
* name: `agent_framework` - used for all logging in the abstractions and base components
282
262
283
263
Each of the other subpackages for connectors will have a similar single logger.
284
-
* name: `agent_framework.connectors.openai`
285
-
* name: `agent_framework.connectors.azure`
264
+
* name: `agent_framework.openai`
265
+
* name: `agent_framework.azure`
286
266
287
267
This means that when a logger is needed, it should be created like this:
Get a logger with the specified name, defaulting to 'agent_framework'.
303
-
283
+
304
284
Args:
305
285
name (str): The name of the logger. Defaults to 'agent_framework'.
306
-
286
+
307
287
Returns:
308
288
logging.Logger: The configured logger instance.
309
289
"""
310
290
logger = logging.getLogger(name)
311
291
# create the specifics for the logger, such as setting the level, handlers, etc.
312
292
return logger
313
293
```
314
-
This will ensure that the logger is created with the correct name and configuration, and it will be consistent across the package.
294
+
This will ensure that the logger is created with the correct name and configuration, and it will be consistent across the package.
315
295
316
296
Further there should be a easy way to configure the log levels, either through a environment variable or with a similar function as the get_logger.
317
297
@@ -320,7 +300,7 @@ This will not be allowed:
320
300
import logging
321
301
322
302
logger = logging.getLogger(__name__)
323
-
```
303
+
```
324
304
325
305
This is allowed but discouraged, if the get_logger function has been called at least once then this will return the same logger as the get_logger function, however that might not have happened and then the logging experience (in terms of formats and handlers, etc) is not consistent across the package:
Telemetry will be based on OpenTelemetry (OTel), and will be implemented in the `agent_framework.telemetry` package.
334
314
335
-
We should consider auto-instrumentation and provide an implementation of it to the OTel community.
336
-
337
-
### Function definitions
338
-
To make the code easier to use, we will be very deliberate about the ordering and marking of function parameters.
339
-
This means that we will use the following conventions:
340
-
* Only parameters that are fully expected to be passed and only if there are a very limited number of them, let's say 3 or less, can they be supplied as positional parameters (still with a keyword, _almost_ never positional only).
341
-
* All other parameters should be supplied as keyword parameters, this is especially important to configure correctly when using Pydantic or dataclasses.
342
-
* If there are multiple required parameters, and they do not have a order that is common sense, then they will all use keyword parameters.
343
-
* If we use `kwargs` we will document how and what we use them for, this might be a reference to a outside package's documentation or an explanation of what the `kwargs` are used for.
344
-
* If we want to combine `kwargs` for multiple things, such as partly for a external client constructor, and partly for our own use, we will try to keep those separate, by adding a parameter, such as `client_kwargs` with type `dict[str, Any]`, and then use that to pass the kwargs to the client constructor (by using `Client(**client_kwargs)`), while using the `**kwargs` parameters for other uses, which are then also well documented.
345
-
346
-
### Attributes vs inheritance
315
+
We will also add headers with user-agent strings where applicable, these will include `agent-framework-python` and the version.
347
316
348
-
When the parameters are the same except for one, we will use attributes, instead of inheritance, to minimize the conceptual overhead of understanding the code. Off course there are exceptions and these things will be decided on a case by case basis, but the general rule is that if the parameters are the same, we will use attributes.
349
-
```python
350
-
# ✅ preferred
351
-
from agent_framework import ChatMessage
352
-
user_msg = ChatMessage(
353
-
role="user",
354
-
content="Hello, world!"
355
-
)
356
-
asst_msg = ChatMessage(
357
-
role="assistant",
358
-
content="Hello, world!"
359
-
)
360
-
# ❌ not preferred
361
-
from agent_framework import UserMessage, AssistantMessage
362
-
user_msg = UserMessage(
363
-
content="Hello, world!"
364
-
)
365
-
asst_msg = AssistantMessage(
366
-
content="Hello, world!"
367
-
)
368
-
```
317
+
We should consider auto-instrumentation and provide an implementation of it to the OTel community.
369
318
370
319
### Build and release
371
320
The build step will be done in GHA, adding the package to the release and then we call into Azure DevOps to use the ESRP pipeline to publish to pypi. This is how SK already works, we will just have to adapt it to the new package structure.
0 commit comments