chainlit 2.0rc0__py3-none-any.whl → 2.0.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.

Files changed (76) hide show
  1. chainlit/__init__.py +49 -54
  2. chainlit/action.py +12 -10
  3. chainlit/{auth.py → auth/__init__.py} +20 -34
  4. chainlit/auth/cookie.py +123 -0
  5. chainlit/auth/jwt.py +37 -0
  6. chainlit/callbacks.py +29 -1
  7. chainlit/chat_context.py +2 -2
  8. chainlit/chat_settings.py +3 -1
  9. chainlit/cli/__init__.py +14 -1
  10. chainlit/config.py +21 -59
  11. chainlit/context.py +3 -2
  12. chainlit/copilot/dist/index.js +8319 -1019
  13. chainlit/data/__init__.py +98 -17
  14. chainlit/data/acl.py +3 -2
  15. chainlit/data/base.py +1 -1
  16. chainlit/data/chainlit_data_layer.py +584 -0
  17. chainlit/data/dynamodb.py +5 -3
  18. chainlit/data/literalai.py +4 -6
  19. chainlit/data/sql_alchemy.py +8 -7
  20. chainlit/data/storage_clients/azure.py +1 -0
  21. chainlit/data/storage_clients/azure_blob.py +80 -0
  22. chainlit/data/storage_clients/base.py +6 -0
  23. chainlit/data/storage_clients/gcs.py +78 -0
  24. chainlit/data/storage_clients/s3.py +16 -3
  25. chainlit/discord/app.py +2 -1
  26. chainlit/element.py +13 -9
  27. chainlit/emitter.py +17 -21
  28. chainlit/frontend/dist/assets/{DailyMotion-CleI-8Dh.js → DailyMotion-B8XgmoRm.js} +1 -1
  29. chainlit/frontend/dist/assets/Dataframe-VU4lXMbv.js +22 -0
  30. chainlit/frontend/dist/assets/{Facebook-C4PuTowX.js → Facebook-fVIMi9h_.js} +1 -1
  31. chainlit/frontend/dist/assets/{FilePlayer-D49YToZz.js → FilePlayer-DlXvvaZa.js} +1 -1
  32. chainlit/frontend/dist/assets/{Kaltura-BkZcQEIs.js → Kaltura-C48Ui_4V.js} +1 -1
  33. chainlit/frontend/dist/assets/{Mixcloud-DzvBFYsm.js → Mixcloud-Dmjz7RrS.js} +1 -1
  34. chainlit/frontend/dist/assets/{Mux-UXPyWWYv.js → Mux-Bqaa3ZzG.js} +1 -1
  35. chainlit/frontend/dist/assets/{Preview-0YXzpiVm.js → Preview-B2d1Ugq4.js} +1 -1
  36. chainlit/frontend/dist/assets/{SoundCloud-CS54COex.js → SoundCloud-BGuk87T3.js} +1 -1
  37. chainlit/frontend/dist/assets/{Streamable-DYYShO6Q.js → Streamable-DOe4rXrG.js} +1 -1
  38. chainlit/frontend/dist/assets/{Twitch-DG7403Hm.js → Twitch-TA7I2UEi.js} +1 -1
  39. chainlit/frontend/dist/assets/{Vidyard-C5JbOHIQ.js → Vidyard-B5F6Dk_y.js} +1 -1
  40. chainlit/frontend/dist/assets/{Vimeo-dFLZbhqH.js → Vimeo-DP_Y98tQ.js} +1 -1
  41. chainlit/frontend/dist/assets/Wistia-DB26BTg8.js +1 -0
  42. chainlit/frontend/dist/assets/{YouTube-Dct4gpfH.js → YouTube-CMwwf2TN.js} +1 -1
  43. chainlit/frontend/dist/assets/index-88S3ZtD5.css +1 -0
  44. chainlit/frontend/dist/assets/index-D7lZEN9m.js +8665 -0
  45. chainlit/frontend/dist/assets/{react-plotly-CFHBSMgg.js → react-plotly-28_xImPF.js} +1 -1
  46. chainlit/frontend/dist/index.html +2 -2
  47. chainlit/haystack/callbacks.py +5 -4
  48. chainlit/input_widget.py +6 -4
  49. chainlit/langchain/callbacks.py +56 -47
  50. chainlit/langflow/__init__.py +1 -0
  51. chainlit/llama_index/callbacks.py +7 -7
  52. chainlit/message.py +6 -7
  53. chainlit/mistralai/__init__.py +3 -2
  54. chainlit/oauth_providers.py +70 -3
  55. chainlit/openai/__init__.py +3 -2
  56. chainlit/secret.py +1 -1
  57. chainlit/server.py +483 -199
  58. chainlit/session.py +7 -5
  59. chainlit/slack/app.py +3 -2
  60. chainlit/socket.py +79 -106
  61. chainlit/step.py +11 -11
  62. chainlit/sync.py +2 -1
  63. chainlit/teams/app.py +1 -0
  64. chainlit/translations/en-US.json +1 -1
  65. chainlit/translations/nl-NL.json +229 -0
  66. chainlit/types.py +20 -4
  67. chainlit/user.py +2 -1
  68. chainlit/utils.py +3 -2
  69. {chainlit-2.0rc0.dist-info → chainlit-2.0.1.dist-info}/METADATA +3 -34
  70. chainlit-2.0.1.dist-info/RECORD +106 -0
  71. chainlit/frontend/dist/assets/Wistia-143Q9V9c.js +0 -1
  72. chainlit/frontend/dist/assets/index-2yAiK0R5.js +0 -1091
  73. chainlit/frontend/dist/assets/index-CwmincdQ.css +0 -1
  74. chainlit-2.0rc0.dist-info/RECORD +0 -99
  75. {chainlit-2.0rc0.dist-info → chainlit-2.0.1.dist-info}/WHEEL +0 -0
  76. {chainlit-2.0rc0.dist-info → chainlit-2.0.1.dist-info}/entry_points.txt +0 -0
chainlit/config.py CHANGED
@@ -18,7 +18,8 @@ from typing import (
18
18
 
19
19
  import tomli
20
20
  from dataclasses_json import DataClassJsonMixin
21
- from pydantic.dataclasses import Field, dataclass
21
+ from pydantic import Field
22
+ from pydantic.dataclasses import dataclass
22
23
  from starlette.datastructures import Headers
23
24
 
24
25
  from chainlit.data.base import BaseDataLayer
@@ -35,7 +36,11 @@ if TYPE_CHECKING:
35
36
  from chainlit.message import Message
36
37
  from chainlit.types import ChatProfile, InputAudioChunk, Starter, ThreadDict
37
38
  from chainlit.user import User
38
-
39
+ else:
40
+ # Pydantic needs to resolve forward annotations. Because all of these are used
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
39
44
 
40
45
  BACKEND_ROOT = os.path.dirname(__file__)
41
46
  PACKAGE_ROOT = os.path.dirname(os.path.dirname(BACKEND_ROOT))
@@ -50,6 +55,7 @@ FILES_DIRECTORY = Path(APP_ROOT) / ".files"
50
55
  FILES_DIRECTORY.mkdir(exist_ok=True)
51
56
 
52
57
  config_dir = os.path.join(APP_ROOT, ".chainlit")
58
+ public_dir = os.path.join(APP_ROOT, "public")
53
59
  config_file = os.path.join(config_dir, "config.toml")
54
60
  config_translation_dir = os.path.join(config_dir, "translations")
55
61
 
@@ -74,9 +80,6 @@ cache = false
74
80
  # Authorized origins
75
81
  allow_origins = ["*"]
76
82
 
77
- # Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
78
- # follow_symlink = false
79
-
80
83
  [features]
81
84
  # 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)
82
85
  unsafe_allow_html = false
@@ -105,12 +108,13 @@ edit_message = true
105
108
  # Name of the assistant.
106
109
  name = "Assistant"
107
110
 
111
+ # default_theme = "dark"
112
+
113
+ # layout = "wide"
114
+
108
115
  # Description of the assistant. This is used for HTML tags.
109
116
  # description = ""
110
117
 
111
- # Large size content are by default collapsed for a cleaner ui
112
- default_collapse_content = true
113
-
114
118
  # Chain of Thought (CoT) display mode. Can be "hidden", "tool_call" or "full".
115
119
  cot = "full"
116
120
 
@@ -125,9 +129,6 @@ cot = "full"
125
129
  # The Javascript file can be served from the public directory.
126
130
  # custom_js = "/public/test.js"
127
131
 
128
- # Specify a custom font url.
129
- # custom_font = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap"
130
-
131
132
  # Specify a custom meta image url.
132
133
  # custom_meta_image_url = "https://chainlit-cloud.s3.eu-west-3.amazonaws.com/logo/chainlit_banner.png"
133
134
 
@@ -136,36 +137,6 @@ cot = "full"
136
137
  # Be careful: If this is a relative path, it should not start with a slash.
137
138
  # custom_build = "./public/build"
138
139
 
139
- [UI.theme]
140
- default = "dark"
141
- #layout = "wide"
142
- #font_family = "Inter, sans-serif"
143
- # Override default MUI light theme. (Check theme.ts)
144
- [UI.theme.light]
145
- #background = "#FAFAFA"
146
- #paper = "#FFFFFF"
147
-
148
- [UI.theme.light.primary]
149
- #main = "#F80061"
150
- #dark = "#980039"
151
- #light = "#FFE7EB"
152
- [UI.theme.light.text]
153
- #primary = "#212121"
154
- #secondary = "#616161"
155
-
156
- # Override default MUI dark theme. (Check theme.ts)
157
- [UI.theme.dark]
158
- #background = "#FAFAFA"
159
- #paper = "#FFFFFF"
160
-
161
- [UI.theme.dark.primary]
162
- #main = "#F80061"
163
- #dark = "#980039"
164
- #light = "#FFE7EB"
165
- [UI.theme.dark.text]
166
- #primary = "#EEEEEE"
167
- #secondary = "#BDBDBD"
168
-
169
140
  [meta]
170
141
  generated_by = "{__version__}"
171
142
  """
@@ -213,15 +184,6 @@ class Palette(DataClassJsonMixin):
213
184
  text: Optional[TextOptions] = None
214
185
 
215
186
 
216
- @dataclass()
217
- class Theme(DataClassJsonMixin):
218
- font_family: Optional[str] = None
219
- default: Optional[Literal["light", "dark"]] = "dark"
220
- layout: Optional[Literal["default", "wide"]] = "default"
221
- light: Optional[Palette] = None
222
- dark: Optional[Palette] = None
223
-
224
-
225
187
  @dataclass
226
188
  class SpontaneousFileUploadFeature(DataClassJsonMixin):
227
189
  enabled: Optional[bool] = None
@@ -251,14 +213,13 @@ class UISettings(DataClassJsonMixin):
251
213
  name: str
252
214
  description: str = ""
253
215
  cot: Literal["hidden", "tool_call", "full"] = "full"
254
- # Large size content are by default collapsed for a cleaner ui
255
- default_collapse_content: bool = True
216
+ font_family: Optional[str] = None
217
+ default_theme: Optional[Literal["light", "dark"]] = "dark"
218
+ layout: Optional[Literal["default", "wide"]] = "default"
256
219
  github: Optional[str] = None
257
- theme: Optional[Theme] = None
258
220
  # Optional custom CSS file that allows you to customize the UI
259
221
  custom_css: Optional[str] = None
260
222
  custom_js: Optional[str] = None
261
- custom_font: Optional[str] = None
262
223
  # Optional custom meta tag for image preview
263
224
  custom_meta_image_url: Optional[str] = None
264
225
  # Optional custom build directory for the frontend
@@ -287,6 +248,7 @@ class CodeSettings:
287
248
  on_chat_end: Optional[Callable[[], Any]] = None
288
249
  on_chat_resume: Optional[Callable[["ThreadDict"], Any]] = None
289
250
  on_message: Optional[Callable[["Message"], Any]] = None
251
+ on_window_message: Optional[Callable[[str], Any]] = None
290
252
  on_audio_start: Optional[Callable[[], Any]] = None
291
253
  on_audio_chunk: Optional[Callable[["InputAudioChunk"], Any]] = None
292
254
  on_audio_end: Optional[Callable[[], Any]] = None
@@ -305,6 +267,8 @@ class CodeSettings:
305
267
  @dataclass()
306
268
  class ProjectSettings(DataClassJsonMixin):
307
269
  allow_origins: List[str] = Field(default_factory=lambda: ["*"])
270
+ # Socket.io client transports option
271
+ transports: Optional[List[str]] = None
308
272
  enable_telemetry: bool = True
309
273
  # 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.
310
274
  user_env: Optional[List[str]] = None
@@ -317,8 +281,6 @@ class ProjectSettings(DataClassJsonMixin):
317
281
  user_session_timeout: int = 1296000 # 15 days
318
282
  # Enable third parties caching (e.g LangChain cache)
319
283
  cache: bool = False
320
- # Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
321
- follow_symlink: bool = False
322
284
 
323
285
 
324
286
  @dataclass()
@@ -399,7 +361,7 @@ def init_config(log=False):
399
361
  dst = os.path.join(config_translation_dir, file)
400
362
  if not os.path.exists(dst):
401
363
  src = os.path.join(TRANSLATIONS_DIR, file)
402
- with open(src, "r", encoding="utf-8") as f:
364
+ with open(src, encoding="utf-8") as f:
403
365
  translation = json.load(f)
404
366
  with open(dst, "w", encoding="utf-8") as f:
405
367
  json.dump(translation, f, indent=4)
@@ -514,7 +476,7 @@ def load_config():
514
476
  def lint_translations():
515
477
  # Load the ground truth (en-US.json file from chainlit source code)
516
478
  src = os.path.join(TRANSLATIONS_DIR, "en-US.json")
517
- with open(src, "r", encoding="utf-8") as f:
479
+ with open(src, encoding="utf-8") as f:
518
480
  truth = json.load(f)
519
481
 
520
482
  # Find the local app translations
@@ -522,7 +484,7 @@ def lint_translations():
522
484
  if file.endswith(".json"):
523
485
  # Load the translation file
524
486
  to_lint = os.path.join(config_translation_dir, file)
525
- with open(to_lint, "r", encoding="utf-8") as f:
487
+ with open(to_lint, encoding="utf-8") as f:
526
488
  translation = json.load(f)
527
489
 
528
490
  # Lint the translation file
chainlit/context.py CHANGED
@@ -3,9 +3,10 @@ import uuid
3
3
  from contextvars import ContextVar
4
4
  from typing import TYPE_CHECKING, Dict, List, Optional, Union
5
5
 
6
- from chainlit.session import ClientType, HTTPSession, WebsocketSession
7
6
  from lazify import LazyProxy
8
7
 
8
+ from chainlit.session import ClientType, HTTPSession, WebsocketSession
9
+
9
10
  if TYPE_CHECKING:
10
11
  from chainlit.emitter import BaseChainlitEmitter
11
12
  from chainlit.step import Step
@@ -104,7 +105,7 @@ def get_context() -> ChainlitContext:
104
105
  try:
105
106
  return context_var.get()
106
107
  except LookupError as e:
107
- raise ChainlitContextException() from e
108
+ raise ChainlitContextException from e
108
109
 
109
110
 
110
111
  context: ChainlitContext = LazyProxy(get_context, enable_cache=False)