livekit-plugins-atmee 0.1.0__py3-none-any.whl
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.
- livekit/plugins/atmee/__init__.py +63 -0
- livekit/plugins/atmee/api.py +447 -0
- livekit/plugins/atmee/avatar.py +275 -0
- livekit/plugins/atmee/log.py +3 -0
- livekit/plugins/atmee/py.typed +0 -0
- livekit/plugins/atmee/version.py +15 -0
- livekit_plugins_atmee-0.1.0.dist-info/METADATA +195 -0
- livekit_plugins_atmee-0.1.0.dist-info/RECORD +10 -0
- livekit_plugins_atmee-0.1.0.dist-info/WHEEL +4 -0
- livekit_plugins_atmee-0.1.0.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Copyright 2026 Atmanity
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Atmee avatar plugin for LiveKit Agents.
|
|
16
|
+
|
|
17
|
+
Bring your own LiveKit voice agent; Atmee renders a talking-head avatar from a
|
|
18
|
+
single portrait into your room and bills per minute::
|
|
19
|
+
|
|
20
|
+
from livekit.plugins import atmee
|
|
21
|
+
|
|
22
|
+
avatar_id = await atmee.AtmeeAPI().create_avatar(name="Val", image="portrait.jpg")
|
|
23
|
+
|
|
24
|
+
avatar = atmee.AvatarSession(avatar_id=avatar_id) # ATMEE_API_KEY in the environment
|
|
25
|
+
await avatar.start(session, room=ctx.room)
|
|
26
|
+
await session.start(agent=..., room=ctx.room) # the agent's TTS drives the avatar's video
|
|
27
|
+
|
|
28
|
+
See https://github.com/Atmanity/atmee_livekit_plugin for the architecture notes.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
from .api import (
|
|
32
|
+
AtmeeAPI,
|
|
33
|
+
AtmeeAvatarNotReadyError,
|
|
34
|
+
AtmeeException,
|
|
35
|
+
AtmeeNoCapacityError,
|
|
36
|
+
AvatarInfo,
|
|
37
|
+
AvatarSessionInfo,
|
|
38
|
+
)
|
|
39
|
+
from .avatar import AvatarSession
|
|
40
|
+
from .version import __version__
|
|
41
|
+
|
|
42
|
+
__all__ = [
|
|
43
|
+
"AtmeeAPI",
|
|
44
|
+
"AtmeeAvatarNotReadyError",
|
|
45
|
+
"AtmeeException",
|
|
46
|
+
"AtmeeNoCapacityError",
|
|
47
|
+
"AvatarInfo",
|
|
48
|
+
"AvatarSession",
|
|
49
|
+
"AvatarSessionInfo",
|
|
50
|
+
"__version__",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
from livekit.agents import Plugin
|
|
54
|
+
|
|
55
|
+
from .log import logger
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class AtmeePlugin(Plugin):
|
|
59
|
+
def __init__(self) -> None:
|
|
60
|
+
super().__init__(__name__, __version__, __package__, logger)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Plugin.register_plugin(AtmeePlugin())
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
# Copyright 2026 Atmanity
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Thin async client for the Atmee API (session_service) used by the plugin.
|
|
16
|
+
|
|
17
|
+
Two resources matter here: **avatars** (create one from a portrait, read its
|
|
18
|
+
status) and **avatar sessions** (render an avatar into your LiveKit room for
|
|
19
|
+
your agent, end it). Authentication is your Atmee API key (``sk_atmee_...``)
|
|
20
|
+
in the ``X-Api-Key`` header; the key never reaches a browser.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
import asyncio
|
|
26
|
+
import mimetypes
|
|
27
|
+
import os
|
|
28
|
+
from dataclasses import dataclass, field
|
|
29
|
+
from pathlib import Path
|
|
30
|
+
from typing import Any, Literal
|
|
31
|
+
|
|
32
|
+
import aiohttp
|
|
33
|
+
|
|
34
|
+
from livekit.agents import (
|
|
35
|
+
DEFAULT_API_CONNECT_OPTIONS,
|
|
36
|
+
NOT_GIVEN,
|
|
37
|
+
APIConnectOptions,
|
|
38
|
+
NotGivenOr,
|
|
39
|
+
utils,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
from .log import logger
|
|
43
|
+
|
|
44
|
+
DEFAULT_API_URL = "https://api.atmanity.us"
|
|
45
|
+
|
|
46
|
+
WaitFor = Literal["initializing", "avatar_joined"]
|
|
47
|
+
|
|
48
|
+
# Overall budget of the start call: the worker acknowledges within seconds, but
|
|
49
|
+
# waiting for the avatar to join covers model priming on a cold pod (the
|
|
50
|
+
# server's own join timeout is 90 s) plus the room join.
|
|
51
|
+
_START_TOTAL_TIMEOUT: dict[str, float] = {"initializing": 60.0, "avatar_joined": 180.0}
|
|
52
|
+
_DEFAULT_TOTAL_TIMEOUT = 120.0
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class AtmeeException(Exception):
|
|
56
|
+
"""An Atmee API call failed.
|
|
57
|
+
|
|
58
|
+
``status_code`` is the HTTP status (0 when the request never got an
|
|
59
|
+
answer), ``code`` the machine-readable ``error`` field of the response
|
|
60
|
+
body when the API sent one (``invalid_livekit_token``,
|
|
61
|
+
``avatar_not_renderable``, ``insufficient_credits``, ...), and
|
|
62
|
+
``message`` its human-readable text.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
def __init__(self, message: str, *, status_code: int = 0, code: str | None = None) -> None:
|
|
66
|
+
super().__init__(message)
|
|
67
|
+
self.status_code = status_code
|
|
68
|
+
self.code = code
|
|
69
|
+
self.message = message
|
|
70
|
+
|
|
71
|
+
def __str__(self) -> str:
|
|
72
|
+
parts = [self.message]
|
|
73
|
+
if self.code:
|
|
74
|
+
parts.append(f"[{self.code}]")
|
|
75
|
+
if self.status_code:
|
|
76
|
+
parts.append(f"(HTTP {self.status_code})")
|
|
77
|
+
return " ".join(parts)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class AtmeeNoCapacityError(AtmeeException):
|
|
81
|
+
"""Every rendering worker is busy (HTTP 503 ``no_capacity``).
|
|
82
|
+
|
|
83
|
+
Never retried by the client: a render slot frees up on the order of
|
|
84
|
+
seconds to minutes, not the milliseconds a transport retry covers.
|
|
85
|
+
``retry_after`` is the server's hint in seconds, when it sent one.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
def __init__(self, message: str, *, retry_after: float | None = None) -> None:
|
|
89
|
+
super().__init__(message, status_code=503, code="no_capacity")
|
|
90
|
+
self.retry_after = retry_after
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class AtmeeAvatarNotReadyError(AtmeeException):
|
|
94
|
+
"""The avatar cannot be rendered yet (HTTP 409 ``avatar_not_renderable``):
|
|
95
|
+
it has no portrait, or its appearance is still being processed."""
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@dataclass
|
|
99
|
+
class AvatarSessionInfo:
|
|
100
|
+
"""The ``202`` body of ``POST /v1/avatars/{avatarId}/avatar_sessions``."""
|
|
101
|
+
|
|
102
|
+
session_id: str
|
|
103
|
+
status: str
|
|
104
|
+
avatar_participant_identity: str
|
|
105
|
+
agent_identity: str
|
|
106
|
+
room_name: str
|
|
107
|
+
max_duration_seconds: int
|
|
108
|
+
billing_mode: str
|
|
109
|
+
raw: dict[str, Any] = field(default_factory=dict, repr=False)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@dataclass
|
|
113
|
+
class AvatarInfo:
|
|
114
|
+
"""What ``GET /v1/avatars/{avatarId}`` (and a create) report about an avatar."""
|
|
115
|
+
|
|
116
|
+
avatar_id: str
|
|
117
|
+
status: str
|
|
118
|
+
kind: str | None = None
|
|
119
|
+
name: str | None = None
|
|
120
|
+
raw: dict[str, Any] = field(default_factory=dict, repr=False)
|
|
121
|
+
|
|
122
|
+
@property
|
|
123
|
+
def ready(self) -> bool:
|
|
124
|
+
return self.status == "ready"
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
_IMAGE_TYPES = {
|
|
128
|
+
".jpg": "image/jpeg",
|
|
129
|
+
".jpeg": "image/jpeg",
|
|
130
|
+
".png": "image/png",
|
|
131
|
+
".webp": "image/webp",
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class AtmeeAPI:
|
|
136
|
+
"""Async client for the Atmee API.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
api_key: your ``sk_atmee_...`` key; defaults to ``ATMEE_API_KEY``.
|
|
140
|
+
api_url: API base; defaults to ``ATMEE_API_URL`` or ``https://api.atmanity.us``.
|
|
141
|
+
conn_options: retry/timeout policy for transport failures and 5xx
|
|
142
|
+
answers (a 503 ``no_capacity`` is never retried).
|
|
143
|
+
session: an ``aiohttp.ClientSession`` to reuse. Inside a LiveKit job the
|
|
144
|
+
worker's shared session is used; outside (scripts, tests) a private
|
|
145
|
+
one is created and closed by :meth:`aclose`.
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
def __init__(
|
|
149
|
+
self,
|
|
150
|
+
api_key: NotGivenOr[str] = NOT_GIVEN,
|
|
151
|
+
api_url: NotGivenOr[str] = NOT_GIVEN,
|
|
152
|
+
*,
|
|
153
|
+
conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS,
|
|
154
|
+
session: aiohttp.ClientSession | None = None,
|
|
155
|
+
) -> None:
|
|
156
|
+
key = api_key or os.getenv("ATMEE_API_KEY")
|
|
157
|
+
if not key:
|
|
158
|
+
raise AtmeeException(
|
|
159
|
+
"ATMEE_API_KEY must be set (or pass api_key=...); create one in the Atmee "
|
|
160
|
+
"developer settings"
|
|
161
|
+
)
|
|
162
|
+
self._api_key = key
|
|
163
|
+
self._api_url = (api_url or os.getenv("ATMEE_API_URL") or DEFAULT_API_URL).rstrip("/")
|
|
164
|
+
self._conn_options = conn_options
|
|
165
|
+
self._session = session
|
|
166
|
+
self._owns_session = False
|
|
167
|
+
|
|
168
|
+
@property
|
|
169
|
+
def api_url(self) -> str:
|
|
170
|
+
return self._api_url
|
|
171
|
+
|
|
172
|
+
# --- avatar sessions -------------------------------------------------
|
|
173
|
+
|
|
174
|
+
async def create_avatar_session(
|
|
175
|
+
self,
|
|
176
|
+
avatar_id: str,
|
|
177
|
+
*,
|
|
178
|
+
livekit_url: str,
|
|
179
|
+
livekit_token: str,
|
|
180
|
+
agent_identity: str | None = None,
|
|
181
|
+
max_duration_seconds: int | None = None,
|
|
182
|
+
metadata: dict[str, Any] | None = None,
|
|
183
|
+
wait_for: WaitFor = "initializing",
|
|
184
|
+
) -> AvatarSessionInfo:
|
|
185
|
+
"""Render ``avatar_id`` into the room ``livekit_token`` grants.
|
|
186
|
+
|
|
187
|
+
``livekit_token`` is a LiveKit access token you minted with YOUR
|
|
188
|
+
project's secret for the avatar participant: ``kind=agent``, a
|
|
189
|
+
``roomJoin`` grant for your room, and the ``lk.publish_on_behalf``
|
|
190
|
+
attribute naming your agent (:class:`AvatarSession` does this for
|
|
191
|
+
you). Returns as soon as the rendering worker acknowledged the start,
|
|
192
|
+
or once the avatar joined with ``wait_for="avatar_joined"``.
|
|
193
|
+
"""
|
|
194
|
+
payload: dict[str, Any] = {"livekitUrl": livekit_url, "livekitToken": livekit_token}
|
|
195
|
+
if agent_identity:
|
|
196
|
+
payload["agentIdentity"] = agent_identity
|
|
197
|
+
if max_duration_seconds is not None:
|
|
198
|
+
payload["maxDurationSeconds"] = int(max_duration_seconds)
|
|
199
|
+
if metadata:
|
|
200
|
+
payload["metadata"] = metadata
|
|
201
|
+
params: dict[str, str] | None = (
|
|
202
|
+
{"waitFor": wait_for} if wait_for != "initializing" else None
|
|
203
|
+
)
|
|
204
|
+
# Never retried: the POST reserves and bills a session as soon as the
|
|
205
|
+
# server accepts it, so a retry after a timeout or a 5xx could open a
|
|
206
|
+
# second render for the same room. The caller decides whether to try
|
|
207
|
+
# again (the AvatarSession does not).
|
|
208
|
+
data = await self._request(
|
|
209
|
+
"POST",
|
|
210
|
+
f"/v1/avatars/{avatar_id}/avatar_sessions",
|
|
211
|
+
json=payload,
|
|
212
|
+
params=params,
|
|
213
|
+
retry=False,
|
|
214
|
+
total_timeout=_START_TOTAL_TIMEOUT[wait_for],
|
|
215
|
+
)
|
|
216
|
+
return AvatarSessionInfo(
|
|
217
|
+
session_id=str(data.get("sessionId", "")),
|
|
218
|
+
status=str(data.get("status", "")),
|
|
219
|
+
avatar_participant_identity=str(data.get("avatarParticipantIdentity", "")),
|
|
220
|
+
agent_identity=str(data.get("agentIdentity", "")),
|
|
221
|
+
room_name=str(data.get("roomName", "")),
|
|
222
|
+
max_duration_seconds=int(data.get("maxDurationSeconds") or 0),
|
|
223
|
+
billing_mode=str(data.get("billingMode", "")),
|
|
224
|
+
raw=data,
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
async def end_avatar_session(self, session_id: str) -> dict[str, Any]:
|
|
228
|
+
"""Stop billing for a session now. Idempotent: ending an ended session
|
|
229
|
+
answers normally with ``alreadyEnded: true``. Does not remove the avatar
|
|
230
|
+
from your room — :meth:`AvatarSession.aclose` does that."""
|
|
231
|
+
return await self._request("POST", f"/v1/avatar_sessions/{session_id}/end")
|
|
232
|
+
|
|
233
|
+
async def get_avatar_session(self, session_id: str) -> dict[str, Any]:
|
|
234
|
+
return await self._request("GET", f"/v1/avatar_sessions/{session_id}")
|
|
235
|
+
|
|
236
|
+
# --- avatars -----------------------------------------------------------
|
|
237
|
+
|
|
238
|
+
async def create_avatar(
|
|
239
|
+
self,
|
|
240
|
+
name: str,
|
|
241
|
+
image: str | Path | bytes,
|
|
242
|
+
*,
|
|
243
|
+
description: str | None = None,
|
|
244
|
+
content_type: str | None = None,
|
|
245
|
+
) -> str:
|
|
246
|
+
"""Create a render-only avatar from a single portrait and return its id.
|
|
247
|
+
|
|
248
|
+
``image`` is a local file path, the image bytes, or an ``https://``
|
|
249
|
+
URL the Atmee service can download. A portrait-only avatar is ready
|
|
250
|
+
at once; nothing to poll. Add a voice later in the Atmee studio (or
|
|
251
|
+
``PUT /v1/avatars/{id}/voice``) to make it conversational as well.
|
|
252
|
+
"""
|
|
253
|
+
info = await self.create_avatar_info(
|
|
254
|
+
name, image, description=description, content_type=content_type
|
|
255
|
+
)
|
|
256
|
+
return info.avatar_id
|
|
257
|
+
|
|
258
|
+
async def create_avatar_info(
|
|
259
|
+
self,
|
|
260
|
+
name: str,
|
|
261
|
+
image: str | Path | bytes,
|
|
262
|
+
*,
|
|
263
|
+
description: str | None = None,
|
|
264
|
+
content_type: str | None = None,
|
|
265
|
+
) -> AvatarInfo:
|
|
266
|
+
"""Like :meth:`create_avatar`, returning the whole response."""
|
|
267
|
+
if isinstance(image, str) and _is_url(image):
|
|
268
|
+
manifest: dict[str, Any] = {
|
|
269
|
+
"schemaVersion": 1,
|
|
270
|
+
"name": name,
|
|
271
|
+
"assets": {"image": {"url": image}},
|
|
272
|
+
}
|
|
273
|
+
if description:
|
|
274
|
+
manifest["description"] = description
|
|
275
|
+
data = await self._request("POST", "/v1/avatars", json=manifest, retry=False)
|
|
276
|
+
return _avatar_info(data)
|
|
277
|
+
|
|
278
|
+
if isinstance(image, bytes | bytearray):
|
|
279
|
+
blob = bytes(image)
|
|
280
|
+
filename = "portrait" + _extension_for(content_type) if content_type else "portrait.jpg"
|
|
281
|
+
ctype = content_type or "image/jpeg"
|
|
282
|
+
else:
|
|
283
|
+
blob, filename, ctype = await asyncio.to_thread(_load_image_file, image, content_type)
|
|
284
|
+
form = aiohttp.FormData()
|
|
285
|
+
form.add_field("name", name)
|
|
286
|
+
if description:
|
|
287
|
+
form.add_field("description", description)
|
|
288
|
+
form.add_field("file", blob, filename=filename, content_type=ctype)
|
|
289
|
+
data = await self._request("POST", "/v1/avatars", data=form, retry=False)
|
|
290
|
+
return _avatar_info(data)
|
|
291
|
+
|
|
292
|
+
async def get_avatar(self, avatar_id: str) -> AvatarInfo:
|
|
293
|
+
return _avatar_info(await self._request("GET", f"/v1/avatars/{avatar_id}"))
|
|
294
|
+
|
|
295
|
+
async def wait_until_ready(
|
|
296
|
+
self, avatar_id: str, *, timeout: float = 600.0, poll_interval: float = 5.0
|
|
297
|
+
) -> AvatarInfo:
|
|
298
|
+
"""Poll until the avatar reports ``ready`` (a conversational avatar
|
|
299
|
+
builds asynchronously; a portrait-only one is ready immediately)."""
|
|
300
|
+
deadline = asyncio.get_running_loop().time() + timeout
|
|
301
|
+
while True:
|
|
302
|
+
info = await self.get_avatar(avatar_id)
|
|
303
|
+
if info.ready:
|
|
304
|
+
return info
|
|
305
|
+
if info.status == "failed":
|
|
306
|
+
raise AtmeeException(f"avatar {avatar_id} failed to build", code="avatar_failed")
|
|
307
|
+
if asyncio.get_running_loop().time() >= deadline:
|
|
308
|
+
raise AtmeeException(
|
|
309
|
+
f"avatar {avatar_id} not ready after {timeout:.0f}s (status {info.status})",
|
|
310
|
+
code="timeout",
|
|
311
|
+
)
|
|
312
|
+
await asyncio.sleep(poll_interval)
|
|
313
|
+
|
|
314
|
+
# --- plumbing ------------------------------------------------------------
|
|
315
|
+
|
|
316
|
+
def _ensure_session(self) -> aiohttp.ClientSession:
|
|
317
|
+
if self._session is not None and not self._session.closed:
|
|
318
|
+
return self._session
|
|
319
|
+
try:
|
|
320
|
+
self._session = utils.http_context.http_session()
|
|
321
|
+
except RuntimeError:
|
|
322
|
+
# Outside a LiveKit job (a script creating avatars, tests): own one.
|
|
323
|
+
self._session = aiohttp.ClientSession()
|
|
324
|
+
self._owns_session = True
|
|
325
|
+
return self._session
|
|
326
|
+
|
|
327
|
+
async def aclose(self) -> None:
|
|
328
|
+
"""Close the HTTP session if this client created it."""
|
|
329
|
+
if self._owns_session and self._session is not None and not self._session.closed:
|
|
330
|
+
await self._session.close()
|
|
331
|
+
self._session = None
|
|
332
|
+
self._owns_session = False
|
|
333
|
+
|
|
334
|
+
async def __aenter__(self) -> AtmeeAPI:
|
|
335
|
+
return self
|
|
336
|
+
|
|
337
|
+
async def __aexit__(self, *exc: object) -> None:
|
|
338
|
+
await self.aclose()
|
|
339
|
+
|
|
340
|
+
async def _request(
|
|
341
|
+
self,
|
|
342
|
+
method: str,
|
|
343
|
+
path: str,
|
|
344
|
+
*,
|
|
345
|
+
json: dict[str, Any] | None = None,
|
|
346
|
+
data: aiohttp.FormData | None = None,
|
|
347
|
+
params: dict[str, str] | None = None,
|
|
348
|
+
retry: bool = True,
|
|
349
|
+
total_timeout: float = _DEFAULT_TOTAL_TIMEOUT,
|
|
350
|
+
) -> dict[str, Any]:
|
|
351
|
+
"""One API call with the plugin's retry policy: transport errors and
|
|
352
|
+
5xx answers are retried ``conn_options.max_retry`` times; a 503
|
|
353
|
+
``no_capacity`` and every 4xx are final. ``retry=False`` for calls
|
|
354
|
+
that are not idempotent (creating a session or an avatar)."""
|
|
355
|
+
attempts = max(1, self._conn_options.max_retry) if retry else 1
|
|
356
|
+
last_error: Exception | None = None
|
|
357
|
+
for attempt in range(attempts):
|
|
358
|
+
try:
|
|
359
|
+
async with self._ensure_session().request(
|
|
360
|
+
method,
|
|
361
|
+
f"{self._api_url}{path}",
|
|
362
|
+
headers={"X-Api-Key": self._api_key, "Accept": "application/json"},
|
|
363
|
+
json=json,
|
|
364
|
+
data=data,
|
|
365
|
+
params=params,
|
|
366
|
+
timeout=aiohttp.ClientTimeout(
|
|
367
|
+
sock_connect=self._conn_options.timeout, total=total_timeout
|
|
368
|
+
),
|
|
369
|
+
) as response:
|
|
370
|
+
if response.ok:
|
|
371
|
+
if response.status == 204 or response.content_length == 0:
|
|
372
|
+
return {}
|
|
373
|
+
payload = await response.json(content_type=None)
|
|
374
|
+
return payload if isinstance(payload, dict) else {"data": payload}
|
|
375
|
+
raise await _error_from_response(response)
|
|
376
|
+
except AtmeeException as e:
|
|
377
|
+
if e.status_code >= 500 and not isinstance(e, AtmeeNoCapacityError):
|
|
378
|
+
last_error = e
|
|
379
|
+
else:
|
|
380
|
+
raise
|
|
381
|
+
except (aiohttp.ClientError, asyncio.TimeoutError) as e:
|
|
382
|
+
last_error = AtmeeException(f"could not reach the Atmee API: {e}")
|
|
383
|
+
if attempt < attempts - 1:
|
|
384
|
+
logger.warning(
|
|
385
|
+
"atmee api call failed; retrying",
|
|
386
|
+
extra={"path": path, "attempt": attempt + 1, "error": str(last_error)},
|
|
387
|
+
)
|
|
388
|
+
await asyncio.sleep(self._conn_options.retry_interval)
|
|
389
|
+
assert last_error is not None
|
|
390
|
+
raise last_error
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
async def _error_from_response(response: aiohttp.ClientResponse) -> AtmeeException:
|
|
394
|
+
text = await response.text()
|
|
395
|
+
code: str | None = None
|
|
396
|
+
message = text.strip() or response.reason or f"HTTP {response.status}"
|
|
397
|
+
try:
|
|
398
|
+
body = await response.json(content_type=None)
|
|
399
|
+
except Exception:
|
|
400
|
+
body = None
|
|
401
|
+
if isinstance(body, dict):
|
|
402
|
+
code = body.get("error") if isinstance(body.get("error"), str) else None
|
|
403
|
+
message = str(body.get("message") or body.get("detail") or message)
|
|
404
|
+
if response.status == 503 and code in (None, "no_capacity"):
|
|
405
|
+
retry_after: float | None = None
|
|
406
|
+
header = response.headers.get("Retry-After")
|
|
407
|
+
if header:
|
|
408
|
+
try:
|
|
409
|
+
retry_after = float(header)
|
|
410
|
+
except ValueError:
|
|
411
|
+
retry_after = None
|
|
412
|
+
return AtmeeNoCapacityError(message, retry_after=retry_after)
|
|
413
|
+
if response.status == 409 and code == "avatar_not_renderable":
|
|
414
|
+
return AtmeeAvatarNotReadyError(message, status_code=409, code=code)
|
|
415
|
+
return AtmeeException(message, status_code=response.status, code=code)
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
def _avatar_info(data: dict[str, Any]) -> AvatarInfo:
|
|
419
|
+
return AvatarInfo(
|
|
420
|
+
avatar_id=str(data.get("avatarId") or data.get("id") or ""),
|
|
421
|
+
status=str(data.get("status", "")),
|
|
422
|
+
kind=data.get("kind"),
|
|
423
|
+
name=data.get("name"),
|
|
424
|
+
raw=data,
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
def _is_url(value: str) -> bool:
|
|
429
|
+
return value.startswith(("http://", "https://"))
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
def _load_image_file(image: str | Path, content_type: str | None) -> tuple[bytes, str, str]:
|
|
433
|
+
path = Path(image)
|
|
434
|
+
ctype = (
|
|
435
|
+
content_type
|
|
436
|
+
or _IMAGE_TYPES.get(path.suffix.lower())
|
|
437
|
+
or mimetypes.guess_type(path.name)[0]
|
|
438
|
+
or "application/octet-stream"
|
|
439
|
+
)
|
|
440
|
+
return path.read_bytes(), path.name, ctype
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
def _extension_for(content_type: str) -> str:
|
|
444
|
+
for ext, ctype in _IMAGE_TYPES.items():
|
|
445
|
+
if ctype == content_type and ext != ".jpeg":
|
|
446
|
+
return ext
|
|
447
|
+
return mimetypes.guess_extension(content_type) or ""
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# Copyright 2026 Atmanity
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import asyncio
|
|
18
|
+
import os
|
|
19
|
+
from datetime import timedelta
|
|
20
|
+
from typing import Any, Literal
|
|
21
|
+
|
|
22
|
+
import aiohttp
|
|
23
|
+
|
|
24
|
+
from livekit import api, rtc
|
|
25
|
+
from livekit.agents import (
|
|
26
|
+
DEFAULT_API_CONNECT_OPTIONS,
|
|
27
|
+
NOT_GIVEN,
|
|
28
|
+
AgentSession,
|
|
29
|
+
APIConnectOptions,
|
|
30
|
+
NotGivenOr,
|
|
31
|
+
get_job_context,
|
|
32
|
+
utils,
|
|
33
|
+
)
|
|
34
|
+
from livekit.agents.voice.avatar import AvatarSession as BaseAvatarSession
|
|
35
|
+
from livekit.agents.voice.avatar import DataStreamAudioOutput
|
|
36
|
+
from livekit.agents.voice.room_io import ATTRIBUTE_PUBLISH_ON_BEHALF
|
|
37
|
+
|
|
38
|
+
from .api import AtmeeAPI, AtmeeException, AvatarSessionInfo, WaitFor
|
|
39
|
+
from .log import logger
|
|
40
|
+
|
|
41
|
+
# The rendering worker resamples nothing: it consumes 16 kHz mono PCM over the
|
|
42
|
+
# data stream, so the agent's audio tail is asked for exactly that.
|
|
43
|
+
SAMPLE_RATE = 16000
|
|
44
|
+
_AVATAR_AGENT_IDENTITY = "atmee-avatar-agent"
|
|
45
|
+
_AVATAR_AGENT_NAME = "atmee-avatar-agent"
|
|
46
|
+
# Ceiling of a session when none is given (also the most a session can bill
|
|
47
|
+
# if the agent dies without the worker ever reporting; server default).
|
|
48
|
+
DEFAULT_MAX_DURATION_SECONDS = 3600
|
|
49
|
+
# The avatar's token outlives the session ceiling by this much so a slow start
|
|
50
|
+
# never joins with an expired token.
|
|
51
|
+
_TOKEN_TTL_SLACK = timedelta(minutes=10)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class AvatarSession(BaseAvatarSession[Literal["avatar_disconnected"]]):
|
|
55
|
+
"""An Atmee avatar session: render an Atmee avatar into your agent's room.
|
|
56
|
+
|
|
57
|
+
The avatar joins the room as its own participant (``atmee-avatar-agent``)
|
|
58
|
+
publishing on behalf of your agent; your agent's audio output is replaced
|
|
59
|
+
by a data stream to it, and the avatar publishes synced video and audio.
|
|
60
|
+
Billing runs while the avatar is in the room and stops when your agent
|
|
61
|
+
leaves, the room closes, or :meth:`aclose` runs (which also removes the
|
|
62
|
+
avatar participant); a ceiling of ``max_duration_seconds`` bounds it.
|
|
63
|
+
|
|
64
|
+
Emits ``avatar_disconnected`` (the ``rtc.RemoteParticipant``) if the
|
|
65
|
+
avatar participant leaves the room while the session is still running,
|
|
66
|
+
for example because its rendering worker died.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
def __init__(
|
|
70
|
+
self,
|
|
71
|
+
*,
|
|
72
|
+
avatar_id: str,
|
|
73
|
+
api_url: NotGivenOr[str] = NOT_GIVEN,
|
|
74
|
+
api_key: NotGivenOr[str] = NOT_GIVEN,
|
|
75
|
+
avatar_participant_identity: NotGivenOr[str] = NOT_GIVEN,
|
|
76
|
+
avatar_participant_name: NotGivenOr[str] = NOT_GIVEN,
|
|
77
|
+
max_duration_seconds: int = DEFAULT_MAX_DURATION_SECONDS,
|
|
78
|
+
metadata: dict[str, Any] | None = None,
|
|
79
|
+
wait_for: WaitFor = "initializing",
|
|
80
|
+
conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS,
|
|
81
|
+
http_session: aiohttp.ClientSession | None = None,
|
|
82
|
+
) -> None:
|
|
83
|
+
"""
|
|
84
|
+
Args:
|
|
85
|
+
avatar_id: the Atmee avatar to render (``AtmeeAPI.create_avatar``).
|
|
86
|
+
api_key: your ``sk_atmee_...`` key; defaults to ``ATMEE_API_KEY``.
|
|
87
|
+
api_url: API base; defaults to ``ATMEE_API_URL`` or the Atmee cloud.
|
|
88
|
+
avatar_participant_identity: identity the avatar joins with
|
|
89
|
+
(``atmee-avatar-agent``). Set it when one room hosts several
|
|
90
|
+
avatars.
|
|
91
|
+
max_duration_seconds: hard ceiling of the session (default 3600).
|
|
92
|
+
metadata: free-form JSON attached to the session on the Atmee side.
|
|
93
|
+
wait_for: ``"initializing"`` (default) returns from :meth:`start`
|
|
94
|
+
once the worker acknowledged the start; ``"avatar_joined"``
|
|
95
|
+
blocks until the avatar is in the room.
|
|
96
|
+
http_session: an aiohttp session to reuse; the job's shared one by
|
|
97
|
+
default.
|
|
98
|
+
"""
|
|
99
|
+
super().__init__()
|
|
100
|
+
if not avatar_id:
|
|
101
|
+
raise AtmeeException("avatar_id is required")
|
|
102
|
+
self._avatar_id = avatar_id
|
|
103
|
+
self._max_duration_seconds = int(max_duration_seconds)
|
|
104
|
+
self._metadata = metadata
|
|
105
|
+
self._wait_for: WaitFor = wait_for
|
|
106
|
+
self._conn_options = conn_options
|
|
107
|
+
self._http_session = http_session
|
|
108
|
+
self._api = AtmeeAPI(
|
|
109
|
+
api_key=api_key,
|
|
110
|
+
api_url=api_url,
|
|
111
|
+
conn_options=conn_options,
|
|
112
|
+
session=self._ensure_http_session(),
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
self._avatar_participant_identity = avatar_participant_identity or _AVATAR_AGENT_IDENTITY
|
|
116
|
+
self._avatar_participant_name = avatar_participant_name or _AVATAR_AGENT_NAME
|
|
117
|
+
|
|
118
|
+
self.session_id: str | None = None
|
|
119
|
+
"""The Atmee avatar session id once :meth:`start` returned."""
|
|
120
|
+
self.session_info: AvatarSessionInfo | None = None
|
|
121
|
+
"""The full start response once :meth:`start` returned."""
|
|
122
|
+
|
|
123
|
+
self._end_task: asyncio.Task[None] | None = None
|
|
124
|
+
self._ended = False
|
|
125
|
+
self._room_for_events: rtc.Room | None = None
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def avatar_identity(self) -> str:
|
|
129
|
+
return self._avatar_participant_identity
|
|
130
|
+
|
|
131
|
+
@property
|
|
132
|
+
def provider(self) -> str:
|
|
133
|
+
return "atmee"
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def api(self) -> AtmeeAPI:
|
|
137
|
+
"""The API client this session uses (same key and base URL)."""
|
|
138
|
+
return self._api
|
|
139
|
+
|
|
140
|
+
def _ensure_http_session(self) -> aiohttp.ClientSession:
|
|
141
|
+
if self._http_session is None:
|
|
142
|
+
self._http_session = utils.http_context.http_session()
|
|
143
|
+
return self._http_session
|
|
144
|
+
|
|
145
|
+
async def start(
|
|
146
|
+
self,
|
|
147
|
+
agent_session: AgentSession[Any],
|
|
148
|
+
room: rtc.Room,
|
|
149
|
+
*,
|
|
150
|
+
livekit_url: NotGivenOr[str] = NOT_GIVEN,
|
|
151
|
+
livekit_api_key: NotGivenOr[str] = NOT_GIVEN,
|
|
152
|
+
livekit_api_secret: NotGivenOr[str] = NOT_GIVEN,
|
|
153
|
+
) -> None:
|
|
154
|
+
"""Start rendering the avatar into ``room`` for ``agent_session``.
|
|
155
|
+
|
|
156
|
+
Mints a LiveKit access token for the avatar participant with YOUR
|
|
157
|
+
project's credentials (``LIVEKIT_URL`` / ``LIVEKIT_API_KEY`` /
|
|
158
|
+
``LIVEKIT_API_SECRET`` or the arguments), asks Atmee to render into
|
|
159
|
+
the room, and routes the agent's audio to the avatar. Call before
|
|
160
|
+
``agent_session.start``.
|
|
161
|
+
"""
|
|
162
|
+
await super().start(agent_session, room)
|
|
163
|
+
|
|
164
|
+
livekit_url = livekit_url or (os.getenv("LIVEKIT_URL") or NOT_GIVEN)
|
|
165
|
+
livekit_api_key = livekit_api_key or (os.getenv("LIVEKIT_API_KEY") or NOT_GIVEN)
|
|
166
|
+
livekit_api_secret = livekit_api_secret or (os.getenv("LIVEKIT_API_SECRET") or NOT_GIVEN)
|
|
167
|
+
if not livekit_url or not livekit_api_key or not livekit_api_secret:
|
|
168
|
+
raise AtmeeException(
|
|
169
|
+
"livekit_url, livekit_api_key, and livekit_api_secret must be set "
|
|
170
|
+
"by arguments or environment variables"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
job_ctx = get_job_context(required=False)
|
|
174
|
+
local_participant_identity = (
|
|
175
|
+
job_ctx.local_participant_identity
|
|
176
|
+
if job_ctx is not None
|
|
177
|
+
else room.local_participant.identity
|
|
178
|
+
)
|
|
179
|
+
livekit_token = (
|
|
180
|
+
api.AccessToken(api_key=livekit_api_key, api_secret=livekit_api_secret)
|
|
181
|
+
.with_kind("agent")
|
|
182
|
+
.with_identity(self._avatar_participant_identity)
|
|
183
|
+
.with_name(self._avatar_participant_name)
|
|
184
|
+
.with_grants(api.VideoGrants(room_join=True, room=room.name))
|
|
185
|
+
# allow the avatar to publish audio and video on behalf of your local agent
|
|
186
|
+
.with_attributes({ATTRIBUTE_PUBLISH_ON_BEHALF: local_participant_identity})
|
|
187
|
+
.with_ttl(timedelta(seconds=self._max_duration_seconds) + _TOKEN_TTL_SLACK)
|
|
188
|
+
.to_jwt()
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
logger.debug(
|
|
192
|
+
"starting atmee avatar session",
|
|
193
|
+
extra={"avatar_id": self._avatar_id, "room": room.name},
|
|
194
|
+
)
|
|
195
|
+
info = await self._api.create_avatar_session(
|
|
196
|
+
self._avatar_id,
|
|
197
|
+
livekit_url=livekit_url,
|
|
198
|
+
livekit_token=livekit_token,
|
|
199
|
+
agent_identity=local_participant_identity,
|
|
200
|
+
max_duration_seconds=self._max_duration_seconds,
|
|
201
|
+
metadata=self._metadata,
|
|
202
|
+
wait_for=self._wait_for,
|
|
203
|
+
)
|
|
204
|
+
self.session_info = info
|
|
205
|
+
self.session_id = info.session_id
|
|
206
|
+
logger.info(
|
|
207
|
+
"atmee avatar session started",
|
|
208
|
+
extra={
|
|
209
|
+
"session_id": info.session_id,
|
|
210
|
+
"status": info.status,
|
|
211
|
+
"billing_mode": info.billing_mode,
|
|
212
|
+
"max_duration_seconds": info.max_duration_seconds,
|
|
213
|
+
},
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
self._room_for_events = room
|
|
217
|
+
room.on("participant_disconnected", self._on_participant_disconnected)
|
|
218
|
+
|
|
219
|
+
agent_session.output.replace_audio_tail(
|
|
220
|
+
DataStreamAudioOutput(
|
|
221
|
+
room=room,
|
|
222
|
+
destination_identity=self._avatar_participant_identity,
|
|
223
|
+
sample_rate=SAMPLE_RATE,
|
|
224
|
+
wait_remote_track=rtc.TrackKind.KIND_VIDEO,
|
|
225
|
+
),
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
def _on_participant_disconnected(self, participant: rtc.RemoteParticipant) -> None:
|
|
229
|
+
if participant.identity != self._avatar_participant_identity or self._ended:
|
|
230
|
+
return
|
|
231
|
+
# The avatar left while we are still running: its worker died or was
|
|
232
|
+
# removed. The worker reports its own end to Atmee; ending here too
|
|
233
|
+
# closes the gap for a worker that could not (idempotent).
|
|
234
|
+
logger.warning(
|
|
235
|
+
"atmee avatar participant left the room",
|
|
236
|
+
extra={"session_id": self.session_id, "identity": participant.identity},
|
|
237
|
+
)
|
|
238
|
+
self.emit("avatar_disconnected", participant)
|
|
239
|
+
self._schedule_end()
|
|
240
|
+
|
|
241
|
+
def _schedule_end(self) -> None:
|
|
242
|
+
if self._end_task is None or self._end_task.done():
|
|
243
|
+
self._end_task = asyncio.create_task(self._end_session())
|
|
244
|
+
|
|
245
|
+
async def _end_session(self) -> None:
|
|
246
|
+
"""Best-effort ``POST /v1/avatar_sessions/{id}/end`` — once."""
|
|
247
|
+
if self._ended or not self.session_id:
|
|
248
|
+
return
|
|
249
|
+
self._ended = True
|
|
250
|
+
try:
|
|
251
|
+
await self._api.end_avatar_session(self.session_id)
|
|
252
|
+
logger.debug("atmee avatar session ended", extra={"session_id": self.session_id})
|
|
253
|
+
except Exception as e: # never let a billing hint break teardown
|
|
254
|
+
logger.warning(
|
|
255
|
+
"failed to end atmee avatar session; the worker's own report or the "
|
|
256
|
+
"session ceiling will settle it",
|
|
257
|
+
extra={"session_id": self.session_id, "error": str(e)},
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
async def aclose(self) -> None:
|
|
261
|
+
"""End the Atmee session and remove the avatar from the room.
|
|
262
|
+
|
|
263
|
+
Registered as a job shutdown callback by :meth:`start`; call it
|
|
264
|
+
yourself when running outside a job.
|
|
265
|
+
"""
|
|
266
|
+
if self._room_for_events is not None:
|
|
267
|
+
self._room_for_events.off("participant_disconnected", self._on_participant_disconnected)
|
|
268
|
+
self._room_for_events = None
|
|
269
|
+
if self._end_task is not None and not self._end_task.done():
|
|
270
|
+
try:
|
|
271
|
+
await self._end_task
|
|
272
|
+
except Exception:
|
|
273
|
+
pass
|
|
274
|
+
await self._end_session()
|
|
275
|
+
await super().aclose()
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Copyright 2026 Atmanity
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: livekit-plugins-atmee
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: LiveKit Agents plugin for Atmee avatars: render a talking-head avatar from a single portrait into your agent's room
|
|
5
|
+
Project-URL: Documentation, https://github.com/Atmanity/atmee_livekit_plugin#readme
|
|
6
|
+
Project-URL: Website, https://atmee.ai
|
|
7
|
+
Project-URL: Source, https://github.com/Atmanity/atmee_livekit_plugin
|
|
8
|
+
Author-email: Atmanity <hello@atmee.ai>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: atmee,audio,avatar,livekit,realtime,video,webrtc
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
21
|
+
Classifier: Topic :: Multimedia :: Video
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: aiohttp>=3.9
|
|
25
|
+
Requires-Dist: livekit-agents<2,>=1.6.8
|
|
26
|
+
Requires-Dist: livekit-api>=1.0
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# Atmee avatar plugin for LiveKit Agents
|
|
30
|
+
|
|
31
|
+
Bring your own LiveKit voice agent; Atmee renders a talking-head avatar from a
|
|
32
|
+
single portrait into your room and bills per minute. Works like the other
|
|
33
|
+
avatar plugins for [LiveKit Agents](https://docs.livekit.io/agents/): the
|
|
34
|
+
avatar joins your room as its own participant, your agent's speech drives its
|
|
35
|
+
video.
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from livekit.plugins import atmee
|
|
39
|
+
|
|
40
|
+
avatar_id = await atmee.AtmeeAPI().create_avatar(name="Val", image="portrait.jpg")
|
|
41
|
+
|
|
42
|
+
avatar = atmee.AvatarSession(avatar_id=avatar_id) # ATMEE_API_KEY in the environment
|
|
43
|
+
await avatar.start(session, room=ctx.room)
|
|
44
|
+
await session.start(agent=..., room=ctx.room) # the agent's TTS drives the avatar's video
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install livekit-plugins-atmee
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Python 3.10+, `livekit-agents` 1.6.8 or newer.
|
|
54
|
+
|
|
55
|
+
## Prerequisites
|
|
56
|
+
|
|
57
|
+
- An **Atmee API key** (`sk_atmee_...`) from your Atmee developer settings, in
|
|
58
|
+
`ATMEE_API_KEY`. Keep it on your agent's side; it never goes to a browser.
|
|
59
|
+
- Your **own LiveKit project** (LiveKit Cloud or self-hosted): `LIVEKIT_URL`,
|
|
60
|
+
`LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET` — the same variables your agent
|
|
61
|
+
already uses. Atmee never sees your LiveKit secret: the plugin mints a token
|
|
62
|
+
for the avatar participant locally and hands only that token to Atmee.
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
### 1. Create an avatar from a portrait
|
|
67
|
+
|
|
68
|
+
Once, from a script or your backend (see `examples/create_avatar.py`):
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
async with atmee.AtmeeAPI() as api:
|
|
72
|
+
avatar_id = await api.create_avatar(name="Val", image="portrait.jpg") # path, bytes, or https URL
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
A portrait-only avatar is ready immediately. You can also create and manage
|
|
76
|
+
avatars in the Atmee studio; any avatar of your account with a portrait works.
|
|
77
|
+
|
|
78
|
+
### 2. Render it in your agent
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
async def entrypoint(ctx: agents.JobContext):
|
|
82
|
+
await ctx.connect()
|
|
83
|
+
session = AgentSession(stt=..., llm=..., tts=..., vad=...)
|
|
84
|
+
|
|
85
|
+
avatar = atmee.AvatarSession(avatar_id=os.environ["ATMEE_AVATAR_ID"])
|
|
86
|
+
await avatar.start(session, room=ctx.room) # before session.start
|
|
87
|
+
|
|
88
|
+
await session.start(agent=MyAgent(), room=ctx.room)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`start()` returns as soon as Atmee's rendering worker acknowledged the start
|
|
92
|
+
(about a second); the avatar's video and audio tracks appear in the room a few
|
|
93
|
+
seconds later, published by the participant `atmee-avatar-agent`. Your agent
|
|
94
|
+
publishes no audio of its own — the avatar speaks for it, lips in sync.
|
|
95
|
+
|
|
96
|
+
Options on `AvatarSession`:
|
|
97
|
+
|
|
98
|
+
| Argument | Default | Meaning |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| `avatar_id` | required | The Atmee avatar to render. |
|
|
101
|
+
| `api_key`, `api_url` | `ATMEE_API_KEY`, `ATMEE_API_URL` | Credentials and API base. |
|
|
102
|
+
| `avatar_participant_identity` | `atmee-avatar-agent` | Identity the avatar joins with; set it when one room hosts several avatars. |
|
|
103
|
+
| `max_duration_seconds` | `3600` | Hard ceiling of the session; also the most it can bill if your agent dies without a trace. |
|
|
104
|
+
| `wait_for` | `"initializing"` | `"avatar_joined"` makes `start()` block until the avatar is in the room. |
|
|
105
|
+
| `metadata` | `None` | Free-form JSON stored with the session on the Atmee side. |
|
|
106
|
+
|
|
107
|
+
`avatar.session_id` and `avatar.session_info` hold the Atmee session after
|
|
108
|
+
`start()`; `avatar.on("avatar_disconnected", ...)` fires if the avatar
|
|
109
|
+
participant leaves while your agent is still running.
|
|
110
|
+
|
|
111
|
+
### Lifecycle and billing
|
|
112
|
+
|
|
113
|
+
Billing starts when the avatar sees your agent in the room and runs by the
|
|
114
|
+
minute. It stops when
|
|
115
|
+
|
|
116
|
+
- your agent leaves the room or the room closes (the rendering worker notices
|
|
117
|
+
and reports the end itself — a crashed agent stops being billed within
|
|
118
|
+
seconds),
|
|
119
|
+
- `aclose()` runs — registered automatically as a job shutdown callback; it
|
|
120
|
+
ends the session and removes the avatar participant from your room,
|
|
121
|
+
- the rendering worker itself dies or loses contact: it proves it is alive
|
|
122
|
+
once a minute, and a session silent for a few minutes is closed and billed
|
|
123
|
+
only up to the last proof,
|
|
124
|
+
- or the session reaches `max_duration_seconds`.
|
|
125
|
+
|
|
126
|
+
### Errors
|
|
127
|
+
|
|
128
|
+
All API failures raise `atmee.AtmeeException` with `status_code`, `code`
|
|
129
|
+
(the API's error code, e.g. `insufficient_credits`, `avatar_not_renderable`,
|
|
130
|
+
`missing_publish_on_behalf`) and `message`. Two subclasses are worth
|
|
131
|
+
handling: `AtmeeNoCapacityError` (every rendering worker is busy; check
|
|
132
|
+
`retry_after` and try again later) and `AtmeeAvatarNotReadyError` (the avatar
|
|
133
|
+
has no portrait yet).
|
|
134
|
+
|
|
135
|
+
## Examples
|
|
136
|
+
|
|
137
|
+
- [`examples/agent.py`](examples/agent.py) — a Deepgram + OpenAI + Silero agent
|
|
138
|
+
with an Atmee avatar; run with `python examples/agent.py dev` and open the
|
|
139
|
+
LiveKit Agents Playground.
|
|
140
|
+
- [`examples/create_avatar.py`](examples/create_avatar.py) — create an avatar
|
|
141
|
+
from a portrait and print its id.
|
|
142
|
+
- [`tests/test_live_agent.py`](tests/test_live_agent.py) — a manual live
|
|
143
|
+
smoke test: a real GPT voice agent (OpenAI LLM + TTS, silero VAD) with an
|
|
144
|
+
Atmee avatar in a real LiveKit room, asserting the avatar joins, publishes
|
|
145
|
+
video, and that its agent-driven audio flows. Skipped unless
|
|
146
|
+
`RUN_LIVE_ATMEE_AGENT=1` and the credentials are set:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
RUN_LIVE_ATMEE_AGENT=1 ATMEE_API_KEY=… ATMEE_AVATAR_ID=… \
|
|
150
|
+
LIVEKIT_URL=… LIVEKIT_API_KEY=… LIVEKIT_API_SECRET=… OPENAI_API_KEY=… \
|
|
151
|
+
uv run --group dev --with "livekit-agents[openai,silero]" \
|
|
152
|
+
pytest tests/test_live_agent.py -m live -s
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## How it works
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
your agent (livekit-agents) ── plugin ──► Atmee API (X-Api-Key, https)
|
|
159
|
+
│ │
|
|
160
|
+
│ audio over lk.audio_stream ▼
|
|
161
|
+
└──────────────► your LiveKit room ◄── Atmee rendering worker
|
|
162
|
+
joins as atmee-avatar-agent,
|
|
163
|
+
publishes video + audio
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
1. `AvatarSession.start()` mints a LiveKit access token for the avatar
|
|
167
|
+
participant with **your** LiveKit credentials: identity
|
|
168
|
+
`atmee-avatar-agent`, `kind: agent`, a `roomJoin` grant for your room,
|
|
169
|
+
and the attribute `lk.publish_on_behalf` set to your agent's identity.
|
|
170
|
+
Atmee receives only that token, never your secret.
|
|
171
|
+
2. It calls `POST /v1/avatars/{avatarId}/avatar_sessions` with your LiveKit
|
|
172
|
+
URL and the token. Atmee reserves a session, starts a rendering worker,
|
|
173
|
+
and answers as soon as the worker acknowledged the start.
|
|
174
|
+
3. The worker joins your room with the token, waits for your agent, receives
|
|
175
|
+
its audio over the LiveKit data stream (`lk.audio_stream`, 16 kHz PCM, the
|
|
176
|
+
standard `DataStreamAudioOutput`), and publishes lip-synced video and
|
|
177
|
+
audio on behalf of your agent.
|
|
178
|
+
4. When your agent leaves or the room closes, the worker notices from inside
|
|
179
|
+
the room and reports the end to Atmee, which stops billing. `aclose()`
|
|
180
|
+
removes the avatar participant and ends the session explicitly as well.
|
|
181
|
+
|
|
182
|
+
## Development
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
uv venv && uv pip install -e . --group dev
|
|
186
|
+
uv run pytest -q
|
|
187
|
+
uv run ruff check . && uv run ruff format --check . && uv run mypy
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Releases are published to PyPI from `v*` tags by `.github/workflows/publish.yml`
|
|
191
|
+
(PyPI trusted publishing).
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
Apache-2.0.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
livekit/plugins/atmee/__init__.py,sha256=rsTsuct4riIW7H1Ol05W9RtlTFo2ob5nonw6476L4Ng,1846
|
|
2
|
+
livekit/plugins/atmee/api.py,sha256=JFNUvspvrqK59aMCILIj0_NKOg9-5J9xt3h1fV9wBJM,17358
|
|
3
|
+
livekit/plugins/atmee/avatar.py,sha256=Y6WNpvqGKqNzMiP-ef6gOwZUaS807N5p36U9bDFfjJ0,11456
|
|
4
|
+
livekit/plugins/atmee/log.py,sha256=xg7UdKD7FaYxwL6KOsLGHTE8uxutz8k5Atid-zvwa9A,68
|
|
5
|
+
livekit/plugins/atmee/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
livekit/plugins/atmee/version.py,sha256=Oq2wWv9CnzGmaw5MjGmr-PC4s6VqxCLUhE9wn8oCJ2o,595
|
|
7
|
+
livekit_plugins_atmee-0.1.0.dist-info/METADATA,sha256=N-uatr1VcA5uM-WtqDH59d-vFfidkI9Scj1s7taBmGQ,8400
|
|
8
|
+
livekit_plugins_atmee-0.1.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
9
|
+
livekit_plugins_atmee-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
10
|
+
livekit_plugins_atmee-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|