microsoft-agents-hosting-fastapi 1.2.0.dev20__tar.gz → 1.4.0.dev10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- microsoft_agents_hosting_fastapi-1.4.0.dev10/PKG-INFO +169 -0
- microsoft_agents_hosting_fastapi-1.4.0.dev10/VERSION.txt +1 -0
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/microsoft_agents/hosting/fastapi/__init__.py +5 -0
- microsoft_agents_hosting_fastapi-1.4.0.dev10/microsoft_agents/hosting/fastapi/_fastapi_request_adapter.py +28 -0
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/microsoft_agents/hosting/fastapi/_start_agent_process.py +3 -0
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/microsoft_agents/hosting/fastapi/channel_service_route_table.py +1 -23
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/microsoft_agents/hosting/fastapi/cloud_adapter.py +10 -29
- microsoft_agents_hosting_fastapi-1.4.0.dev10/microsoft_agents/hosting/fastapi/jwt_authorization_middleware.py +80 -0
- microsoft_agents_hosting_fastapi-1.4.0.dev10/microsoft_agents_hosting_fastapi.egg-info/PKG-INFO +169 -0
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/microsoft_agents_hosting_fastapi.egg-info/SOURCES.txt +1 -0
- microsoft_agents_hosting_fastapi-1.4.0.dev10/microsoft_agents_hosting_fastapi.egg-info/requires.txt +3 -0
- microsoft_agents_hosting_fastapi-1.4.0.dev10/readme.md +151 -0
- microsoft_agents_hosting_fastapi-1.2.0.dev20/PKG-INFO +0 -123
- microsoft_agents_hosting_fastapi-1.2.0.dev20/VERSION.txt +0 -1
- microsoft_agents_hosting_fastapi-1.2.0.dev20/microsoft_agents/hosting/fastapi/jwt_authorization_middleware.py +0 -74
- microsoft_agents_hosting_fastapi-1.2.0.dev20/microsoft_agents_hosting_fastapi.egg-info/PKG-INFO +0 -123
- microsoft_agents_hosting_fastapi-1.2.0.dev20/microsoft_agents_hosting_fastapi.egg-info/requires.txt +0 -3
- microsoft_agents_hosting_fastapi-1.2.0.dev20/readme.md +0 -105
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/LICENSE +0 -0
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/MANIFEST.in +0 -0
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/microsoft_agents/hosting/fastapi/agent_http_adapter.py +0 -0
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/microsoft_agents_hosting_fastapi.egg-info/dependency_links.txt +0 -0
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/microsoft_agents_hosting_fastapi.egg-info/top_level.txt +0 -0
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/pyproject.toml +0 -0
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/setup.cfg +0 -0
- {microsoft_agents_hosting_fastapi-1.2.0.dev20 → microsoft_agents_hosting_fastapi-1.4.0.dev10}/setup.py +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: microsoft-agents-hosting-fastapi
|
|
3
|
+
Version: 1.4.0.dev10
|
|
4
|
+
Summary: Integration library for Microsoft Agents with FastAPI
|
|
5
|
+
Author: Microsoft Corporation
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/microsoft/Agents
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: microsoft-agents-hosting-core==1.4.0.dev10
|
|
14
|
+
Requires-Dist: fastapi>=0.104.0
|
|
15
|
+
Requires-Dist: starlette>=1.0.1
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
Dynamic: requires-dist
|
|
18
|
+
|
|
19
|
+
# Microsoft Agents Hosting FastAPI
|
|
20
|
+
|
|
21
|
+
This library provides FastAPI integration for Microsoft Agents, enabling you to build conversational agents using the FastAPI web framework.
|
|
22
|
+
|
|
23
|
+
## Release Notes
|
|
24
|
+
<table style="width:100%">
|
|
25
|
+
<tr>
|
|
26
|
+
<th style="width:20%">Version</th>
|
|
27
|
+
<th style="width:20%">Date</th>
|
|
28
|
+
<th style="width:60%">Release Notes</th>
|
|
29
|
+
</tr>
|
|
30
|
+
<tr>
|
|
31
|
+
<td>1.3.0</td>
|
|
32
|
+
<td>2026-07-30</td>
|
|
33
|
+
<td>
|
|
34
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v130">
|
|
35
|
+
1.3.0 Release Notes
|
|
36
|
+
</a>
|
|
37
|
+
</td>
|
|
38
|
+
</tr>
|
|
39
|
+
<tr>
|
|
40
|
+
<td>1.2.0</td>
|
|
41
|
+
<td>2026-07-17</td>
|
|
42
|
+
<td>
|
|
43
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v120">
|
|
44
|
+
1.2.0 Release Notes
|
|
45
|
+
</a>
|
|
46
|
+
</td>
|
|
47
|
+
</tr>
|
|
48
|
+
<tr>
|
|
49
|
+
<td>1.1.0</td>
|
|
50
|
+
<td>2026-06-19</td>
|
|
51
|
+
<td>
|
|
52
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v110">
|
|
53
|
+
1.1.0 Release Notes
|
|
54
|
+
</a>
|
|
55
|
+
</td>
|
|
56
|
+
</tr>
|
|
57
|
+
<tr>
|
|
58
|
+
<td>1.0.0</td>
|
|
59
|
+
<td>2026-05-22</td>
|
|
60
|
+
<td>
|
|
61
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v100">
|
|
62
|
+
1.0.0 Release Notes
|
|
63
|
+
</a>
|
|
64
|
+
</td>
|
|
65
|
+
</tr>
|
|
66
|
+
<tr>
|
|
67
|
+
<td>0.9.1</td>
|
|
68
|
+
<td>2026-05-04</td>
|
|
69
|
+
<td>
|
|
70
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v091">
|
|
71
|
+
0.9.1 Release Notes
|
|
72
|
+
</a>
|
|
73
|
+
</td>
|
|
74
|
+
</tr>
|
|
75
|
+
<tr>
|
|
76
|
+
<td>0.9.0</td>
|
|
77
|
+
<td>2026-04-15</td>
|
|
78
|
+
<td>
|
|
79
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v090">
|
|
80
|
+
0.9.0 Release Notes
|
|
81
|
+
</a>
|
|
82
|
+
</td>
|
|
83
|
+
</tr>
|
|
84
|
+
<tr>
|
|
85
|
+
<td>0.8.0</td>
|
|
86
|
+
<td>2026-02-23</td>
|
|
87
|
+
<td>
|
|
88
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v080">
|
|
89
|
+
0.8.0 Release Notes
|
|
90
|
+
</a>
|
|
91
|
+
</td>
|
|
92
|
+
</tr>
|
|
93
|
+
<tr>
|
|
94
|
+
<td>0.7.0</td>
|
|
95
|
+
<td>2026-01-21</td>
|
|
96
|
+
<td>
|
|
97
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v070">
|
|
98
|
+
0.7.0 Release Notes
|
|
99
|
+
</a>
|
|
100
|
+
</td>
|
|
101
|
+
</tr>
|
|
102
|
+
<tr>
|
|
103
|
+
<td>0.6.1</td>
|
|
104
|
+
<td>2025-12-01</td>
|
|
105
|
+
<td>
|
|
106
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v061">
|
|
107
|
+
0.6.1 Release Notes
|
|
108
|
+
</a>
|
|
109
|
+
</td>
|
|
110
|
+
</tr>
|
|
111
|
+
<tr>
|
|
112
|
+
<td>0.6.0</td>
|
|
113
|
+
<td>2025-11-18</td>
|
|
114
|
+
<td>
|
|
115
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v060">
|
|
116
|
+
0.6.0 Release Notes
|
|
117
|
+
</a>
|
|
118
|
+
</td>
|
|
119
|
+
</tr>
|
|
120
|
+
</table>
|
|
121
|
+
|
|
122
|
+
## Packages Overview
|
|
123
|
+
|
|
124
|
+
We offer the following PyPI packages to create conversational experiences based on Agents:
|
|
125
|
+
|
|
126
|
+
| Package Name | PyPI Version | Description |
|
|
127
|
+
|--------------|-------------|-------------|
|
|
128
|
+
| `microsoft-agents-activity` | [](https://pypi.org/project/microsoft-agents-activity/) | Types and validators implementing the Activity protocol spec. |
|
|
129
|
+
| `microsoft-agents-hosting-core` | [](https://pypi.org/project/microsoft-agents-hosting-core/) | Core library for Microsoft Agents hosting. |
|
|
130
|
+
| `microsoft-agents-hosting-aiohttp` | [](https://pypi.org/project/microsoft-agents-hosting-aiohttp/) | Configures aiohttp to run the Agent. |
|
|
131
|
+
| `microsoft-agents-hosting-fastapi` | [](https://pypi.org/project/microsoft-agents-hosting-fastapi/) | Configures fastapi to run the Agent. |
|
|
132
|
+
| `microsoft-agents-hosting-msteams` | [](https://pypi.org/project/microsoft-agents-hosting-msteams/) | Provides classes to host an Agent for Teams. |
|
|
133
|
+
| `microsoft-agents-hosting-dialogs` | [](https://pypi.org/project/microsoft-agents-hosting-dialogs/) | Dialog system with waterfall dialogs, prompts, and multi-turn conversation management. |
|
|
134
|
+
| `microsoft-agents-hosting-slack` | [](https://pypi.org/project/microsoft-agents-hosting-slack/) | Provides classes to host an Agent for Slack. |
|
|
135
|
+
| `microsoft-agents-storage-blob` | [](https://pypi.org/project/microsoft-agents-storage-blob/) | Extension to use Azure Blob as storage. |
|
|
136
|
+
| `microsoft-agents-storage-cosmos` | [](https://pypi.org/project/microsoft-agents-storage-cosmos/) | Extension to use CosmosDB as storage. |
|
|
137
|
+
| `microsoft-agents-authentication-msal` | [](https://pypi.org/project/microsoft-agents-authentication-msal/) | MSAL-based authentication for Microsoft Agents. |
|
|
138
|
+
| `microsoft-agents-authentication-entra-auth-sidecar` | [](https://pypi.org/project/microsoft-agents-authentication-entra-auth-sidecar/) | Credential-free Entra ID Agent ID authentication via the sidecar. |
|
|
139
|
+
|
|
140
|
+
## Features
|
|
141
|
+
|
|
142
|
+
- FastAPI integration for Microsoft Agents
|
|
143
|
+
- JWT authorization middleware
|
|
144
|
+
- Channel service API endpoints
|
|
145
|
+
- Streaming response support
|
|
146
|
+
- Cloud adapter for processing agent activities
|
|
147
|
+
|
|
148
|
+
## Installation
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pip install microsoft-agents-hosting-fastapi
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Usage
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from fastapi import FastAPI, Request
|
|
158
|
+
from microsoft_agents.hosting.fastapi import start_agent_process, CloudAdapter
|
|
159
|
+
from microsoft_agents.hosting.core.app import AgentApplication
|
|
160
|
+
|
|
161
|
+
app = FastAPI()
|
|
162
|
+
connection_manager = MsalConnectionManager(**agents_sdk_config)
|
|
163
|
+
adapter = CloudAdapter(connection_manager=connection_manager)
|
|
164
|
+
agent_app = AgentApplication()
|
|
165
|
+
|
|
166
|
+
@app.post("/api/messages")
|
|
167
|
+
async def messages(request: Request):
|
|
168
|
+
return await start_agent_process(request, agent_app, adapter)
|
|
169
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.4.0.dev10
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
1
4
|
from ._start_agent_process import start_agent_process
|
|
2
5
|
from .agent_http_adapter import AgentHttpAdapter
|
|
3
6
|
from .channel_service_route_table import channel_service_route_table
|
|
4
7
|
from .cloud_adapter import CloudAdapter
|
|
5
8
|
from .jwt_authorization_middleware import (
|
|
6
9
|
JwtAuthorizationMiddleware,
|
|
10
|
+
jwt_authorization_decorator,
|
|
7
11
|
)
|
|
8
12
|
|
|
9
13
|
# Import streaming utilities from core for backward compatibility
|
|
@@ -18,6 +22,7 @@ __all__ = [
|
|
|
18
22
|
"AgentHttpAdapter",
|
|
19
23
|
"CloudAdapter",
|
|
20
24
|
"JwtAuthorizationMiddleware",
|
|
25
|
+
"jwt_authorization_decorator",
|
|
21
26
|
"channel_service_route_table",
|
|
22
27
|
"Citation",
|
|
23
28
|
"CitationUtil",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
from fastapi import Request
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class FastApiRequestAdapter:
|
|
8
|
+
"""Adapter to make FastAPI Request compatible with HttpRequestProtocol."""
|
|
9
|
+
|
|
10
|
+
def __init__(self, request: Request):
|
|
11
|
+
self._request = request
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def method(self) -> str:
|
|
15
|
+
return self._request.method
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def headers(self):
|
|
19
|
+
return self._request.headers
|
|
20
|
+
|
|
21
|
+
async def json(self):
|
|
22
|
+
return await self._request.json()
|
|
23
|
+
|
|
24
|
+
def get_claims_identity(self):
|
|
25
|
+
return getattr(self._request.state, "claims_identity", None)
|
|
26
|
+
|
|
27
|
+
def get_path_param(self, name: str) -> str:
|
|
28
|
+
return self._request.path_params.get(name, "")
|
|
@@ -7,29 +7,7 @@ from fastapi.responses import JSONResponse
|
|
|
7
7
|
from microsoft_agents.hosting.core import ChannelApiHandlerProtocol
|
|
8
8
|
from microsoft_agents.hosting.core.http import ChannelServiceRoutes
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
class FastApiRequestAdapter:
|
|
12
|
-
"""Adapter for FastAPI requests to use with ChannelServiceRoutes."""
|
|
13
|
-
|
|
14
|
-
def __init__(self, request: Request):
|
|
15
|
-
self._request = request
|
|
16
|
-
|
|
17
|
-
@property
|
|
18
|
-
def method(self) -> str:
|
|
19
|
-
return self._request.method
|
|
20
|
-
|
|
21
|
-
@property
|
|
22
|
-
def headers(self):
|
|
23
|
-
return self._request.headers
|
|
24
|
-
|
|
25
|
-
async def json(self):
|
|
26
|
-
return await self._request.json()
|
|
27
|
-
|
|
28
|
-
def get_claims_identity(self):
|
|
29
|
-
return getattr(self._request.state, "claims_identity", None)
|
|
30
|
-
|
|
31
|
-
def get_path_param(self, name: str) -> str:
|
|
32
|
-
return self._request.path_params.get(name, "")
|
|
10
|
+
from ._fastapi_request_adapter import FastApiRequestAdapter
|
|
33
11
|
|
|
34
12
|
|
|
35
13
|
def channel_service_route_table(
|
|
@@ -1,43 +1,20 @@
|
|
|
1
1
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
2
|
# Licensed under the MIT License.
|
|
3
|
+
|
|
3
4
|
from typing import Optional
|
|
4
5
|
|
|
5
6
|
from fastapi import Request, Response
|
|
6
7
|
from fastapi.responses import JSONResponse
|
|
7
8
|
|
|
8
|
-
from microsoft_agents.hosting.core import Agent
|
|
9
|
+
from microsoft_agents.hosting.core import Agent, HttpAdapterBase
|
|
9
10
|
from microsoft_agents.hosting.core.authorization import Connections
|
|
10
11
|
from microsoft_agents.hosting.core.http import (
|
|
11
|
-
HttpAdapterBase,
|
|
12
12
|
HttpResponse,
|
|
13
13
|
)
|
|
14
14
|
from microsoft_agents.hosting.core import ChannelServiceClientFactoryBase
|
|
15
15
|
|
|
16
16
|
from .agent_http_adapter import AgentHttpAdapter
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class FastApiRequestAdapter:
|
|
20
|
-
"""Adapter to make FastAPI Request compatible with HttpRequestProtocol."""
|
|
21
|
-
|
|
22
|
-
def __init__(self, request: Request):
|
|
23
|
-
self._request = request
|
|
24
|
-
|
|
25
|
-
@property
|
|
26
|
-
def method(self) -> str:
|
|
27
|
-
return self._request.method
|
|
28
|
-
|
|
29
|
-
@property
|
|
30
|
-
def headers(self):
|
|
31
|
-
return self._request.headers
|
|
32
|
-
|
|
33
|
-
async def json(self):
|
|
34
|
-
return await self._request.json()
|
|
35
|
-
|
|
36
|
-
def get_claims_identity(self):
|
|
37
|
-
return getattr(self._request.state, "claims_identity", None)
|
|
38
|
-
|
|
39
|
-
def get_path_param(self, name: str) -> str:
|
|
40
|
-
return self._request.path_params.get(name, "")
|
|
17
|
+
from ._fastapi_request_adapter import FastApiRequestAdapter
|
|
41
18
|
|
|
42
19
|
|
|
43
20
|
class CloudAdapter(HttpAdapterBase, AgentHttpAdapter):
|
|
@@ -46,18 +23,22 @@ class CloudAdapter(HttpAdapterBase, AgentHttpAdapter):
|
|
|
46
23
|
def __init__(
|
|
47
24
|
self,
|
|
48
25
|
*,
|
|
49
|
-
connection_manager: Connections = None,
|
|
50
|
-
channel_service_client_factory: ChannelServiceClientFactoryBase = None,
|
|
26
|
+
connection_manager: Connections | None = None,
|
|
27
|
+
channel_service_client_factory: ChannelServiceClientFactoryBase | None = None,
|
|
28
|
+
channel_service_client_factory_options: dict | None = None,
|
|
51
29
|
):
|
|
52
30
|
"""
|
|
53
31
|
Initializes a new instance of the CloudAdapter class.
|
|
54
32
|
|
|
55
33
|
:param connection_manager: Optional connection manager for OAuth.
|
|
56
|
-
:param channel_service_client_factory:
|
|
34
|
+
:param channel_service_client_factory: Factory for creating channel service clients.
|
|
35
|
+
:param channel_service_client_factory_options: Optional dictionary of options to pass to the channel service client factory
|
|
36
|
+
This is only used if channel_service_client_factory is not provided and connection_manager is provided.
|
|
57
37
|
"""
|
|
58
38
|
super().__init__(
|
|
59
39
|
connection_manager=connection_manager,
|
|
60
40
|
channel_service_client_factory=channel_service_client_factory,
|
|
41
|
+
channel_service_client_factory_options=channel_service_client_factory_options,
|
|
61
42
|
)
|
|
62
43
|
|
|
63
44
|
async def process(self, request: Request, agent: Agent) -> Optional[Response]:
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import functools
|
|
5
|
+
import inspect
|
|
6
|
+
|
|
7
|
+
from fastapi import Request
|
|
8
|
+
from fastapi.responses import JSONResponse
|
|
9
|
+
from starlette.types import ASGIApp, Receive, Scope, Send
|
|
10
|
+
|
|
11
|
+
from microsoft_agents.hosting.core import AgentAuthConfiguration
|
|
12
|
+
from microsoft_agents.hosting.core.authorization.jwt import _authorize_request
|
|
13
|
+
from microsoft_agents.hosting.core.http import HttpResponse
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class JwtAuthorizationMiddleware:
|
|
17
|
+
"""Starlette-compatible ASGI middleware for JWT authorization.
|
|
18
|
+
|
|
19
|
+
Usage:
|
|
20
|
+
from fastapi import FastAPI
|
|
21
|
+
|
|
22
|
+
app = FastAPI()
|
|
23
|
+
app.add_middleware(JwtAuthorizationMiddleware)
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(self, app: ASGIApp):
|
|
27
|
+
self.app = app
|
|
28
|
+
|
|
29
|
+
async def __call__(self, scope: Scope, receive: Receive, send: Send):
|
|
30
|
+
if scope["type"] == "lifespan":
|
|
31
|
+
await self.app(scope, receive, send)
|
|
32
|
+
return
|
|
33
|
+
|
|
34
|
+
app = scope.get("app")
|
|
35
|
+
state = getattr(app, "state", None) if app else None
|
|
36
|
+
auth_config: AgentAuthConfiguration | None = getattr(
|
|
37
|
+
state, "agent_configuration", None
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
request = Request(scope, receive=receive)
|
|
41
|
+
res = await _authorize_request(
|
|
42
|
+
request.headers.get("Authorization"), auth_config
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
if isinstance(res, HttpResponse):
|
|
46
|
+
response = JSONResponse(content=res.body, status_code=res.status_code)
|
|
47
|
+
await response(scope, receive, send)
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
request.state.claims_identity = res
|
|
51
|
+
await self.app(scope, receive, send)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def jwt_authorization_decorator(func):
|
|
55
|
+
"""
|
|
56
|
+
:param func: The FastAPI route handler function to be decorated.
|
|
57
|
+
:return: The decorated FastAPI route handler function.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
@functools.wraps(func)
|
|
61
|
+
async def wrapper(request: Request, *args, **kwargs):
|
|
62
|
+
if request is None:
|
|
63
|
+
return JSONResponse({"error": "Request object not found"}, status_code=500)
|
|
64
|
+
|
|
65
|
+
auth_config: AgentAuthConfiguration | None = getattr(
|
|
66
|
+
request.app.state, "agent_configuration", None
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
auth_header = request.headers.get("Authorization")
|
|
70
|
+
|
|
71
|
+
res = await _authorize_request(auth_header, auth_config)
|
|
72
|
+
if isinstance(res, HttpResponse):
|
|
73
|
+
return JSONResponse(content=res.body, status_code=res.status_code)
|
|
74
|
+
request.state.claims_identity = res
|
|
75
|
+
return await func(request, *args, **kwargs)
|
|
76
|
+
|
|
77
|
+
# FastAPI relies on inspect.signature for dependency injection and docs.
|
|
78
|
+
wrapper.__signature__ = inspect.signature(func) # type: ignore[attr-defined]
|
|
79
|
+
|
|
80
|
+
return wrapper
|
microsoft_agents_hosting_fastapi-1.4.0.dev10/microsoft_agents_hosting_fastapi.egg-info/PKG-INFO
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: microsoft-agents-hosting-fastapi
|
|
3
|
+
Version: 1.4.0.dev10
|
|
4
|
+
Summary: Integration library for Microsoft Agents with FastAPI
|
|
5
|
+
Author: Microsoft Corporation
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/microsoft/Agents
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: microsoft-agents-hosting-core==1.4.0.dev10
|
|
14
|
+
Requires-Dist: fastapi>=0.104.0
|
|
15
|
+
Requires-Dist: starlette>=1.0.1
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
Dynamic: requires-dist
|
|
18
|
+
|
|
19
|
+
# Microsoft Agents Hosting FastAPI
|
|
20
|
+
|
|
21
|
+
This library provides FastAPI integration for Microsoft Agents, enabling you to build conversational agents using the FastAPI web framework.
|
|
22
|
+
|
|
23
|
+
## Release Notes
|
|
24
|
+
<table style="width:100%">
|
|
25
|
+
<tr>
|
|
26
|
+
<th style="width:20%">Version</th>
|
|
27
|
+
<th style="width:20%">Date</th>
|
|
28
|
+
<th style="width:60%">Release Notes</th>
|
|
29
|
+
</tr>
|
|
30
|
+
<tr>
|
|
31
|
+
<td>1.3.0</td>
|
|
32
|
+
<td>2026-07-30</td>
|
|
33
|
+
<td>
|
|
34
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v130">
|
|
35
|
+
1.3.0 Release Notes
|
|
36
|
+
</a>
|
|
37
|
+
</td>
|
|
38
|
+
</tr>
|
|
39
|
+
<tr>
|
|
40
|
+
<td>1.2.0</td>
|
|
41
|
+
<td>2026-07-17</td>
|
|
42
|
+
<td>
|
|
43
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v120">
|
|
44
|
+
1.2.0 Release Notes
|
|
45
|
+
</a>
|
|
46
|
+
</td>
|
|
47
|
+
</tr>
|
|
48
|
+
<tr>
|
|
49
|
+
<td>1.1.0</td>
|
|
50
|
+
<td>2026-06-19</td>
|
|
51
|
+
<td>
|
|
52
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v110">
|
|
53
|
+
1.1.0 Release Notes
|
|
54
|
+
</a>
|
|
55
|
+
</td>
|
|
56
|
+
</tr>
|
|
57
|
+
<tr>
|
|
58
|
+
<td>1.0.0</td>
|
|
59
|
+
<td>2026-05-22</td>
|
|
60
|
+
<td>
|
|
61
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v100">
|
|
62
|
+
1.0.0 Release Notes
|
|
63
|
+
</a>
|
|
64
|
+
</td>
|
|
65
|
+
</tr>
|
|
66
|
+
<tr>
|
|
67
|
+
<td>0.9.1</td>
|
|
68
|
+
<td>2026-05-04</td>
|
|
69
|
+
<td>
|
|
70
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v091">
|
|
71
|
+
0.9.1 Release Notes
|
|
72
|
+
</a>
|
|
73
|
+
</td>
|
|
74
|
+
</tr>
|
|
75
|
+
<tr>
|
|
76
|
+
<td>0.9.0</td>
|
|
77
|
+
<td>2026-04-15</td>
|
|
78
|
+
<td>
|
|
79
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v090">
|
|
80
|
+
0.9.0 Release Notes
|
|
81
|
+
</a>
|
|
82
|
+
</td>
|
|
83
|
+
</tr>
|
|
84
|
+
<tr>
|
|
85
|
+
<td>0.8.0</td>
|
|
86
|
+
<td>2026-02-23</td>
|
|
87
|
+
<td>
|
|
88
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v080">
|
|
89
|
+
0.8.0 Release Notes
|
|
90
|
+
</a>
|
|
91
|
+
</td>
|
|
92
|
+
</tr>
|
|
93
|
+
<tr>
|
|
94
|
+
<td>0.7.0</td>
|
|
95
|
+
<td>2026-01-21</td>
|
|
96
|
+
<td>
|
|
97
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v070">
|
|
98
|
+
0.7.0 Release Notes
|
|
99
|
+
</a>
|
|
100
|
+
</td>
|
|
101
|
+
</tr>
|
|
102
|
+
<tr>
|
|
103
|
+
<td>0.6.1</td>
|
|
104
|
+
<td>2025-12-01</td>
|
|
105
|
+
<td>
|
|
106
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v061">
|
|
107
|
+
0.6.1 Release Notes
|
|
108
|
+
</a>
|
|
109
|
+
</td>
|
|
110
|
+
</tr>
|
|
111
|
+
<tr>
|
|
112
|
+
<td>0.6.0</td>
|
|
113
|
+
<td>2025-11-18</td>
|
|
114
|
+
<td>
|
|
115
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v060">
|
|
116
|
+
0.6.0 Release Notes
|
|
117
|
+
</a>
|
|
118
|
+
</td>
|
|
119
|
+
</tr>
|
|
120
|
+
</table>
|
|
121
|
+
|
|
122
|
+
## Packages Overview
|
|
123
|
+
|
|
124
|
+
We offer the following PyPI packages to create conversational experiences based on Agents:
|
|
125
|
+
|
|
126
|
+
| Package Name | PyPI Version | Description |
|
|
127
|
+
|--------------|-------------|-------------|
|
|
128
|
+
| `microsoft-agents-activity` | [](https://pypi.org/project/microsoft-agents-activity/) | Types and validators implementing the Activity protocol spec. |
|
|
129
|
+
| `microsoft-agents-hosting-core` | [](https://pypi.org/project/microsoft-agents-hosting-core/) | Core library for Microsoft Agents hosting. |
|
|
130
|
+
| `microsoft-agents-hosting-aiohttp` | [](https://pypi.org/project/microsoft-agents-hosting-aiohttp/) | Configures aiohttp to run the Agent. |
|
|
131
|
+
| `microsoft-agents-hosting-fastapi` | [](https://pypi.org/project/microsoft-agents-hosting-fastapi/) | Configures fastapi to run the Agent. |
|
|
132
|
+
| `microsoft-agents-hosting-msteams` | [](https://pypi.org/project/microsoft-agents-hosting-msteams/) | Provides classes to host an Agent for Teams. |
|
|
133
|
+
| `microsoft-agents-hosting-dialogs` | [](https://pypi.org/project/microsoft-agents-hosting-dialogs/) | Dialog system with waterfall dialogs, prompts, and multi-turn conversation management. |
|
|
134
|
+
| `microsoft-agents-hosting-slack` | [](https://pypi.org/project/microsoft-agents-hosting-slack/) | Provides classes to host an Agent for Slack. |
|
|
135
|
+
| `microsoft-agents-storage-blob` | [](https://pypi.org/project/microsoft-agents-storage-blob/) | Extension to use Azure Blob as storage. |
|
|
136
|
+
| `microsoft-agents-storage-cosmos` | [](https://pypi.org/project/microsoft-agents-storage-cosmos/) | Extension to use CosmosDB as storage. |
|
|
137
|
+
| `microsoft-agents-authentication-msal` | [](https://pypi.org/project/microsoft-agents-authentication-msal/) | MSAL-based authentication for Microsoft Agents. |
|
|
138
|
+
| `microsoft-agents-authentication-entra-auth-sidecar` | [](https://pypi.org/project/microsoft-agents-authentication-entra-auth-sidecar/) | Credential-free Entra ID Agent ID authentication via the sidecar. |
|
|
139
|
+
|
|
140
|
+
## Features
|
|
141
|
+
|
|
142
|
+
- FastAPI integration for Microsoft Agents
|
|
143
|
+
- JWT authorization middleware
|
|
144
|
+
- Channel service API endpoints
|
|
145
|
+
- Streaming response support
|
|
146
|
+
- Cloud adapter for processing agent activities
|
|
147
|
+
|
|
148
|
+
## Installation
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pip install microsoft-agents-hosting-fastapi
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Usage
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from fastapi import FastAPI, Request
|
|
158
|
+
from microsoft_agents.hosting.fastapi import start_agent_process, CloudAdapter
|
|
159
|
+
from microsoft_agents.hosting.core.app import AgentApplication
|
|
160
|
+
|
|
161
|
+
app = FastAPI()
|
|
162
|
+
connection_manager = MsalConnectionManager(**agents_sdk_config)
|
|
163
|
+
adapter = CloudAdapter(connection_manager=connection_manager)
|
|
164
|
+
agent_app = AgentApplication()
|
|
165
|
+
|
|
166
|
+
@app.post("/api/messages")
|
|
167
|
+
async def messages(request: Request):
|
|
168
|
+
return await start_agent_process(request, agent_app, adapter)
|
|
169
|
+
```
|
|
@@ -5,6 +5,7 @@ pyproject.toml
|
|
|
5
5
|
readme.md
|
|
6
6
|
setup.py
|
|
7
7
|
microsoft_agents/hosting/fastapi/__init__.py
|
|
8
|
+
microsoft_agents/hosting/fastapi/_fastapi_request_adapter.py
|
|
8
9
|
microsoft_agents/hosting/fastapi/_start_agent_process.py
|
|
9
10
|
microsoft_agents/hosting/fastapi/agent_http_adapter.py
|
|
10
11
|
microsoft_agents/hosting/fastapi/channel_service_route_table.py
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Microsoft Agents Hosting FastAPI
|
|
2
|
+
|
|
3
|
+
This library provides FastAPI integration for Microsoft Agents, enabling you to build conversational agents using the FastAPI web framework.
|
|
4
|
+
|
|
5
|
+
## Release Notes
|
|
6
|
+
<table style="width:100%">
|
|
7
|
+
<tr>
|
|
8
|
+
<th style="width:20%">Version</th>
|
|
9
|
+
<th style="width:20%">Date</th>
|
|
10
|
+
<th style="width:60%">Release Notes</th>
|
|
11
|
+
</tr>
|
|
12
|
+
<tr>
|
|
13
|
+
<td>1.3.0</td>
|
|
14
|
+
<td>2026-07-30</td>
|
|
15
|
+
<td>
|
|
16
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v130">
|
|
17
|
+
1.3.0 Release Notes
|
|
18
|
+
</a>
|
|
19
|
+
</td>
|
|
20
|
+
</tr>
|
|
21
|
+
<tr>
|
|
22
|
+
<td>1.2.0</td>
|
|
23
|
+
<td>2026-07-17</td>
|
|
24
|
+
<td>
|
|
25
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v120">
|
|
26
|
+
1.2.0 Release Notes
|
|
27
|
+
</a>
|
|
28
|
+
</td>
|
|
29
|
+
</tr>
|
|
30
|
+
<tr>
|
|
31
|
+
<td>1.1.0</td>
|
|
32
|
+
<td>2026-06-19</td>
|
|
33
|
+
<td>
|
|
34
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v110">
|
|
35
|
+
1.1.0 Release Notes
|
|
36
|
+
</a>
|
|
37
|
+
</td>
|
|
38
|
+
</tr>
|
|
39
|
+
<tr>
|
|
40
|
+
<td>1.0.0</td>
|
|
41
|
+
<td>2026-05-22</td>
|
|
42
|
+
<td>
|
|
43
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v100">
|
|
44
|
+
1.0.0 Release Notes
|
|
45
|
+
</a>
|
|
46
|
+
</td>
|
|
47
|
+
</tr>
|
|
48
|
+
<tr>
|
|
49
|
+
<td>0.9.1</td>
|
|
50
|
+
<td>2026-05-04</td>
|
|
51
|
+
<td>
|
|
52
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v091">
|
|
53
|
+
0.9.1 Release Notes
|
|
54
|
+
</a>
|
|
55
|
+
</td>
|
|
56
|
+
</tr>
|
|
57
|
+
<tr>
|
|
58
|
+
<td>0.9.0</td>
|
|
59
|
+
<td>2026-04-15</td>
|
|
60
|
+
<td>
|
|
61
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v090">
|
|
62
|
+
0.9.0 Release Notes
|
|
63
|
+
</a>
|
|
64
|
+
</td>
|
|
65
|
+
</tr>
|
|
66
|
+
<tr>
|
|
67
|
+
<td>0.8.0</td>
|
|
68
|
+
<td>2026-02-23</td>
|
|
69
|
+
<td>
|
|
70
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v080">
|
|
71
|
+
0.8.0 Release Notes
|
|
72
|
+
</a>
|
|
73
|
+
</td>
|
|
74
|
+
</tr>
|
|
75
|
+
<tr>
|
|
76
|
+
<td>0.7.0</td>
|
|
77
|
+
<td>2026-01-21</td>
|
|
78
|
+
<td>
|
|
79
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v070">
|
|
80
|
+
0.7.0 Release Notes
|
|
81
|
+
</a>
|
|
82
|
+
</td>
|
|
83
|
+
</tr>
|
|
84
|
+
<tr>
|
|
85
|
+
<td>0.6.1</td>
|
|
86
|
+
<td>2025-12-01</td>
|
|
87
|
+
<td>
|
|
88
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v061">
|
|
89
|
+
0.6.1 Release Notes
|
|
90
|
+
</a>
|
|
91
|
+
</td>
|
|
92
|
+
</tr>
|
|
93
|
+
<tr>
|
|
94
|
+
<td>0.6.0</td>
|
|
95
|
+
<td>2025-11-18</td>
|
|
96
|
+
<td>
|
|
97
|
+
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v060">
|
|
98
|
+
0.6.0 Release Notes
|
|
99
|
+
</a>
|
|
100
|
+
</td>
|
|
101
|
+
</tr>
|
|
102
|
+
</table>
|
|
103
|
+
|
|
104
|
+
## Packages Overview
|
|
105
|
+
|
|
106
|
+
We offer the following PyPI packages to create conversational experiences based on Agents:
|
|
107
|
+
|
|
108
|
+
| Package Name | PyPI Version | Description |
|
|
109
|
+
|--------------|-------------|-------------|
|
|
110
|
+
| `microsoft-agents-activity` | [](https://pypi.org/project/microsoft-agents-activity/) | Types and validators implementing the Activity protocol spec. |
|
|
111
|
+
| `microsoft-agents-hosting-core` | [](https://pypi.org/project/microsoft-agents-hosting-core/) | Core library for Microsoft Agents hosting. |
|
|
112
|
+
| `microsoft-agents-hosting-aiohttp` | [](https://pypi.org/project/microsoft-agents-hosting-aiohttp/) | Configures aiohttp to run the Agent. |
|
|
113
|
+
| `microsoft-agents-hosting-fastapi` | [](https://pypi.org/project/microsoft-agents-hosting-fastapi/) | Configures fastapi to run the Agent. |
|
|
114
|
+
| `microsoft-agents-hosting-msteams` | [](https://pypi.org/project/microsoft-agents-hosting-msteams/) | Provides classes to host an Agent for Teams. |
|
|
115
|
+
| `microsoft-agents-hosting-dialogs` | [](https://pypi.org/project/microsoft-agents-hosting-dialogs/) | Dialog system with waterfall dialogs, prompts, and multi-turn conversation management. |
|
|
116
|
+
| `microsoft-agents-hosting-slack` | [](https://pypi.org/project/microsoft-agents-hosting-slack/) | Provides classes to host an Agent for Slack. |
|
|
117
|
+
| `microsoft-agents-storage-blob` | [](https://pypi.org/project/microsoft-agents-storage-blob/) | Extension to use Azure Blob as storage. |
|
|
118
|
+
| `microsoft-agents-storage-cosmos` | [](https://pypi.org/project/microsoft-agents-storage-cosmos/) | Extension to use CosmosDB as storage. |
|
|
119
|
+
| `microsoft-agents-authentication-msal` | [](https://pypi.org/project/microsoft-agents-authentication-msal/) | MSAL-based authentication for Microsoft Agents. |
|
|
120
|
+
| `microsoft-agents-authentication-entra-auth-sidecar` | [](https://pypi.org/project/microsoft-agents-authentication-entra-auth-sidecar/) | Credential-free Entra ID Agent ID authentication via the sidecar. |
|
|
121
|
+
|
|
122
|
+
## Features
|
|
123
|
+
|
|
124
|
+
- FastAPI integration for Microsoft Agents
|
|
125
|
+
- JWT authorization middleware
|
|
126
|
+
- Channel service API endpoints
|
|
127
|
+
- Streaming response support
|
|
128
|
+
- Cloud adapter for processing agent activities
|
|
129
|
+
|
|
130
|
+
## Installation
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
pip install microsoft-agents-hosting-fastapi
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Usage
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from fastapi import FastAPI, Request
|
|
140
|
+
from microsoft_agents.hosting.fastapi import start_agent_process, CloudAdapter
|
|
141
|
+
from microsoft_agents.hosting.core.app import AgentApplication
|
|
142
|
+
|
|
143
|
+
app = FastAPI()
|
|
144
|
+
connection_manager = MsalConnectionManager(**agents_sdk_config)
|
|
145
|
+
adapter = CloudAdapter(connection_manager=connection_manager)
|
|
146
|
+
agent_app = AgentApplication()
|
|
147
|
+
|
|
148
|
+
@app.post("/api/messages")
|
|
149
|
+
async def messages(request: Request):
|
|
150
|
+
return await start_agent_process(request, agent_app, adapter)
|
|
151
|
+
```
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: microsoft-agents-hosting-fastapi
|
|
3
|
-
Version: 1.2.0.dev20
|
|
4
|
-
Summary: Integration library for Microsoft Agents with FastAPI
|
|
5
|
-
Author: Microsoft Corporation
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/microsoft/Agents
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Operating System :: OS Independent
|
|
10
|
-
Requires-Python: >=3.10
|
|
11
|
-
Description-Content-Type: text/markdown
|
|
12
|
-
License-File: LICENSE
|
|
13
|
-
Requires-Dist: microsoft-agents-hosting-core==1.2.0.dev20
|
|
14
|
-
Requires-Dist: fastapi>=0.104.0
|
|
15
|
-
Requires-Dist: starlette>=1.0.1
|
|
16
|
-
Dynamic: license-file
|
|
17
|
-
Dynamic: requires-dist
|
|
18
|
-
|
|
19
|
-
# Microsoft Agents Hosting FastAPI
|
|
20
|
-
|
|
21
|
-
This library provides FastAPI integration for Microsoft Agents, enabling you to build conversational agents using the FastAPI web framework.
|
|
22
|
-
|
|
23
|
-
## Release Notes
|
|
24
|
-
<table style="width:100%">
|
|
25
|
-
<tr>
|
|
26
|
-
<th style="width:20%">Version</th>
|
|
27
|
-
<th style="width:20%">Date</th>
|
|
28
|
-
<th style="width:60%">Release Notes</th>
|
|
29
|
-
</tr>
|
|
30
|
-
<tr>
|
|
31
|
-
<td>1.1.0</td>
|
|
32
|
-
<td>2026-06-19</td>
|
|
33
|
-
<td>
|
|
34
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v110">
|
|
35
|
-
1.1.0 Release Notes
|
|
36
|
-
</a>
|
|
37
|
-
</td>
|
|
38
|
-
</tr>
|
|
39
|
-
<tr>
|
|
40
|
-
<td>1.0.0</td>
|
|
41
|
-
<td>2026-05-22</td>
|
|
42
|
-
<td>
|
|
43
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v100">
|
|
44
|
-
1.0.0 Release Notes
|
|
45
|
-
</a>
|
|
46
|
-
</td>
|
|
47
|
-
</tr>
|
|
48
|
-
<tr>
|
|
49
|
-
<td>0.9.0</td>
|
|
50
|
-
<td>2026-04-15</td>
|
|
51
|
-
<td>
|
|
52
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v090">
|
|
53
|
-
0.9.0 Release Notes
|
|
54
|
-
</a>
|
|
55
|
-
</td>
|
|
56
|
-
</tr>
|
|
57
|
-
<tr>
|
|
58
|
-
<td>0.8.0</td>
|
|
59
|
-
<td>2026-02-23</td>
|
|
60
|
-
<td>
|
|
61
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v080">
|
|
62
|
-
0.8.0 Release Notes
|
|
63
|
-
</a>
|
|
64
|
-
</td>
|
|
65
|
-
</tr>
|
|
66
|
-
<tr>
|
|
67
|
-
<td>0.7.0</td>
|
|
68
|
-
<td>2026-01-21</td>
|
|
69
|
-
<td>
|
|
70
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v070">
|
|
71
|
-
0.7.0 Release Notes
|
|
72
|
-
</a>
|
|
73
|
-
</td>
|
|
74
|
-
</tr>
|
|
75
|
-
<tr>
|
|
76
|
-
<td>0.6.1</td>
|
|
77
|
-
<td>2025-12-01</td>
|
|
78
|
-
<td>
|
|
79
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v061">
|
|
80
|
-
0.6.1 Release Notes
|
|
81
|
-
</a>
|
|
82
|
-
</td>
|
|
83
|
-
</tr>
|
|
84
|
-
<tr>
|
|
85
|
-
<td>0.6.0</td>
|
|
86
|
-
<td>2025-11-18</td>
|
|
87
|
-
<td>
|
|
88
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v060">
|
|
89
|
-
0.6.0 Release Notes
|
|
90
|
-
</a>
|
|
91
|
-
</td>
|
|
92
|
-
</tr>
|
|
93
|
-
</table>
|
|
94
|
-
|
|
95
|
-
## Features
|
|
96
|
-
|
|
97
|
-
- FastAPI integration for Microsoft Agents
|
|
98
|
-
- JWT authorization middleware
|
|
99
|
-
- Channel service API endpoints
|
|
100
|
-
- Streaming response support
|
|
101
|
-
- Cloud adapter for processing agent activities
|
|
102
|
-
|
|
103
|
-
## Installation
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
pip install microsoft-agents-hosting-fastapi
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## Usage
|
|
110
|
-
|
|
111
|
-
```python
|
|
112
|
-
from fastapi import FastAPI, Request
|
|
113
|
-
from microsoft_agents.hosting.fastapi import start_agent_process, CloudAdapter
|
|
114
|
-
from microsoft_agents.hosting.core.app import AgentApplication
|
|
115
|
-
|
|
116
|
-
app = FastAPI()
|
|
117
|
-
adapter = CloudAdapter()
|
|
118
|
-
agent_app = AgentApplication()
|
|
119
|
-
|
|
120
|
-
@app.post("/api/messages")
|
|
121
|
-
async def messages(request: Request):
|
|
122
|
-
return await start_agent_process(request, agent_app, adapter)
|
|
123
|
-
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.2.0.dev20
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
from fastapi import Request
|
|
2
|
-
from fastapi.responses import JSONResponse
|
|
3
|
-
import logging
|
|
4
|
-
from starlette.types import ASGIApp, Receive, Scope, Send
|
|
5
|
-
from microsoft_agents.hosting.core import (
|
|
6
|
-
AgentAuthConfiguration,
|
|
7
|
-
JwtTokenValidator,
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
logger = logging.getLogger(__name__)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class JwtAuthorizationMiddleware:
|
|
14
|
-
"""Starlette-compatible ASGI middleware for JWT authorization.
|
|
15
|
-
|
|
16
|
-
Usage:
|
|
17
|
-
from fastapi import FastAPI
|
|
18
|
-
|
|
19
|
-
app = FastAPI()
|
|
20
|
-
app.add_middleware(JwtAuthorizationMiddleware)
|
|
21
|
-
"""
|
|
22
|
-
|
|
23
|
-
def __init__(self, app: ASGIApp):
|
|
24
|
-
self.app = app
|
|
25
|
-
|
|
26
|
-
async def __call__(self, scope: Scope, receive: Receive, send: Send):
|
|
27
|
-
if scope["type"] == "lifespan":
|
|
28
|
-
await self.app(scope, receive, send)
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
app = scope.get("app")
|
|
32
|
-
state = getattr(app, "state", None) if app else None
|
|
33
|
-
auth_config: AgentAuthConfiguration = getattr(
|
|
34
|
-
state, "agent_configuration", None
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
request = Request(scope, receive=receive)
|
|
38
|
-
token_validator = JwtTokenValidator(auth_config)
|
|
39
|
-
auth_header = request.headers.get("Authorization")
|
|
40
|
-
|
|
41
|
-
if auth_header:
|
|
42
|
-
parts = auth_header.split(" ")
|
|
43
|
-
if len(parts) == 2 and parts[0].lower() == "bearer":
|
|
44
|
-
token = parts[1]
|
|
45
|
-
try:
|
|
46
|
-
claims = await token_validator.validate_token(token)
|
|
47
|
-
request.state.claims_identity = claims
|
|
48
|
-
except ValueError as e:
|
|
49
|
-
logger.warning("JWT validation error: %s", e)
|
|
50
|
-
response = JSONResponse(
|
|
51
|
-
{"error": "Invalid token or authentication failed."},
|
|
52
|
-
status_code=401,
|
|
53
|
-
)
|
|
54
|
-
await response(scope, receive, send)
|
|
55
|
-
return
|
|
56
|
-
else:
|
|
57
|
-
response = JSONResponse(
|
|
58
|
-
{"error": "Invalid authorization header format"},
|
|
59
|
-
status_code=401,
|
|
60
|
-
)
|
|
61
|
-
await response(scope, receive, send)
|
|
62
|
-
return
|
|
63
|
-
else:
|
|
64
|
-
if auth_config.ANONYMOUS_ALLOWED:
|
|
65
|
-
request.state.claims_identity = token_validator.get_anonymous_claims()
|
|
66
|
-
else:
|
|
67
|
-
response = JSONResponse(
|
|
68
|
-
{"error": "Authorization header not found"},
|
|
69
|
-
status_code=401,
|
|
70
|
-
)
|
|
71
|
-
await response(scope, receive, send)
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
await self.app(scope, receive, send)
|
microsoft_agents_hosting_fastapi-1.2.0.dev20/microsoft_agents_hosting_fastapi.egg-info/PKG-INFO
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: microsoft-agents-hosting-fastapi
|
|
3
|
-
Version: 1.2.0.dev20
|
|
4
|
-
Summary: Integration library for Microsoft Agents with FastAPI
|
|
5
|
-
Author: Microsoft Corporation
|
|
6
|
-
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/microsoft/Agents
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Operating System :: OS Independent
|
|
10
|
-
Requires-Python: >=3.10
|
|
11
|
-
Description-Content-Type: text/markdown
|
|
12
|
-
License-File: LICENSE
|
|
13
|
-
Requires-Dist: microsoft-agents-hosting-core==1.2.0.dev20
|
|
14
|
-
Requires-Dist: fastapi>=0.104.0
|
|
15
|
-
Requires-Dist: starlette>=1.0.1
|
|
16
|
-
Dynamic: license-file
|
|
17
|
-
Dynamic: requires-dist
|
|
18
|
-
|
|
19
|
-
# Microsoft Agents Hosting FastAPI
|
|
20
|
-
|
|
21
|
-
This library provides FastAPI integration for Microsoft Agents, enabling you to build conversational agents using the FastAPI web framework.
|
|
22
|
-
|
|
23
|
-
## Release Notes
|
|
24
|
-
<table style="width:100%">
|
|
25
|
-
<tr>
|
|
26
|
-
<th style="width:20%">Version</th>
|
|
27
|
-
<th style="width:20%">Date</th>
|
|
28
|
-
<th style="width:60%">Release Notes</th>
|
|
29
|
-
</tr>
|
|
30
|
-
<tr>
|
|
31
|
-
<td>1.1.0</td>
|
|
32
|
-
<td>2026-06-19</td>
|
|
33
|
-
<td>
|
|
34
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v110">
|
|
35
|
-
1.1.0 Release Notes
|
|
36
|
-
</a>
|
|
37
|
-
</td>
|
|
38
|
-
</tr>
|
|
39
|
-
<tr>
|
|
40
|
-
<td>1.0.0</td>
|
|
41
|
-
<td>2026-05-22</td>
|
|
42
|
-
<td>
|
|
43
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v100">
|
|
44
|
-
1.0.0 Release Notes
|
|
45
|
-
</a>
|
|
46
|
-
</td>
|
|
47
|
-
</tr>
|
|
48
|
-
<tr>
|
|
49
|
-
<td>0.9.0</td>
|
|
50
|
-
<td>2026-04-15</td>
|
|
51
|
-
<td>
|
|
52
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v090">
|
|
53
|
-
0.9.0 Release Notes
|
|
54
|
-
</a>
|
|
55
|
-
</td>
|
|
56
|
-
</tr>
|
|
57
|
-
<tr>
|
|
58
|
-
<td>0.8.0</td>
|
|
59
|
-
<td>2026-02-23</td>
|
|
60
|
-
<td>
|
|
61
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v080">
|
|
62
|
-
0.8.0 Release Notes
|
|
63
|
-
</a>
|
|
64
|
-
</td>
|
|
65
|
-
</tr>
|
|
66
|
-
<tr>
|
|
67
|
-
<td>0.7.0</td>
|
|
68
|
-
<td>2026-01-21</td>
|
|
69
|
-
<td>
|
|
70
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v070">
|
|
71
|
-
0.7.0 Release Notes
|
|
72
|
-
</a>
|
|
73
|
-
</td>
|
|
74
|
-
</tr>
|
|
75
|
-
<tr>
|
|
76
|
-
<td>0.6.1</td>
|
|
77
|
-
<td>2025-12-01</td>
|
|
78
|
-
<td>
|
|
79
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v061">
|
|
80
|
-
0.6.1 Release Notes
|
|
81
|
-
</a>
|
|
82
|
-
</td>
|
|
83
|
-
</tr>
|
|
84
|
-
<tr>
|
|
85
|
-
<td>0.6.0</td>
|
|
86
|
-
<td>2025-11-18</td>
|
|
87
|
-
<td>
|
|
88
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v060">
|
|
89
|
-
0.6.0 Release Notes
|
|
90
|
-
</a>
|
|
91
|
-
</td>
|
|
92
|
-
</tr>
|
|
93
|
-
</table>
|
|
94
|
-
|
|
95
|
-
## Features
|
|
96
|
-
|
|
97
|
-
- FastAPI integration for Microsoft Agents
|
|
98
|
-
- JWT authorization middleware
|
|
99
|
-
- Channel service API endpoints
|
|
100
|
-
- Streaming response support
|
|
101
|
-
- Cloud adapter for processing agent activities
|
|
102
|
-
|
|
103
|
-
## Installation
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
pip install microsoft-agents-hosting-fastapi
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## Usage
|
|
110
|
-
|
|
111
|
-
```python
|
|
112
|
-
from fastapi import FastAPI, Request
|
|
113
|
-
from microsoft_agents.hosting.fastapi import start_agent_process, CloudAdapter
|
|
114
|
-
from microsoft_agents.hosting.core.app import AgentApplication
|
|
115
|
-
|
|
116
|
-
app = FastAPI()
|
|
117
|
-
adapter = CloudAdapter()
|
|
118
|
-
agent_app = AgentApplication()
|
|
119
|
-
|
|
120
|
-
@app.post("/api/messages")
|
|
121
|
-
async def messages(request: Request):
|
|
122
|
-
return await start_agent_process(request, agent_app, adapter)
|
|
123
|
-
```
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
# Microsoft Agents Hosting FastAPI
|
|
2
|
-
|
|
3
|
-
This library provides FastAPI integration for Microsoft Agents, enabling you to build conversational agents using the FastAPI web framework.
|
|
4
|
-
|
|
5
|
-
## Release Notes
|
|
6
|
-
<table style="width:100%">
|
|
7
|
-
<tr>
|
|
8
|
-
<th style="width:20%">Version</th>
|
|
9
|
-
<th style="width:20%">Date</th>
|
|
10
|
-
<th style="width:60%">Release Notes</th>
|
|
11
|
-
</tr>
|
|
12
|
-
<tr>
|
|
13
|
-
<td>1.1.0</td>
|
|
14
|
-
<td>2026-06-19</td>
|
|
15
|
-
<td>
|
|
16
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v110">
|
|
17
|
-
1.1.0 Release Notes
|
|
18
|
-
</a>
|
|
19
|
-
</td>
|
|
20
|
-
</tr>
|
|
21
|
-
<tr>
|
|
22
|
-
<td>1.0.0</td>
|
|
23
|
-
<td>2026-05-22</td>
|
|
24
|
-
<td>
|
|
25
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v100">
|
|
26
|
-
1.0.0 Release Notes
|
|
27
|
-
</a>
|
|
28
|
-
</td>
|
|
29
|
-
</tr>
|
|
30
|
-
<tr>
|
|
31
|
-
<td>0.9.0</td>
|
|
32
|
-
<td>2026-04-15</td>
|
|
33
|
-
<td>
|
|
34
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v090">
|
|
35
|
-
0.9.0 Release Notes
|
|
36
|
-
</a>
|
|
37
|
-
</td>
|
|
38
|
-
</tr>
|
|
39
|
-
<tr>
|
|
40
|
-
<td>0.8.0</td>
|
|
41
|
-
<td>2026-02-23</td>
|
|
42
|
-
<td>
|
|
43
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v080">
|
|
44
|
-
0.8.0 Release Notes
|
|
45
|
-
</a>
|
|
46
|
-
</td>
|
|
47
|
-
</tr>
|
|
48
|
-
<tr>
|
|
49
|
-
<td>0.7.0</td>
|
|
50
|
-
<td>2026-01-21</td>
|
|
51
|
-
<td>
|
|
52
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v070">
|
|
53
|
-
0.7.0 Release Notes
|
|
54
|
-
</a>
|
|
55
|
-
</td>
|
|
56
|
-
</tr>
|
|
57
|
-
<tr>
|
|
58
|
-
<td>0.6.1</td>
|
|
59
|
-
<td>2025-12-01</td>
|
|
60
|
-
<td>
|
|
61
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v061">
|
|
62
|
-
0.6.1 Release Notes
|
|
63
|
-
</a>
|
|
64
|
-
</td>
|
|
65
|
-
</tr>
|
|
66
|
-
<tr>
|
|
67
|
-
<td>0.6.0</td>
|
|
68
|
-
<td>2025-11-18</td>
|
|
69
|
-
<td>
|
|
70
|
-
<a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md#microsoft-365-agents-sdk-for-python---release-notes-v060">
|
|
71
|
-
0.6.0 Release Notes
|
|
72
|
-
</a>
|
|
73
|
-
</td>
|
|
74
|
-
</tr>
|
|
75
|
-
</table>
|
|
76
|
-
|
|
77
|
-
## Features
|
|
78
|
-
|
|
79
|
-
- FastAPI integration for Microsoft Agents
|
|
80
|
-
- JWT authorization middleware
|
|
81
|
-
- Channel service API endpoints
|
|
82
|
-
- Streaming response support
|
|
83
|
-
- Cloud adapter for processing agent activities
|
|
84
|
-
|
|
85
|
-
## Installation
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
pip install microsoft-agents-hosting-fastapi
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Usage
|
|
92
|
-
|
|
93
|
-
```python
|
|
94
|
-
from fastapi import FastAPI, Request
|
|
95
|
-
from microsoft_agents.hosting.fastapi import start_agent_process, CloudAdapter
|
|
96
|
-
from microsoft_agents.hosting.core.app import AgentApplication
|
|
97
|
-
|
|
98
|
-
app = FastAPI()
|
|
99
|
-
adapter = CloudAdapter()
|
|
100
|
-
agent_app = AgentApplication()
|
|
101
|
-
|
|
102
|
-
@app.post("/api/messages")
|
|
103
|
-
async def messages(request: Request):
|
|
104
|
-
return await start_agent_process(request, agent_app, adapter)
|
|
105
|
-
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|