chainlit 2.0.0__py3-none-any.whl → 2.0.dev1__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 +57 -55
- chainlit/action.py +10 -12
- chainlit/{auth/__init__.py → auth.py} +34 -20
- chainlit/cache.py +1 -2
- chainlit/callbacks.py +7 -52
- chainlit/chat_context.py +2 -2
- chainlit/chat_settings.py +1 -3
- chainlit/cli/__init__.py +1 -14
- chainlit/config.py +69 -35
- chainlit/context.py +2 -3
- chainlit/copilot/dist/index.js +935 -8533
- chainlit/data/__init__.py +8 -96
- chainlit/data/acl.py +2 -3
- chainlit/data/base.py +1 -1
- chainlit/data/dynamodb.py +3 -5
- chainlit/data/literalai.py +6 -4
- chainlit/data/sql_alchemy.py +7 -8
- chainlit/data/storage_clients/azure.py +0 -1
- chainlit/data/storage_clients/base.py +0 -6
- chainlit/data/storage_clients/s3.py +3 -16
- chainlit/discord/app.py +1 -2
- chainlit/element.py +9 -13
- chainlit/emitter.py +21 -17
- chainlit/frontend/dist/assets/{DailyMotion-DgRzV5GZ.js → DailyMotion-D1ipkdPJ.js} +1 -1
- chainlit/frontend/dist/assets/{Facebook-C0vx6HWv.js → Facebook-d4TLeTik.js} +1 -1
- chainlit/frontend/dist/assets/{FilePlayer-CdhzeHPP.js → FilePlayer-BcU7tttX.js} +1 -1
- chainlit/frontend/dist/assets/{Kaltura-5iVmeUct.js → Kaltura-DdaRjZrh.js} +1 -1
- chainlit/frontend/dist/assets/{Mixcloud-C2zi77Ex.js → Mixcloud-BaJoMsaU.js} +1 -1
- chainlit/frontend/dist/assets/{Mux-Vkebogdf.js → Mux-DxPCM5d3.js} +1 -1
- chainlit/frontend/dist/assets/{Preview-DwY_sEIl.js → Preview-tUK_Z9pZ.js} +1 -1
- chainlit/frontend/dist/assets/{SoundCloud-CREBXAWo.js → SoundCloud-K8-lFZC6.js} +1 -1
- chainlit/frontend/dist/assets/{Streamable-B5Lu25uy.js → Streamable-hB-AQ54w.js} +1 -1
- chainlit/frontend/dist/assets/{Twitch-y9iKCcM1.js → Twitch-pmuNY0J5.js} +1 -1
- chainlit/frontend/dist/assets/{Vidyard-ClYvcuEu.js → Vidyard-BSUm6trV.js} +1 -1
- chainlit/frontend/dist/assets/{Vimeo-D6HvM2jt.js → Vimeo-JIPn71zS.js} +1 -1
- chainlit/frontend/dist/assets/Wistia-D75KkqOG.js +1 -0
- chainlit/frontend/dist/assets/{YouTube-D10tR6CJ.js → YouTube-CPlwqNm_.js} +1 -1
- chainlit/frontend/dist/assets/index-CuSbXjG5.js +1091 -0
- chainlit/frontend/dist/assets/index-CwmincdQ.css +1 -0
- chainlit/frontend/dist/assets/{react-plotly-BpxUS-ab.js → react-plotly-DALmanjC.js} +1 -1
- chainlit/frontend/dist/index.html +2 -2
- chainlit/haystack/callbacks.py +4 -5
- chainlit/input_widget.py +4 -6
- chainlit/langchain/callbacks.py +47 -56
- chainlit/langflow/__init__.py +0 -1
- chainlit/llama_index/callbacks.py +7 -7
- chainlit/message.py +7 -6
- chainlit/mistralai/__init__.py +2 -3
- chainlit/oauth_providers.py +3 -70
- chainlit/openai/__init__.py +2 -3
- chainlit/secret.py +1 -1
- chainlit/server.py +174 -474
- chainlit/session.py +5 -7
- chainlit/slack/app.py +2 -3
- chainlit/socket.py +103 -78
- chainlit/step.py +11 -11
- chainlit/sync.py +1 -2
- chainlit/teams/app.py +0 -1
- chainlit/types.py +4 -20
- chainlit/user.py +1 -2
- chainlit/utils.py +2 -3
- {chainlit-2.0.0.dist-info → chainlit-2.0.dev1.dist-info}/METADATA +38 -8
- chainlit-2.0.dev1.dist-info/RECORD +99 -0
- chainlit/auth/cookie.py +0 -123
- chainlit/auth/jwt.py +0 -37
- chainlit/data/chainlit_data_layer.py +0 -584
- chainlit/data/storage_clients/azure_blob.py +0 -80
- chainlit/data/storage_clients/gcs.py +0 -78
- chainlit/frontend/dist/assets/Dataframe-DVgwSMU2.js +0 -22
- chainlit/frontend/dist/assets/Wistia-Cu4zZ2Ci.js +0 -1
- chainlit/frontend/dist/assets/index-CI4qFOt5.js +0 -8665
- chainlit/frontend/dist/assets/index-CrrqM0nZ.css +0 -1
- chainlit/translations/nl-NL.json +0 -229
- chainlit-2.0.0.dist-info/RECORD +0 -106
- {chainlit-2.0.0.dist-info → chainlit-2.0.dev1.dist-info}/WHEEL +0 -0
- {chainlit-2.0.0.dist-info → chainlit-2.0.dev1.dist-info}/entry_points.txt +0 -0
chainlit/config.py
CHANGED
|
@@ -17,30 +17,22 @@ from typing import (
|
|
|
17
17
|
)
|
|
18
18
|
|
|
19
19
|
import tomli
|
|
20
|
-
from dataclasses_json import DataClassJsonMixin
|
|
21
|
-
from pydantic import Field
|
|
22
|
-
from pydantic.dataclasses import dataclass
|
|
23
|
-
from starlette.datastructures import Headers
|
|
24
|
-
|
|
25
|
-
from chainlit.data.base import BaseDataLayer
|
|
26
20
|
from chainlit.logger import logger
|
|
27
21
|
from chainlit.translations import lint_translation_json
|
|
28
22
|
from chainlit.version import __version__
|
|
23
|
+
from dataclasses_json import DataClassJsonMixin
|
|
24
|
+
from pydantic.dataclasses import Field, dataclass
|
|
25
|
+
from starlette.datastructures import Headers
|
|
29
26
|
|
|
30
27
|
from ._utils import is_path_inside
|
|
31
28
|
|
|
32
29
|
if TYPE_CHECKING:
|
|
33
|
-
from fastapi import Request, Response
|
|
34
|
-
|
|
35
30
|
from chainlit.action import Action
|
|
36
31
|
from chainlit.message import Message
|
|
37
|
-
from chainlit.types import
|
|
32
|
+
from chainlit.types import InputAudioChunk, ChatProfile, Starter, ThreadDict
|
|
38
33
|
from chainlit.user import User
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# within `typing.Callable`, alias to `Any` as Pydantic does not perform validation
|
|
42
|
-
# of callable argument/return types anyway.
|
|
43
|
-
Request = Response = Action = Message = ChatProfile = InputAudioChunk = Starter = ThreadDict = User = Any # fmt: off
|
|
34
|
+
from fastapi import Request, Response
|
|
35
|
+
|
|
44
36
|
|
|
45
37
|
BACKEND_ROOT = os.path.dirname(__file__)
|
|
46
38
|
PACKAGE_ROOT = os.path.dirname(os.path.dirname(BACKEND_ROOT))
|
|
@@ -55,7 +47,6 @@ FILES_DIRECTORY = Path(APP_ROOT) / ".files"
|
|
|
55
47
|
FILES_DIRECTORY.mkdir(exist_ok=True)
|
|
56
48
|
|
|
57
49
|
config_dir = os.path.join(APP_ROOT, ".chainlit")
|
|
58
|
-
public_dir = os.path.join(APP_ROOT, "public")
|
|
59
50
|
config_file = os.path.join(config_dir, "config.toml")
|
|
60
51
|
config_translation_dir = os.path.join(config_dir, "translations")
|
|
61
52
|
|
|
@@ -80,6 +71,9 @@ cache = false
|
|
|
80
71
|
# Authorized origins
|
|
81
72
|
allow_origins = ["*"]
|
|
82
73
|
|
|
74
|
+
# Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
|
|
75
|
+
# follow_symlink = false
|
|
76
|
+
|
|
83
77
|
[features]
|
|
84
78
|
# Process and display HTML in messages. This can be a security risk (see https://stackoverflow.com/questions/19603097/why-is-it-dangerous-to-render-user-generated-html-or-javascript)
|
|
85
79
|
unsafe_allow_html = false
|
|
@@ -108,13 +102,12 @@ edit_message = true
|
|
|
108
102
|
# Name of the assistant.
|
|
109
103
|
name = "Assistant"
|
|
110
104
|
|
|
111
|
-
# default_theme = "dark"
|
|
112
|
-
|
|
113
|
-
# layout = "wide"
|
|
114
|
-
|
|
115
105
|
# Description of the assistant. This is used for HTML tags.
|
|
116
106
|
# description = ""
|
|
117
107
|
|
|
108
|
+
# Large size content are by default collapsed for a cleaner ui
|
|
109
|
+
default_collapse_content = true
|
|
110
|
+
|
|
118
111
|
# Chain of Thought (CoT) display mode. Can be "hidden", "tool_call" or "full".
|
|
119
112
|
cot = "full"
|
|
120
113
|
|
|
@@ -129,6 +122,9 @@ cot = "full"
|
|
|
129
122
|
# The Javascript file can be served from the public directory.
|
|
130
123
|
# custom_js = "/public/test.js"
|
|
131
124
|
|
|
125
|
+
# Specify a custom font url.
|
|
126
|
+
# custom_font = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap"
|
|
127
|
+
|
|
132
128
|
# Specify a custom meta image url.
|
|
133
129
|
# custom_meta_image_url = "https://chainlit-cloud.s3.eu-west-3.amazonaws.com/logo/chainlit_banner.png"
|
|
134
130
|
|
|
@@ -137,6 +133,36 @@ cot = "full"
|
|
|
137
133
|
# Be careful: If this is a relative path, it should not start with a slash.
|
|
138
134
|
# custom_build = "./public/build"
|
|
139
135
|
|
|
136
|
+
[UI.theme]
|
|
137
|
+
default = "dark"
|
|
138
|
+
#layout = "wide"
|
|
139
|
+
#font_family = "Inter, sans-serif"
|
|
140
|
+
# Override default MUI light theme. (Check theme.ts)
|
|
141
|
+
[UI.theme.light]
|
|
142
|
+
#background = "#FAFAFA"
|
|
143
|
+
#paper = "#FFFFFF"
|
|
144
|
+
|
|
145
|
+
[UI.theme.light.primary]
|
|
146
|
+
#main = "#F80061"
|
|
147
|
+
#dark = "#980039"
|
|
148
|
+
#light = "#FFE7EB"
|
|
149
|
+
[UI.theme.light.text]
|
|
150
|
+
#primary = "#212121"
|
|
151
|
+
#secondary = "#616161"
|
|
152
|
+
|
|
153
|
+
# Override default MUI dark theme. (Check theme.ts)
|
|
154
|
+
[UI.theme.dark]
|
|
155
|
+
#background = "#FAFAFA"
|
|
156
|
+
#paper = "#FFFFFF"
|
|
157
|
+
|
|
158
|
+
[UI.theme.dark.primary]
|
|
159
|
+
#main = "#F80061"
|
|
160
|
+
#dark = "#980039"
|
|
161
|
+
#light = "#FFE7EB"
|
|
162
|
+
[UI.theme.dark.text]
|
|
163
|
+
#primary = "#EEEEEE"
|
|
164
|
+
#secondary = "#BDBDBD"
|
|
165
|
+
|
|
140
166
|
[meta]
|
|
141
167
|
generated_by = "{__version__}"
|
|
142
168
|
"""
|
|
@@ -184,6 +210,15 @@ class Palette(DataClassJsonMixin):
|
|
|
184
210
|
text: Optional[TextOptions] = None
|
|
185
211
|
|
|
186
212
|
|
|
213
|
+
@dataclass()
|
|
214
|
+
class Theme(DataClassJsonMixin):
|
|
215
|
+
font_family: Optional[str] = None
|
|
216
|
+
default: Optional[Literal["light", "dark"]] = "dark"
|
|
217
|
+
layout: Optional[Literal["default", "wide"]] = "default"
|
|
218
|
+
light: Optional[Palette] = None
|
|
219
|
+
dark: Optional[Palette] = None
|
|
220
|
+
|
|
221
|
+
|
|
187
222
|
@dataclass
|
|
188
223
|
class SpontaneousFileUploadFeature(DataClassJsonMixin):
|
|
189
224
|
enabled: Optional[bool] = None
|
|
@@ -213,13 +248,14 @@ class UISettings(DataClassJsonMixin):
|
|
|
213
248
|
name: str
|
|
214
249
|
description: str = ""
|
|
215
250
|
cot: Literal["hidden", "tool_call", "full"] = "full"
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
layout: Optional[Literal["default", "wide"]] = "default"
|
|
251
|
+
# Large size content are by default collapsed for a cleaner ui
|
|
252
|
+
default_collapse_content: bool = True
|
|
219
253
|
github: Optional[str] = None
|
|
254
|
+
theme: Optional[Theme] = None
|
|
220
255
|
# Optional custom CSS file that allows you to customize the UI
|
|
221
256
|
custom_css: Optional[str] = None
|
|
222
257
|
custom_js: Optional[str] = None
|
|
258
|
+
custom_font: Optional[str] = None
|
|
223
259
|
# Optional custom meta tag for image preview
|
|
224
260
|
custom_meta_image_url: Optional[str] = None
|
|
225
261
|
# Optional custom build directory for the frontend
|
|
@@ -236,9 +272,9 @@ class CodeSettings:
|
|
|
236
272
|
password_auth_callback: Optional[
|
|
237
273
|
Callable[[str, str], Awaitable[Optional["User"]]]
|
|
238
274
|
] = None
|
|
239
|
-
header_auth_callback: Optional[
|
|
240
|
-
|
|
241
|
-
|
|
275
|
+
header_auth_callback: Optional[
|
|
276
|
+
Callable[[Headers], Awaitable[Optional["User"]]]
|
|
277
|
+
] = None
|
|
242
278
|
oauth_callback: Optional[
|
|
243
279
|
Callable[[str, str, Dict[str, str], "User"], Awaitable[Optional["User"]]]
|
|
244
280
|
] = None
|
|
@@ -248,7 +284,6 @@ class CodeSettings:
|
|
|
248
284
|
on_chat_end: Optional[Callable[[], Any]] = None
|
|
249
285
|
on_chat_resume: Optional[Callable[["ThreadDict"], Any]] = None
|
|
250
286
|
on_message: Optional[Callable[["Message"], Any]] = None
|
|
251
|
-
on_window_message: Optional[Callable[[str], Any]] = None
|
|
252
287
|
on_audio_start: Optional[Callable[[], Any]] = None
|
|
253
288
|
on_audio_chunk: Optional[Callable[["InputAudioChunk"], Any]] = None
|
|
254
289
|
on_audio_end: Optional[Callable[[], Any]] = None
|
|
@@ -258,17 +293,14 @@ class CodeSettings:
|
|
|
258
293
|
set_chat_profiles: Optional[
|
|
259
294
|
Callable[[Optional["User"]], Awaitable[List["ChatProfile"]]]
|
|
260
295
|
] = None
|
|
261
|
-
set_starters: Optional[
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
data_layer: Optional[Callable[[], BaseDataLayer]] = None
|
|
296
|
+
set_starters: Optional[
|
|
297
|
+
Callable[[Optional["User"]], Awaitable[List["Starter"]]]
|
|
298
|
+
] = None
|
|
265
299
|
|
|
266
300
|
|
|
267
301
|
@dataclass()
|
|
268
302
|
class ProjectSettings(DataClassJsonMixin):
|
|
269
303
|
allow_origins: List[str] = Field(default_factory=lambda: ["*"])
|
|
270
|
-
# Socket.io client transports option
|
|
271
|
-
transports: Optional[List[str]] = None
|
|
272
304
|
enable_telemetry: bool = True
|
|
273
305
|
# List of environment variables to be provided by each user to use the app. If empty, no environment variables will be asked to the user.
|
|
274
306
|
user_env: Optional[List[str]] = None
|
|
@@ -281,6 +313,8 @@ class ProjectSettings(DataClassJsonMixin):
|
|
|
281
313
|
user_session_timeout: int = 1296000 # 15 days
|
|
282
314
|
# Enable third parties caching (e.g LangChain cache)
|
|
283
315
|
cache: bool = False
|
|
316
|
+
# Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
|
|
317
|
+
follow_symlink: bool = False
|
|
284
318
|
|
|
285
319
|
|
|
286
320
|
@dataclass()
|
|
@@ -361,7 +395,7 @@ def init_config(log=False):
|
|
|
361
395
|
dst = os.path.join(config_translation_dir, file)
|
|
362
396
|
if not os.path.exists(dst):
|
|
363
397
|
src = os.path.join(TRANSLATIONS_DIR, file)
|
|
364
|
-
with open(src, encoding="utf-8") as f:
|
|
398
|
+
with open(src, "r", encoding="utf-8") as f:
|
|
365
399
|
translation = json.load(f)
|
|
366
400
|
with open(dst, "w", encoding="utf-8") as f:
|
|
367
401
|
json.dump(translation, f, indent=4)
|
|
@@ -476,7 +510,7 @@ def load_config():
|
|
|
476
510
|
def lint_translations():
|
|
477
511
|
# Load the ground truth (en-US.json file from chainlit source code)
|
|
478
512
|
src = os.path.join(TRANSLATIONS_DIR, "en-US.json")
|
|
479
|
-
with open(src, encoding="utf-8") as f:
|
|
513
|
+
with open(src, "r", encoding="utf-8") as f:
|
|
480
514
|
truth = json.load(f)
|
|
481
515
|
|
|
482
516
|
# Find the local app translations
|
|
@@ -484,7 +518,7 @@ def lint_translations():
|
|
|
484
518
|
if file.endswith(".json"):
|
|
485
519
|
# Load the translation file
|
|
486
520
|
to_lint = os.path.join(config_translation_dir, file)
|
|
487
|
-
with open(to_lint, encoding="utf-8") as f:
|
|
521
|
+
with open(to_lint, "r", encoding="utf-8") as f:
|
|
488
522
|
translation = json.load(f)
|
|
489
523
|
|
|
490
524
|
# Lint the translation file
|
chainlit/context.py
CHANGED
|
@@ -3,9 +3,8 @@ import uuid
|
|
|
3
3
|
from contextvars import ContextVar
|
|
4
4
|
from typing import TYPE_CHECKING, Dict, List, Optional, Union
|
|
5
5
|
|
|
6
|
-
from lazify import LazyProxy
|
|
7
|
-
|
|
8
6
|
from chainlit.session import ClientType, HTTPSession, WebsocketSession
|
|
7
|
+
from lazify import LazyProxy
|
|
9
8
|
|
|
10
9
|
if TYPE_CHECKING:
|
|
11
10
|
from chainlit.emitter import BaseChainlitEmitter
|
|
@@ -105,7 +104,7 @@ def get_context() -> ChainlitContext:
|
|
|
105
104
|
try:
|
|
106
105
|
return context_var.get()
|
|
107
106
|
except LookupError as e:
|
|
108
|
-
raise ChainlitContextException from e
|
|
107
|
+
raise ChainlitContextException() from e
|
|
109
108
|
|
|
110
109
|
|
|
111
110
|
context: ChainlitContext = LazyProxy(get_context, enable_cache=False)
|