chainlit 1.3.0rc0__py3-none-any.whl → 1.3.0rc1__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.
Potentially problematic release.
This version of chainlit might be problematic. Click here for more details.
- chainlit/__init__.py +5 -2
- chainlit/callbacks.py +13 -4
- chainlit/config.py +6 -21
- chainlit/copilot/dist/index.js +532 -234
- chainlit/emitter.py +25 -0
- chainlit/frontend/dist/assets/{DailyMotion-deaa038d.js → DailyMotion-b4b7af47.js} +1 -1
- chainlit/frontend/dist/assets/{Facebook-07c55425.js → Facebook-572972a0.js} +1 -1
- chainlit/frontend/dist/assets/{FilePlayer-2acc46b1.js → FilePlayer-85c69ca8.js} +1 -1
- chainlit/frontend/dist/assets/{Kaltura-c2689eb3.js → Kaltura-dfc24672.js} +1 -1
- chainlit/frontend/dist/assets/{Mixcloud-79d681a7.js → Mixcloud-705011f4.js} +1 -1
- chainlit/frontend/dist/assets/{Mux-549353dc.js → Mux-4201a9e6.js} +1 -1
- chainlit/frontend/dist/assets/{Preview-000efdea.js → Preview-23ba40a6.js} +1 -1
- chainlit/frontend/dist/assets/{SoundCloud-81b2bf43.js → SoundCloud-1a582d51.js} +1 -1
- chainlit/frontend/dist/assets/{Streamable-032d3cc5.js → Streamable-5017c4ba.js} +1 -1
- chainlit/frontend/dist/assets/{Twitch-43744e0a.js → Twitch-bb2de2fa.js} +1 -1
- chainlit/frontend/dist/assets/{Vidyard-4ac486dc.js → Vidyard-54e269b1.js} +1 -1
- chainlit/frontend/dist/assets/{Vimeo-7f1f7543.js → Vimeo-d92c37dd.js} +1 -1
- chainlit/frontend/dist/assets/{Wistia-d0d070c9.js → Wistia-25a1363b.js} +1 -1
- chainlit/frontend/dist/assets/{YouTube-8a2bf9cd.js → YouTube-616e8cb7.js} +1 -1
- chainlit/frontend/dist/assets/index-f5df2072.js +1027 -0
- chainlit/frontend/dist/assets/{react-plotly-39a45803.js → react-plotly-f0315f86.js} +1 -1
- chainlit/frontend/dist/index.html +1 -1
- chainlit/socket.py +19 -17
- chainlit/translations/en-US.json +2 -1
- chainlit/types.py +6 -6
- {chainlit-1.3.0rc0.dist-info → chainlit-1.3.0rc1.dist-info}/METADATA +1 -1
- {chainlit-1.3.0rc0.dist-info → chainlit-1.3.0rc1.dist-info}/RECORD +29 -29
- chainlit/frontend/dist/assets/index-a0fa87f1.js +0 -729
- {chainlit-1.3.0rc0.dist-info → chainlit-1.3.0rc1.dist-info}/WHEEL +0 -0
- {chainlit-1.3.0rc0.dist-info → chainlit-1.3.0rc1.dist-info}/entry_points.txt +0 -0
chainlit/__init__.py
CHANGED
|
@@ -43,7 +43,7 @@ from chainlit.message import (
|
|
|
43
43
|
)
|
|
44
44
|
from chainlit.step import Step, step
|
|
45
45
|
from chainlit.sync import make_async, run_sync
|
|
46
|
-
from chainlit.types import
|
|
46
|
+
from chainlit.types import InputAudioChunk, OutputAudioChunk, ChatProfile, Starter
|
|
47
47
|
from chainlit.user import PersistedUser, User
|
|
48
48
|
from chainlit.user_session import user_session
|
|
49
49
|
from chainlit.utils import make_module_getattr
|
|
@@ -56,6 +56,7 @@ from .callbacks import (
|
|
|
56
56
|
author_rename,
|
|
57
57
|
header_auth_callback,
|
|
58
58
|
oauth_callback,
|
|
59
|
+
on_audio_start,
|
|
59
60
|
on_audio_chunk,
|
|
60
61
|
on_audio_end,
|
|
61
62
|
on_chat_end,
|
|
@@ -117,7 +118,8 @@ __all__ = [
|
|
|
117
118
|
"user_session",
|
|
118
119
|
"chat_context",
|
|
119
120
|
"CopilotFunction",
|
|
120
|
-
"
|
|
121
|
+
"InputAudioChunk",
|
|
122
|
+
"OutputAudioChunk",
|
|
121
123
|
"Action",
|
|
122
124
|
"User",
|
|
123
125
|
"PersistedUser",
|
|
@@ -176,6 +178,7 @@ __all__ = [
|
|
|
176
178
|
"set_chat_profiles",
|
|
177
179
|
"set_starters",
|
|
178
180
|
"on_chat_end",
|
|
181
|
+
"on_audio_start",
|
|
179
182
|
"on_audio_chunk",
|
|
180
183
|
"on_audio_end",
|
|
181
184
|
"author_rename",
|
chainlit/callbacks.py
CHANGED
|
@@ -209,13 +209,25 @@ def on_chat_end(func: Callable) -> Callable:
|
|
|
209
209
|
return func
|
|
210
210
|
|
|
211
211
|
|
|
212
|
+
@trace
|
|
213
|
+
def on_audio_start(func: Callable) -> Callable:
|
|
214
|
+
"""
|
|
215
|
+
Hook to react to the user initiating audio.
|
|
216
|
+
|
|
217
|
+
Returns:
|
|
218
|
+
Callable[], Any]: The decorated hook.
|
|
219
|
+
"""
|
|
220
|
+
|
|
221
|
+
config.code.on_audio_start = wrap_user_function(func, with_task=False)
|
|
222
|
+
return func
|
|
223
|
+
|
|
212
224
|
@trace
|
|
213
225
|
def on_audio_chunk(func: Callable) -> Callable:
|
|
214
226
|
"""
|
|
215
227
|
Hook to react to the audio chunks being sent.
|
|
216
228
|
|
|
217
229
|
Args:
|
|
218
|
-
chunk (
|
|
230
|
+
chunk (InputAudioChunk): The audio chunk being sent.
|
|
219
231
|
|
|
220
232
|
Returns:
|
|
221
233
|
Callable[], Any]: The decorated hook.
|
|
@@ -230,9 +242,6 @@ def on_audio_end(func: Callable) -> Callable:
|
|
|
230
242
|
"""
|
|
231
243
|
Hook to react to the audio stream ending. This is called after the last audio chunk is sent.
|
|
232
244
|
|
|
233
|
-
Args:
|
|
234
|
-
elements ([List[Element]): The files that were uploaded before starting the audio stream (if any).
|
|
235
|
-
|
|
236
245
|
Returns:
|
|
237
246
|
Callable[], Any]: The decorated hook.
|
|
238
247
|
"""
|
chainlit/config.py
CHANGED
|
@@ -28,9 +28,8 @@ from ._utils import is_path_inside
|
|
|
28
28
|
|
|
29
29
|
if TYPE_CHECKING:
|
|
30
30
|
from chainlit.action import Action
|
|
31
|
-
from chainlit.element import ElementBased
|
|
32
31
|
from chainlit.message import Message
|
|
33
|
-
from chainlit.types import
|
|
32
|
+
from chainlit.types import InputAudioChunk, ChatProfile, Starter, ThreadDict
|
|
34
33
|
from chainlit.user import User
|
|
35
34
|
from fastapi import Request, Response
|
|
36
35
|
|
|
@@ -93,18 +92,8 @@ edit_message = true
|
|
|
93
92
|
max_size_mb = 500
|
|
94
93
|
|
|
95
94
|
[features.audio]
|
|
96
|
-
# Threshold for audio recording
|
|
97
|
-
min_decibels = -45
|
|
98
|
-
# Delay for the user to start speaking in MS
|
|
99
|
-
initial_silence_timeout = 3000
|
|
100
|
-
# Delay for the user to continue speaking in MS. If the user stops speaking for this duration, the recording will stop.
|
|
101
|
-
silence_timeout = 1500
|
|
102
|
-
# Above this duration (MS), the recording will forcefully stop.
|
|
103
|
-
max_duration = 15000
|
|
104
|
-
# Duration of the audio chunks in MS
|
|
105
|
-
chunk_duration = 1000
|
|
106
95
|
# Sample rate of the audio
|
|
107
|
-
sample_rate =
|
|
96
|
+
sample_rate = 24000
|
|
108
97
|
|
|
109
98
|
[UI]
|
|
110
99
|
# Name of the assistant.
|
|
@@ -237,12 +226,7 @@ class SpontaneousFileUploadFeature(DataClassJsonMixin):
|
|
|
237
226
|
|
|
238
227
|
@dataclass
|
|
239
228
|
class AudioFeature(DataClassJsonMixin):
|
|
240
|
-
|
|
241
|
-
initial_silence_timeout: int = 2000
|
|
242
|
-
silence_timeout: int = 1500
|
|
243
|
-
chunk_duration: int = 1000
|
|
244
|
-
max_duration: int = 15000
|
|
245
|
-
sample_rate: int = 44100
|
|
229
|
+
sample_rate: int = 24000
|
|
246
230
|
enabled: bool = False
|
|
247
231
|
|
|
248
232
|
|
|
@@ -297,8 +281,9 @@ class CodeSettings:
|
|
|
297
281
|
on_chat_end: Optional[Callable[[], Any]] = None
|
|
298
282
|
on_chat_resume: Optional[Callable[["ThreadDict"], Any]] = None
|
|
299
283
|
on_message: Optional[Callable[["Message"], Any]] = None
|
|
300
|
-
|
|
301
|
-
|
|
284
|
+
on_audio_start: Optional[Callable[[], Any]] = None
|
|
285
|
+
on_audio_chunk: Optional[Callable[["InputAudioChunk"], Any]] = None
|
|
286
|
+
on_audio_end: Optional[Callable[[], Any]] = None
|
|
302
287
|
|
|
303
288
|
author_rename: Optional[Callable[[str], Awaitable[str]]] = None
|
|
304
289
|
on_settings_update: Optional[Callable[[Dict[str, Any]], Any]] = None
|