chainlit 1.3.0rc1__py3-none-any.whl → 1.3.1__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 +2 -5
- chainlit/auth.py +2 -0
- chainlit/callbacks.py +4 -13
- chainlit/config.py +21 -6
- chainlit/context.py +4 -6
- chainlit/copilot/dist/index.js +296 -603
- chainlit/data/sql_alchemy.py +1 -1
- chainlit/emitter.py +0 -25
- chainlit/frontend/dist/assets/DailyMotion-CwoOhIL8.js +1 -0
- chainlit/frontend/dist/assets/Facebook-BhnGXlzq.js +1 -0
- chainlit/frontend/dist/assets/FilePlayer-CPSVT6fz.js +1 -0
- chainlit/frontend/dist/assets/Kaltura-COYaLzsL.js +1 -0
- chainlit/frontend/dist/assets/Mixcloud-JdadNiQ5.js +1 -0
- chainlit/frontend/dist/assets/Mux-CBN7RO2u.js +1 -0
- chainlit/frontend/dist/assets/Preview-CxAFvvjV.js +1 -0
- chainlit/frontend/dist/assets/SoundCloud-JlgmASWm.js +1 -0
- chainlit/frontend/dist/assets/Streamable-CUWgr6Zw.js +1 -0
- chainlit/frontend/dist/assets/Twitch-BiN1HEDM.js +1 -0
- chainlit/frontend/dist/assets/Vidyard-qhPmrhDm.js +1 -0
- chainlit/frontend/dist/assets/Vimeo-CrZVSCaT.js +1 -0
- chainlit/frontend/dist/assets/Wistia-C891KrBP.js +1 -0
- chainlit/frontend/dist/assets/YouTube-DKjw5Hbn.js +1 -0
- chainlit/frontend/dist/assets/index-DLRdQOIx.js +723 -0
- chainlit/frontend/dist/assets/{react-plotly-f0315f86.js → react-plotly-Dpmqg5Sy.js} +94 -94
- chainlit/frontend/dist/index.html +2 -3
- chainlit/oauth_providers.py +43 -9
- chainlit/openai/__init__.py +3 -5
- chainlit/server.py +20 -9
- chainlit/socket.py +17 -19
- chainlit/step.py +9 -17
- chainlit/translations/en-US.json +1 -2
- chainlit/types.py +6 -6
- {chainlit-1.3.0rc1.dist-info → chainlit-1.3.1.dist-info}/METADATA +12 -4
- {chainlit-1.3.0rc1.dist-info → chainlit-1.3.1.dist-info}/RECORD +41 -41
- chainlit/frontend/dist/assets/DailyMotion-b4b7af47.js +0 -1
- chainlit/frontend/dist/assets/Facebook-572972a0.js +0 -1
- chainlit/frontend/dist/assets/FilePlayer-85c69ca8.js +0 -1
- chainlit/frontend/dist/assets/Kaltura-dfc24672.js +0 -1
- chainlit/frontend/dist/assets/Mixcloud-705011f4.js +0 -1
- chainlit/frontend/dist/assets/Mux-4201a9e6.js +0 -1
- chainlit/frontend/dist/assets/Preview-23ba40a6.js +0 -1
- chainlit/frontend/dist/assets/SoundCloud-1a582d51.js +0 -1
- chainlit/frontend/dist/assets/Streamable-5017c4ba.js +0 -1
- chainlit/frontend/dist/assets/Twitch-bb2de2fa.js +0 -1
- chainlit/frontend/dist/assets/Vidyard-54e269b1.js +0 -1
- chainlit/frontend/dist/assets/Vimeo-d92c37dd.js +0 -1
- chainlit/frontend/dist/assets/Wistia-25a1363b.js +0 -1
- chainlit/frontend/dist/assets/YouTube-616e8cb7.js +0 -1
- chainlit/frontend/dist/assets/index-f5df2072.js +0 -1027
- /chainlit/copilot/dist/assets/{logo_dark-2a3cf740.svg → logo_dark-IkGJ_IwC.svg} +0 -0
- /chainlit/copilot/dist/assets/{logo_light-b078e7bc.svg → logo_light-Bb_IPh6r.svg} +0 -0
- /chainlit/frontend/dist/assets/{index-aaf974a9.css → index-CwmincdQ.css} +0 -0
- /chainlit/frontend/dist/assets/{logo_dark-2a3cf740.svg → logo_dark-IkGJ_IwC.svg} +0 -0
- /chainlit/frontend/dist/assets/{logo_light-b078e7bc.svg → logo_light-Bb_IPh6r.svg} +0 -0
- {chainlit-1.3.0rc1.dist-info → chainlit-1.3.1.dist-info}/WHEEL +0 -0
- {chainlit-1.3.0rc1.dist-info → chainlit-1.3.1.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 AudioChunk, 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,7 +56,6 @@ from .callbacks import (
|
|
|
56
56
|
author_rename,
|
|
57
57
|
header_auth_callback,
|
|
58
58
|
oauth_callback,
|
|
59
|
-
on_audio_start,
|
|
60
59
|
on_audio_chunk,
|
|
61
60
|
on_audio_end,
|
|
62
61
|
on_chat_end,
|
|
@@ -118,8 +117,7 @@ __all__ = [
|
|
|
118
117
|
"user_session",
|
|
119
118
|
"chat_context",
|
|
120
119
|
"CopilotFunction",
|
|
121
|
-
"
|
|
122
|
-
"OutputAudioChunk",
|
|
120
|
+
"AudioChunk",
|
|
123
121
|
"Action",
|
|
124
122
|
"User",
|
|
125
123
|
"PersistedUser",
|
|
@@ -178,7 +176,6 @@ __all__ = [
|
|
|
178
176
|
"set_chat_profiles",
|
|
179
177
|
"set_starters",
|
|
180
178
|
"on_chat_end",
|
|
181
|
-
"on_audio_start",
|
|
182
179
|
"on_audio_chunk",
|
|
183
180
|
"on_audio_end",
|
|
184
181
|
"author_rename",
|
chainlit/auth.py
CHANGED
chainlit/callbacks.py
CHANGED
|
@@ -209,25 +209,13 @@ 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
|
-
|
|
224
212
|
@trace
|
|
225
213
|
def on_audio_chunk(func: Callable) -> Callable:
|
|
226
214
|
"""
|
|
227
215
|
Hook to react to the audio chunks being sent.
|
|
228
216
|
|
|
229
217
|
Args:
|
|
230
|
-
chunk (
|
|
218
|
+
chunk (AudioChunk): The audio chunk being sent.
|
|
231
219
|
|
|
232
220
|
Returns:
|
|
233
221
|
Callable[], Any]: The decorated hook.
|
|
@@ -242,6 +230,9 @@ def on_audio_end(func: Callable) -> Callable:
|
|
|
242
230
|
"""
|
|
243
231
|
Hook to react to the audio stream ending. This is called after the last audio chunk is sent.
|
|
244
232
|
|
|
233
|
+
Args:
|
|
234
|
+
elements ([List[Element]): The files that were uploaded before starting the audio stream (if any).
|
|
235
|
+
|
|
245
236
|
Returns:
|
|
246
237
|
Callable[], Any]: The decorated hook.
|
|
247
238
|
"""
|
chainlit/config.py
CHANGED
|
@@ -28,8 +28,9 @@ 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
|
|
31
32
|
from chainlit.message import Message
|
|
32
|
-
from chainlit.types import
|
|
33
|
+
from chainlit.types import AudioChunk, ChatProfile, Starter, ThreadDict
|
|
33
34
|
from chainlit.user import User
|
|
34
35
|
from fastapi import Request, Response
|
|
35
36
|
|
|
@@ -92,8 +93,18 @@ edit_message = true
|
|
|
92
93
|
max_size_mb = 500
|
|
93
94
|
|
|
94
95
|
[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
|
|
95
106
|
# Sample rate of the audio
|
|
96
|
-
sample_rate =
|
|
107
|
+
sample_rate = 44100
|
|
97
108
|
|
|
98
109
|
[UI]
|
|
99
110
|
# Name of the assistant.
|
|
@@ -226,7 +237,12 @@ class SpontaneousFileUploadFeature(DataClassJsonMixin):
|
|
|
226
237
|
|
|
227
238
|
@dataclass
|
|
228
239
|
class AudioFeature(DataClassJsonMixin):
|
|
229
|
-
|
|
240
|
+
min_decibels: int = -45
|
|
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
|
|
230
246
|
enabled: bool = False
|
|
231
247
|
|
|
232
248
|
|
|
@@ -281,9 +297,8 @@ class CodeSettings:
|
|
|
281
297
|
on_chat_end: Optional[Callable[[], Any]] = None
|
|
282
298
|
on_chat_resume: Optional[Callable[["ThreadDict"], Any]] = None
|
|
283
299
|
on_message: Optional[Callable[["Message"], Any]] = None
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
on_audio_end: Optional[Callable[[], Any]] = None
|
|
300
|
+
on_audio_chunk: Optional[Callable[["AudioChunk"], Any]] = None
|
|
301
|
+
on_audio_end: Optional[Callable[[List["ElementBased"]], Any]] = None
|
|
287
302
|
|
|
288
303
|
author_rename: Optional[Callable[[str], Awaitable[str]]] = None
|
|
289
304
|
on_settings_update: Optional[Callable[[Dict[str, Any]], Any]] = None
|
chainlit/context.py
CHANGED
|
@@ -23,18 +23,17 @@ class ChainlitContext:
|
|
|
23
23
|
loop: asyncio.AbstractEventLoop
|
|
24
24
|
emitter: "BaseChainlitEmitter"
|
|
25
25
|
session: Union["HTTPSession", "WebsocketSession"]
|
|
26
|
-
active_steps: List["Step"]
|
|
27
26
|
|
|
28
27
|
@property
|
|
29
28
|
def current_step(self):
|
|
30
|
-
if
|
|
31
|
-
return
|
|
29
|
+
if previous_steps := local_steps.get():
|
|
30
|
+
return previous_steps[-1]
|
|
32
31
|
|
|
33
32
|
@property
|
|
34
33
|
def current_run(self):
|
|
35
|
-
if
|
|
34
|
+
if previous_steps := local_steps.get():
|
|
36
35
|
return next(
|
|
37
|
-
(step for step in
|
|
36
|
+
(step for step in previous_steps if step.name in CL_RUN_NAMES), None
|
|
38
37
|
)
|
|
39
38
|
|
|
40
39
|
def __init__(
|
|
@@ -46,7 +45,6 @@ class ChainlitContext:
|
|
|
46
45
|
|
|
47
46
|
self.loop = asyncio.get_running_loop()
|
|
48
47
|
self.session = session
|
|
49
|
-
self.active_steps = []
|
|
50
48
|
|
|
51
49
|
if emitter:
|
|
52
50
|
self.emitter = emitter
|