chainlit 2.0.0__py3-none-any.whl → 2.0.dev0__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 (98) hide show
  1. chainlit/__init__.py +57 -56
  2. chainlit/action.py +10 -12
  3. chainlit/{auth/__init__.py → auth.py} +34 -26
  4. chainlit/cache.py +6 -4
  5. chainlit/callbacks.py +7 -52
  6. chainlit/chat_context.py +2 -2
  7. chainlit/chat_settings.py +1 -3
  8. chainlit/cli/__init__.py +2 -15
  9. chainlit/config.py +70 -41
  10. chainlit/context.py +9 -8
  11. chainlit/copilot/dist/index.js +874 -8533
  12. chainlit/data/__init__.py +8 -96
  13. chainlit/data/acl.py +2 -3
  14. chainlit/data/base.py +15 -1
  15. chainlit/data/dynamodb.py +4 -7
  16. chainlit/data/literalai.py +6 -4
  17. chainlit/data/sql_alchemy.py +9 -10
  18. chainlit/data/{storage_clients/azure.py → storage_clients.py} +33 -2
  19. chainlit/discord/__init__.py +4 -4
  20. chainlit/discord/app.py +1 -2
  21. chainlit/element.py +9 -41
  22. chainlit/emitter.py +21 -17
  23. chainlit/frontend/dist/assets/DailyMotion-b4b7af47.js +1 -0
  24. chainlit/frontend/dist/assets/Facebook-572972a0.js +1 -0
  25. chainlit/frontend/dist/assets/FilePlayer-85c69ca8.js +1 -0
  26. chainlit/frontend/dist/assets/Kaltura-dfc24672.js +1 -0
  27. chainlit/frontend/dist/assets/Mixcloud-705011f4.js +1 -0
  28. chainlit/frontend/dist/assets/Mux-4201a9e6.js +1 -0
  29. chainlit/frontend/dist/assets/Preview-23ba40a6.js +1 -0
  30. chainlit/frontend/dist/assets/SoundCloud-1a582d51.js +1 -0
  31. chainlit/frontend/dist/assets/Streamable-5017c4ba.js +1 -0
  32. chainlit/frontend/dist/assets/Twitch-bb2de2fa.js +1 -0
  33. chainlit/frontend/dist/assets/Vidyard-54e269b1.js +1 -0
  34. chainlit/frontend/dist/assets/Vimeo-d92c37dd.js +1 -0
  35. chainlit/frontend/dist/assets/Wistia-25a1363b.js +1 -0
  36. chainlit/frontend/dist/assets/YouTube-616e8cb7.js +1 -0
  37. chainlit/frontend/dist/assets/index-aaf974a9.css +1 -0
  38. chainlit/frontend/dist/assets/index-f5df2072.js +1027 -0
  39. chainlit/frontend/dist/assets/{react-plotly-BpxUS-ab.js → react-plotly-f0315f86.js} +94 -94
  40. chainlit/frontend/dist/index.html +3 -2
  41. chainlit/haystack/callbacks.py +4 -5
  42. chainlit/input_widget.py +4 -6
  43. chainlit/langchain/callbacks.py +47 -56
  44. chainlit/langflow/__init__.py +0 -1
  45. chainlit/llama_index/callbacks.py +7 -7
  46. chainlit/message.py +10 -8
  47. chainlit/mistralai/__init__.py +2 -3
  48. chainlit/oauth_providers.py +12 -113
  49. chainlit/openai/__init__.py +7 -6
  50. chainlit/secret.py +1 -1
  51. chainlit/server.py +181 -491
  52. chainlit/session.py +5 -7
  53. chainlit/slack/__init__.py +3 -3
  54. chainlit/slack/app.py +2 -3
  55. chainlit/socket.py +103 -78
  56. chainlit/step.py +29 -21
  57. chainlit/sync.py +1 -2
  58. chainlit/teams/__init__.py +3 -3
  59. chainlit/teams/app.py +0 -1
  60. chainlit/types.py +4 -20
  61. chainlit/user.py +1 -2
  62. chainlit/utils.py +2 -3
  63. chainlit/version.py +2 -3
  64. {chainlit-2.0.0.dist-info → chainlit-2.0.dev0.dist-info}/METADATA +39 -27
  65. chainlit-2.0.dev0.dist-info/RECORD +96 -0
  66. chainlit/auth/cookie.py +0 -123
  67. chainlit/auth/jwt.py +0 -37
  68. chainlit/data/chainlit_data_layer.py +0 -584
  69. chainlit/data/storage_clients/__init__.py +0 -0
  70. chainlit/data/storage_clients/azure_blob.py +0 -80
  71. chainlit/data/storage_clients/base.py +0 -22
  72. chainlit/data/storage_clients/gcs.py +0 -78
  73. chainlit/data/storage_clients/s3.py +0 -49
  74. chainlit/frontend/dist/assets/DailyMotion-DgRzV5GZ.js +0 -1
  75. chainlit/frontend/dist/assets/Dataframe-DVgwSMU2.js +0 -22
  76. chainlit/frontend/dist/assets/Facebook-C0vx6HWv.js +0 -1
  77. chainlit/frontend/dist/assets/FilePlayer-CdhzeHPP.js +0 -1
  78. chainlit/frontend/dist/assets/Kaltura-5iVmeUct.js +0 -1
  79. chainlit/frontend/dist/assets/Mixcloud-C2zi77Ex.js +0 -1
  80. chainlit/frontend/dist/assets/Mux-Vkebogdf.js +0 -1
  81. chainlit/frontend/dist/assets/Preview-DwY_sEIl.js +0 -1
  82. chainlit/frontend/dist/assets/SoundCloud-CREBXAWo.js +0 -1
  83. chainlit/frontend/dist/assets/Streamable-B5Lu25uy.js +0 -1
  84. chainlit/frontend/dist/assets/Twitch-y9iKCcM1.js +0 -1
  85. chainlit/frontend/dist/assets/Vidyard-ClYvcuEu.js +0 -1
  86. chainlit/frontend/dist/assets/Vimeo-D6HvM2jt.js +0 -1
  87. chainlit/frontend/dist/assets/Wistia-Cu4zZ2Ci.js +0 -1
  88. chainlit/frontend/dist/assets/YouTube-D10tR6CJ.js +0 -1
  89. chainlit/frontend/dist/assets/index-CI4qFOt5.js +0 -8665
  90. chainlit/frontend/dist/assets/index-CrrqM0nZ.css +0 -1
  91. chainlit/translations/nl-NL.json +0 -229
  92. chainlit-2.0.0.dist-info/RECORD +0 -106
  93. /chainlit/copilot/dist/assets/{logo_dark-IkGJ_IwC.svg → logo_dark-2a3cf740.svg} +0 -0
  94. /chainlit/copilot/dist/assets/{logo_light-Bb_IPh6r.svg → logo_light-b078e7bc.svg} +0 -0
  95. /chainlit/frontend/dist/assets/{logo_dark-IkGJ_IwC.svg → logo_dark-2a3cf740.svg} +0 -0
  96. /chainlit/frontend/dist/assets/{logo_light-Bb_IPh6r.svg → logo_light-b078e7bc.svg} +0 -0
  97. {chainlit-2.0.0.dist-info → chainlit-2.0.dev0.dist-info}/WHEEL +0 -0
  98. {chainlit-2.0.0.dist-info → chainlit-2.0.dev0.dist-info}/entry_points.txt +0 -0
chainlit/__init__.py CHANGED
@@ -14,9 +14,6 @@ if env_found:
14
14
  import asyncio
15
15
  from typing import TYPE_CHECKING, Any, Dict
16
16
 
17
- from literalai import ChatGeneration, CompletionGeneration, GenerationMessage
18
- from pydantic.dataclasses import dataclass
19
-
20
17
  import chainlit.input_widget as input_widget
21
18
  from chainlit.action import Action
22
19
  from chainlit.cache import cache
@@ -25,8 +22,7 @@ from chainlit.chat_settings import ChatSettings
25
22
  from chainlit.context import context
26
23
  from chainlit.element import (
27
24
  Audio,
28
- CustomElement,
29
- Dataframe,
25
+ Component,
30
26
  File,
31
27
  Image,
32
28
  Pdf,
@@ -47,21 +43,22 @@ from chainlit.message import (
47
43
  )
48
44
  from chainlit.step import Step, step
49
45
  from chainlit.sync import make_async, run_sync
50
- from chainlit.types import ChatProfile, InputAudioChunk, OutputAudioChunk, Starter
46
+ from chainlit.types import InputAudioChunk, OutputAudioChunk, ChatProfile, Starter
51
47
  from chainlit.user import PersistedUser, User
52
48
  from chainlit.user_session import user_session
53
49
  from chainlit.utils import make_module_getattr
54
50
  from chainlit.version import __version__
51
+ from literalai import ChatGeneration, CompletionGeneration, GenerationMessage
52
+ from pydantic.dataclasses import dataclass
55
53
 
56
54
  from .callbacks import (
57
55
  action_callback,
58
56
  author_rename,
59
- data_layer,
60
57
  header_auth_callback,
61
58
  oauth_callback,
59
+ on_audio_start,
62
60
  on_audio_chunk,
63
61
  on_audio_end,
64
- on_audio_start,
65
62
  on_chat_end,
66
63
  on_chat_resume,
67
64
  on_chat_start,
@@ -69,9 +66,7 @@ from .callbacks import (
69
66
  on_message,
70
67
  on_settings_update,
71
68
  on_stop,
72
- on_window_message,
73
69
  password_auth_callback,
74
- send_window_message,
75
70
  set_chat_profiles,
76
71
  set_starters,
77
72
  )
@@ -117,73 +112,79 @@ __getattr__ = make_module_getattr(
117
112
  )
118
113
 
119
114
  __all__ = [
120
- "Action",
121
- "AskActionMessage",
122
- "AskFileMessage",
123
- "AskUserMessage",
124
- "AsyncLangchainCallbackHandler",
125
- "Audio",
126
- "ChatGeneration",
115
+ "__version__",
127
116
  "ChatProfile",
128
- "ChatSettings",
129
- "CompletionGeneration",
117
+ "Starter",
118
+ "user_session",
119
+ "chat_context",
130
120
  "CopilotFunction",
131
- "CustomElement",
132
- "Dataframe",
133
- "ErrorMessage",
134
- "File",
135
- "GenerationMessage",
136
- "HaystackAgentCallbackHandler",
137
- "Image",
138
121
  "InputAudioChunk",
139
- "LangchainCallbackHandler",
140
- "LlamaIndexCallbackHandler",
141
- "Message",
142
122
  "OutputAudioChunk",
143
- "Pdf",
123
+ "Action",
124
+ "User",
144
125
  "PersistedUser",
126
+ "Audio",
127
+ "Pdf",
145
128
  "Plotly",
129
+ "Image",
130
+ "Text",
131
+ "Component",
146
132
  "Pyplot",
147
- "Starter",
148
- "Step",
133
+ "File",
149
134
  "Task",
150
135
  "TaskList",
151
136
  "TaskStatus",
152
- "Text",
153
- "User",
154
137
  "Video",
155
- "__version__",
138
+ "ChatSettings",
139
+ "input_widget",
140
+ "Message",
141
+ "ErrorMessage",
142
+ "AskUserMessage",
143
+ "AskActionMessage",
144
+ "AskFileMessage",
145
+ "Step",
146
+ "step",
147
+ "ChatGeneration",
148
+ "CompletionGeneration",
149
+ "GenerationMessage",
150
+ "on_logout",
151
+ "on_chat_start",
152
+ "on_chat_end",
153
+ "on_chat_resume",
154
+ "on_stop",
156
155
  "action_callback",
157
156
  "author_rename",
157
+ "on_settings_update",
158
+ "password_auth_callback",
159
+ "header_auth_callback",
160
+ "sleep",
161
+ "run_sync",
162
+ "make_async",
158
163
  "cache",
159
- "chat_context",
160
164
  "context",
161
- "data_layer",
162
- "header_auth_callback",
163
- "input_widget",
164
- "instrument_mistralai",
165
+ "LangchainCallbackHandler",
166
+ "AsyncLangchainCallbackHandler",
167
+ "LlamaIndexCallbackHandler",
168
+ "HaystackAgentCallbackHandler",
165
169
  "instrument_openai",
166
- "make_async",
170
+ "instrument_mistralai",
171
+ "password_auth_callback",
172
+ "header_auth_callback",
167
173
  "oauth_callback",
168
- "on_audio_chunk",
169
- "on_audio_end",
170
- "on_audio_start",
171
- "on_chat_end",
172
- "on_chat_resume",
173
- "on_chat_start",
174
174
  "on_logout",
175
175
  "on_message",
176
- "on_settings_update",
177
- "on_stop",
178
- "on_window_message",
179
- "password_auth_callback",
180
- "run_sync",
181
- "send_window_message",
176
+ "on_chat_start",
177
+ "on_chat_resume",
182
178
  "set_chat_profiles",
183
179
  "set_starters",
184
- "sleep",
185
- "step",
186
- "user_session",
180
+ "on_chat_end",
181
+ "on_audio_start",
182
+ "on_audio_chunk",
183
+ "on_audio_end",
184
+ "author_rename",
185
+ "on_stop",
186
+ "action_callback",
187
+ "on_settings_update",
187
188
  ]
188
189
 
189
190
 
chainlit/action.py CHANGED
@@ -1,30 +1,28 @@
1
1
  import uuid
2
- from typing import Dict, Optional
3
-
4
- from dataclasses_json import DataClassJsonMixin
5
- from pydantic import Field
6
- from pydantic.dataclasses import dataclass
2
+ from typing import Optional
7
3
 
8
4
  from chainlit.context import context
9
5
  from chainlit.telemetry import trace_event
6
+ from dataclasses_json import DataClassJsonMixin
7
+ from pydantic.dataclasses import Field, dataclass
10
8
 
11
9
 
12
10
  @dataclass
13
11
  class Action(DataClassJsonMixin):
14
12
  # Name of the action, this should be used in the action_callback
15
13
  name: str
16
- # The parameters to call this action with.
17
- payload: Dict
18
- # The label of the action. This is what the user will see.
14
+ # The value associated with the action. This is useful to differentiate between multiple actions with the same name.
15
+ value: str
16
+ # The label of the action. This is what the user will see. If not provided the name will be used.
19
17
  label: str = ""
20
- # The tooltip of the action button. This is what the user will see when they hover the action.
21
- tooltip: str = ""
22
- # The lucid icon name for this action.
23
- icon: Optional[str] = None
18
+ # The description of the action. This is what the user will see when they hover the action.
19
+ description: str = ""
24
20
  # This should not be set manually, only used internally.
25
21
  forId: Optional[str] = None
26
22
  # The ID of the action
27
23
  id: str = Field(default_factory=lambda: str(uuid.uuid4()))
24
+ # Show the action in a drawer menu
25
+ collapsed: bool = False
28
26
 
29
27
  def __post_init__(self) -> None:
30
28
  trace_event(f"init {self.__class__.__name__}")
@@ -1,16 +1,20 @@
1
1
  import os
2
+ from datetime import datetime, timedelta
3
+ from typing import Any, Dict
2
4
 
3
- from fastapi import Depends, HTTPException
4
-
5
+ import jwt
5
6
  from chainlit.config import config
6
7
  from chainlit.data import get_data_layer
7
- from chainlit.logger import logger
8
8
  from chainlit.oauth_providers import get_configured_oauth_providers
9
+ from chainlit.user import User
10
+ from fastapi import Depends, HTTPException
11
+ from fastapi.security import OAuth2PasswordBearer
12
+
13
+ reuseable_oauth = OAuth2PasswordBearer(tokenUrl="/login", auto_error=False)
9
14
 
10
- from .cookie import OAuth2PasswordBearerWithCookie
11
- from .jwt import create_jwt, decode_jwt, get_jwt_secret
12
15
 
13
- reuseable_oauth = OAuth2PasswordBearerWithCookie(tokenUrl="/login", auto_error=False)
16
+ def get_jwt_secret():
17
+ return os.environ.get("CHAINLIT_AUTH_SECRET")
14
18
 
15
19
 
16
20
  def ensure_jwt_secret():
@@ -41,36 +45,43 @@ def get_configuration():
41
45
  "oauthProviders": (
42
46
  get_configured_oauth_providers() if is_oauth_enabled() else []
43
47
  ),
44
- "default_theme": config.ui.default_theme,
45
48
  }
46
49
 
47
50
 
51
+ def create_jwt(data: User) -> str:
52
+ to_encode: Dict[str, Any] = data.to_dict()
53
+ to_encode.update(
54
+ {
55
+ "exp": datetime.utcnow() + timedelta(minutes=60 * 24 * 15), # 15 days
56
+ }
57
+ )
58
+ encoded_jwt = jwt.encode(to_encode, get_jwt_secret(), algorithm="HS256")
59
+ return encoded_jwt
60
+
61
+
48
62
  async def authenticate_user(token: str = Depends(reuseable_oauth)):
49
63
  try:
50
- user = decode_jwt(token)
51
- except Exception as e:
52
- raise HTTPException(
53
- status_code=401, detail="Invalid authentication token"
54
- ) from e
55
-
64
+ dict = jwt.decode(
65
+ token,
66
+ get_jwt_secret(),
67
+ algorithms=["HS256"],
68
+ options={"verify_signature": True},
69
+ )
70
+ del dict["exp"]
71
+ user = User(**dict)
72
+ except Exception:
73
+ raise HTTPException(status_code=401, detail="Invalid authentication token")
56
74
  if data_layer := get_data_layer():
57
- # Get or create persistent user if we've a data layer available.
58
75
  try:
59
76
  persisted_user = await data_layer.get_user(user.identifier)
60
77
  if persisted_user is None:
61
78
  persisted_user = await data_layer.create_user(user)
62
- assert persisted_user
63
- except Exception as e:
64
- logger.exception("Unable to get persisted_user from data layer: %s", e)
79
+ except Exception:
65
80
  return user
66
81
 
67
- if user and user.display_name:
68
- # Copy ephemeral display_name from authenticated user to persistent user.
69
- persisted_user.display_name = user.display_name
70
-
71
82
  return persisted_user
72
-
73
- return user
83
+ else:
84
+ return user
74
85
 
75
86
 
76
87
  async def get_current_user(token: str = Depends(reuseable_oauth)):
@@ -78,6 +89,3 @@ async def get_current_user(token: str = Depends(reuseable_oauth)):
78
89
  return None
79
90
 
80
91
  return await authenticate_user(token)
81
-
82
-
83
- __all__ = ["create_jwt", "get_configuration", "get_current_user"]
chainlit/cache.py CHANGED
@@ -1,7 +1,5 @@
1
- import importlib.util
2
1
  import os
3
2
  import threading
4
- from typing import Any
5
3
 
6
4
  from chainlit.config import config
7
5
  from chainlit.logger import logger
@@ -10,7 +8,11 @@ from chainlit.logger import logger
10
8
  def init_lc_cache():
11
9
  use_cache = config.project.cache is True and config.run.no_cache is False
12
10
 
13
- if use_cache and importlib.util.find_spec("langchain") is not None:
11
+ if use_cache:
12
+ try:
13
+ import langchain
14
+ except ImportError:
15
+ return
14
16
  from langchain.cache import SQLiteCache
15
17
  from langchain.globals import set_llm_cache
16
18
 
@@ -23,7 +25,7 @@ def init_lc_cache():
23
25
  )
24
26
 
25
27
 
26
- _cache: dict[tuple, Any] = {}
28
+ _cache = {}
27
29
  _cache_lock = threading.Lock()
28
30
 
29
31
 
chainlit/callbacks.py CHANGED
@@ -1,13 +1,8 @@
1
1
  import inspect
2
2
  from typing import Any, Awaitable, Callable, Dict, List, Optional
3
3
 
4
- from fastapi import Request, Response
5
- from starlette.datastructures import Headers
6
-
7
4
  from chainlit.action import Action
8
5
  from chainlit.config import config
9
- from chainlit.context import context
10
- from chainlit.data.base import BaseDataLayer
11
6
  from chainlit.message import Message
12
7
  from chainlit.oauth_providers import get_configured_oauth_providers
13
8
  from chainlit.step import Step, step
@@ -15,11 +10,13 @@ from chainlit.telemetry import trace
15
10
  from chainlit.types import ChatProfile, Starter, ThreadDict
16
11
  from chainlit.user import User
17
12
  from chainlit.utils import wrap_user_function
13
+ from fastapi import Request, Response
14
+ from starlette.datastructures import Headers
18
15
 
19
16
 
20
17
  @trace
21
18
  def password_auth_callback(
22
- func: Callable[[str, str], Awaitable[Optional[User]]],
19
+ func: Callable[[str, str], Awaitable[Optional[User]]]
23
20
  ) -> Callable:
24
21
  """
25
22
  Framework agnostic decorator to authenticate the user.
@@ -41,7 +38,7 @@ def password_auth_callback(
41
38
 
42
39
  @trace
43
40
  def header_auth_callback(
44
- func: Callable[[Headers], Awaitable[Optional[User]]],
41
+ func: Callable[[Headers], Awaitable[Optional[User]]]
45
42
  ) -> Callable:
46
43
  """
47
44
  Framework agnostic decorator to authenticate the user via a header
@@ -126,33 +123,6 @@ def on_message(func: Callable) -> Callable:
126
123
  return func
127
124
 
128
125
 
129
- @trace
130
- async def send_window_message(data: Any):
131
- """
132
- Send custom data to the host window via a window.postMessage event.
133
-
134
- Args:
135
- data (Any): The data to send with the event.
136
- """
137
- await context.emitter.send_window_message(data)
138
-
139
-
140
- @trace
141
- def on_window_message(func: Callable[[str], Any]) -> Callable:
142
- """
143
- Hook to react to javascript postMessage events coming from the UI.
144
-
145
- Args:
146
- func (Callable[[str], Any]): The function to be called when a window message is received.
147
- Takes the message content as a string parameter.
148
-
149
- Returns:
150
- Callable[[str], Any]: The decorated on_window_message function.
151
- """
152
- config.code.on_window_message = wrap_user_function(func)
153
- return func
154
-
155
-
156
126
  @trace
157
127
  def on_chat_start(func: Callable) -> Callable:
158
128
  """
@@ -207,7 +177,7 @@ def set_chat_profiles(
207
177
 
208
178
  @trace
209
179
  def set_starters(
210
- func: Callable[[Optional["User"]], Awaitable[List["Starter"]]],
180
+ func: Callable[[Optional["User"]], Awaitable[List["Starter"]]]
211
181
  ) -> Callable:
212
182
  """
213
183
  Programmatic declaration of the available starter (can depend on the User from the session if authentication is setup).
@@ -251,7 +221,6 @@ def on_audio_start(func: Callable) -> Callable:
251
221
  config.code.on_audio_start = wrap_user_function(func, with_task=False)
252
222
  return func
253
223
 
254
-
255
224
  @trace
256
225
  def on_audio_chunk(func: Callable) -> Callable:
257
226
  """
@@ -285,7 +254,7 @@ def on_audio_end(func: Callable) -> Callable:
285
254
 
286
255
  @trace
287
256
  def author_rename(
288
- func: Callable[[str], Awaitable[str]],
257
+ func: Callable[[str], Awaitable[str]]
289
258
  ) -> Callable[[str], Awaitable[str]]:
290
259
  """
291
260
  Useful to rename the author of message to display more friendly author names in the UI.
@@ -325,7 +294,7 @@ def action_callback(name: str) -> Callable:
325
294
  """
326
295
 
327
296
  def decorator(func: Callable[[Action], Any]):
328
- config.code.action_callbacks[name] = wrap_user_function(func, with_task=False)
297
+ config.code.action_callbacks[name] = wrap_user_function(func, with_task=True)
329
298
  return func
330
299
 
331
300
  return decorator
@@ -346,17 +315,3 @@ def on_settings_update(
346
315
 
347
316
  config.code.on_settings_update = wrap_user_function(func, with_task=True)
348
317
  return func
349
-
350
-
351
- def data_layer(
352
- func: Callable[[], BaseDataLayer],
353
- ) -> Callable[[], BaseDataLayer]:
354
- """
355
- Hook to configure custom data layer.
356
- """
357
-
358
- # We don't use wrap_user_function here because:
359
- # 1. We don't need to support async here and;
360
- # 2. We don't want to change the API for get_data_layer() to be async, everywhere (at this point).
361
- config.code.data_layer = func
362
- return func
chainlit/chat_context.py CHANGED
@@ -25,10 +25,10 @@ class ChatContext:
25
25
 
26
26
  if context.session.id not in chat_contexts:
27
27
  chat_contexts[context.session.id] = []
28
-
28
+
29
29
  if message not in chat_contexts[context.session.id]:
30
30
  chat_contexts[context.session.id].append(message)
31
-
31
+
32
32
  return message
33
33
 
34
34
  def remove(self, message: "Message") -> bool:
chainlit/chat_settings.py CHANGED
@@ -1,10 +1,8 @@
1
1
  from typing import List
2
2
 
3
- from pydantic import Field
4
- from pydantic.dataclasses import dataclass
5
-
6
3
  from chainlit.context import context
7
4
  from chainlit.input_widget import InputWidget
5
+ from pydantic.dataclasses import Field, dataclass
8
6
 
9
7
 
10
8
  @dataclass
chainlit/cli/__init__.py CHANGED
@@ -9,7 +9,6 @@ import uvicorn
9
9
  nest_asyncio.apply()
10
10
 
11
11
  # ruff: noqa: E402
12
- from chainlit.auth import ensure_jwt_secret
13
12
  from chainlit.cache import init_lc_cache
14
13
  from chainlit.config import (
15
14
  BACKEND_ROOT,
@@ -25,18 +24,7 @@ from chainlit.logger import logger
25
24
  from chainlit.markdown import init_markdown
26
25
  from chainlit.secret import random_secret
27
26
  from chainlit.telemetry import trace_event
28
- from chainlit.utils import check_file
29
-
30
-
31
- def assert_app():
32
- if (
33
- not config.code.on_chat_start
34
- and not config.code.on_message
35
- and not config.code.on_audio_chunk
36
- ):
37
- raise Exception(
38
- "You need to configure at least one of on_chat_start, on_message or on_audio_chunk callback"
39
- )
27
+ from chainlit.utils import check_file, ensure_jwt_secret
40
28
 
41
29
 
42
30
  # Create the main command group for Chainlit CLI
@@ -78,7 +66,6 @@ def run_chainlit(target: str):
78
66
  load_module(config.run.module_name)
79
67
 
80
68
  ensure_jwt_secret()
81
- assert_app()
82
69
 
83
70
  # Create the chainlit.md file if it doesn't exist
84
71
  init_markdown(config.root)
@@ -199,7 +186,7 @@ def chainlit_run(
199
186
  # This is required to have OpenAI LLM providers available for the CI run
200
187
  os.environ["OPENAI_API_KEY"] = "sk-FAKE-OPENAI-API-KEY"
201
188
  # This is required for authentication tests
202
- os.environ["CHAINLIT_AUTH_SECRET"] = "SUPER_SECRET" # nosec B105
189
+ os.environ["CHAINLIT_AUTH_SECRET"] = "SUPER_SECRET"
203
190
  else:
204
191
  trace_event("chainlit run")
205
192