chainlit 1.1.300__py3-none-any.whl → 1.1.300rc1__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 (47) hide show
  1. chainlit/__init__.py +1 -3
  2. chainlit/cli/__init__.py +6 -53
  3. chainlit/cli/utils.py +24 -0
  4. chainlit/config.py +0 -4
  5. chainlit/context.py +0 -9
  6. chainlit/copilot/dist/index.js +201 -201
  7. chainlit/data/__init__.py +3 -6
  8. chainlit/data/sql_alchemy.py +3 -3
  9. chainlit/element.py +9 -33
  10. chainlit/emitter.py +7 -8
  11. chainlit/frontend/dist/assets/{DailyMotion-578b63e6.js → DailyMotion-acaf0251.js} +1 -1
  12. chainlit/frontend/dist/assets/{Facebook-b825e5bb.js → Facebook-7e85d6cd.js} +1 -1
  13. chainlit/frontend/dist/assets/{FilePlayer-bcba3b4e.js → FilePlayer-548ab948.js} +1 -1
  14. chainlit/frontend/dist/assets/{Kaltura-fc1c9497.js → Kaltura-63c33135.js} +1 -1
  15. chainlit/frontend/dist/assets/{Mixcloud-4cfb2724.js → Mixcloud-553956db.js} +1 -1
  16. chainlit/frontend/dist/assets/{Mux-aa92055c.js → Mux-823ded93.js} +1 -1
  17. chainlit/frontend/dist/assets/{Preview-9f55905a.js → Preview-47f5b210.js} +1 -1
  18. chainlit/frontend/dist/assets/{SoundCloud-f991fe03.js → SoundCloud-e5e98e65.js} +1 -1
  19. chainlit/frontend/dist/assets/{Streamable-53128f49.js → Streamable-14812f3b.js} +1 -1
  20. chainlit/frontend/dist/assets/{Twitch-fce8b9f5.js → Twitch-3e4a9570.js} +1 -1
  21. chainlit/frontend/dist/assets/{Vidyard-e35c6102.js → Vidyard-63580b33.js} +1 -1
  22. chainlit/frontend/dist/assets/{Vimeo-fff35f8e.js → Vimeo-1c2b5c4c.js} +1 -1
  23. chainlit/frontend/dist/assets/{Wistia-ec07dc64.js → Wistia-3dc1d7c3.js} +1 -1
  24. chainlit/frontend/dist/assets/{YouTube-ad068e2a.js → YouTube-d92466dc.js} +1 -1
  25. chainlit/frontend/dist/assets/{index-aaf974a9.css → index-53c62926.css} +1 -1
  26. chainlit/frontend/dist/assets/index-89bf1895.js +727 -0
  27. chainlit/frontend/dist/assets/{react-plotly-b2c6442b.js → react-plotly-691f8eab.js} +1 -1
  28. chainlit/frontend/dist/index.html +3 -2
  29. chainlit/message.py +8 -13
  30. chainlit/oauth_providers.py +0 -118
  31. chainlit/server.py +57 -182
  32. chainlit/slack/app.py +2 -2
  33. chainlit/socket.py +20 -26
  34. chainlit/step.py +9 -24
  35. chainlit/translations/en-US.json +1 -1
  36. chainlit/types.py +17 -7
  37. chainlit/user.py +1 -9
  38. chainlit/utils.py +0 -43
  39. {chainlit-1.1.300.dist-info → chainlit-1.1.300rc1.dist-info}/METADATA +3 -3
  40. chainlit-1.1.300rc1.dist-info/RECORD +77 -0
  41. chainlit/data/dynamodb.py +0 -586
  42. chainlit/frontend/dist/assets/index-d40d41cc.js +0 -727
  43. chainlit/teams/__init__.py +0 -6
  44. chainlit/teams/app.py +0 -332
  45. chainlit-1.1.300.dist-info/RECORD +0 -79
  46. {chainlit-1.1.300.dist-info → chainlit-1.1.300rc1.dist-info}/WHEEL +0 -0
  47. {chainlit-1.1.300.dist-info → chainlit-1.1.300rc1.dist-info}/entry_points.txt +0 -0
chainlit/__init__.py CHANGED
@@ -28,7 +28,6 @@ from chainlit.config import config
28
28
  from chainlit.context import context
29
29
  from chainlit.element import (
30
30
  Audio,
31
- Component,
32
31
  File,
33
32
  Image,
34
33
  Pdf,
@@ -115,7 +114,7 @@ def oauth_callback(
115
114
 
116
115
  Example:
117
116
  @cl.oauth_callback
118
- async def oauth_callback(provider_id: str, token: str, raw_user_data: Dict[str, str], default_app_user: User, id_token: Optional[str]) -> Optional[User]:
117
+ async def oauth_callback(provider_id: str, token: str, raw_user_data: Dict[str, str], default_app_user: User) -> Optional[User]:
119
118
 
120
119
  Returns:
121
120
  Callable[[str, str, Dict[str, str], User], Optional[User]]: The decorated authentication callback.
@@ -377,7 +376,6 @@ __all__ = [
377
376
  "Plotly",
378
377
  "Image",
379
378
  "Text",
380
- "Component",
381
379
  "Pyplot",
382
380
  "File",
383
381
  "Task",
chainlit/cli/__init__.py CHANGED
@@ -7,12 +7,13 @@ import uvicorn
7
7
 
8
8
  nest_asyncio.apply()
9
9
 
10
+ from chainlit.auth import ensure_jwt_secret
10
11
  from chainlit.cache import init_lc_cache
12
+ from chainlit.cli.utils import check_file
11
13
  from chainlit.config import (
12
14
  BACKEND_ROOT,
13
15
  DEFAULT_HOST,
14
16
  DEFAULT_PORT,
15
- DEFAULT_ROOT_PATH,
16
17
  config,
17
18
  init_config,
18
19
  lint_translations,
@@ -21,8 +22,8 @@ from chainlit.config import (
21
22
  from chainlit.logger import logger
22
23
  from chainlit.markdown import init_markdown
23
24
  from chainlit.secret import random_secret
25
+ from chainlit.server import app, register_wildcard_route_handler
24
26
  from chainlit.telemetry import trace_event
25
- from chainlit.utils import check_file, ensure_jwt_secret
26
27
 
27
28
 
28
29
  # Create the main command group for Chainlit CLI
@@ -34,14 +35,8 @@ def cli():
34
35
 
35
36
  # Define the function to run Chainlit with provided options
36
37
  def run_chainlit(target: str):
37
- from chainlit.server import combined_asgi_app as app
38
-
39
38
  host = os.environ.get("CHAINLIT_HOST", DEFAULT_HOST)
40
39
  port = int(os.environ.get("CHAINLIT_PORT", DEFAULT_PORT))
41
- root_path = os.environ.get("CHAINLIT_ROOT_PATH", DEFAULT_ROOT_PATH)
42
-
43
- ssl_certfile = os.environ.get("CHAINLIT_SSL_CERT", None)
44
- ssl_keyfile = os.environ.get("CHAINLIT_SSL_KEY", None)
45
40
 
46
41
  ws_per_message_deflate_env = os.environ.get(
47
42
  "UVICORN_WS_PER_MESSAGE_DEFLATE", "true"
@@ -52,13 +47,8 @@ def run_chainlit(target: str):
52
47
  "yes",
53
48
  ] # Convert to boolean
54
49
 
55
- ws_protocol = os.environ.get(
56
- "UVICORN_WS_PROTOCOL", "auto"
57
- )
58
-
59
50
  config.run.host = host
60
51
  config.run.port = port
61
- config.run.root_path = root_path
62
52
 
63
53
  check_file(target)
64
54
  # Load the module provided by the user
@@ -67,6 +57,8 @@ def run_chainlit(target: str):
67
57
 
68
58
  ensure_jwt_secret()
69
59
 
60
+ register_wildcard_route_handler()
61
+
70
62
  # Create the chainlit.md file if it doesn't exist
71
63
  init_markdown(config.root)
72
64
 
@@ -81,11 +73,8 @@ def run_chainlit(target: str):
81
73
  app,
82
74
  host=host,
83
75
  port=port,
84
- ws=ws_protocol,
85
76
  log_level=log_level,
86
77
  ws_per_message_deflate=ws_per_message_deflate,
87
- ssl_keyfile=ssl_keyfile,
88
- ssl_certfile=ssl_certfile,
89
78
  )
90
79
  server = uvicorn.Server(config)
91
80
  await server.serve()
@@ -137,47 +126,13 @@ def run_chainlit(target: str):
137
126
  envvar="NO_CACHE",
138
127
  help="Useful to disable third parties cache, such as langchain.",
139
128
  )
140
- @click.option(
141
- "--ssl-cert",
142
- default=None,
143
- envvar="CHAINLIT_SSL_CERT",
144
- help="Specify the file path for the SSL certificate.",
145
- )
146
- @click.option(
147
- "--ssl-key",
148
- default=None,
149
- envvar="CHAINLIT_SSL_KEY",
150
- help="Specify the file path for the SSL key",
151
- )
152
129
  @click.option("--host", help="Specify a different host to run the server on")
153
130
  @click.option("--port", help="Specify a different port to run the server on")
154
- @click.option("--root-path", help="Specify a different root path to run the server on")
155
- def chainlit_run(
156
- target,
157
- watch,
158
- headless,
159
- debug,
160
- ci,
161
- no_cache,
162
- ssl_cert,
163
- ssl_key,
164
- host,
165
- port,
166
- root_path,
167
- ):
131
+ def chainlit_run(target, watch, headless, debug, ci, no_cache, host, port):
168
132
  if host:
169
133
  os.environ["CHAINLIT_HOST"] = host
170
134
  if port:
171
135
  os.environ["CHAINLIT_PORT"] = port
172
- if bool(ssl_cert) != bool(ssl_key):
173
- raise click.UsageError(
174
- "Both --ssl-cert and --ssl-key must be provided together."
175
- )
176
- if ssl_cert:
177
- os.environ["CHAINLIT_SSL_CERT"] = ssl_cert
178
- os.environ["CHAINLIT_SSL_KEY"] = ssl_key
179
- if root_path:
180
- os.environ["CHAINLIT_ROOT_PATH"] = root_path
181
136
  if ci:
182
137
  logger.info("Running in CI mode")
183
138
 
@@ -195,8 +150,6 @@ def chainlit_run(
195
150
  config.run.no_cache = no_cache
196
151
  config.run.ci = ci
197
152
  config.run.watch = watch
198
- config.run.ssl_cert = ssl_cert
199
- config.run.ssl_key = ssl_key
200
153
 
201
154
  run_chainlit(target)
202
155
 
chainlit/cli/utils.py ADDED
@@ -0,0 +1,24 @@
1
+ import os
2
+
3
+ import click
4
+
5
+
6
+ def check_file(target: str):
7
+ # Define accepted file extensions for Chainlit
8
+ ACCEPTED_FILE_EXTENSIONS = ("py", "py3")
9
+
10
+ _, extension = os.path.splitext(target)
11
+
12
+ # Check file extension
13
+ if extension[1:] not in ACCEPTED_FILE_EXTENSIONS:
14
+ if extension[1:] == "":
15
+ raise click.BadArgumentUsage(
16
+ "Chainlit requires raw Python (.py) files, but the provided file has no extension."
17
+ )
18
+ else:
19
+ raise click.BadArgumentUsage(
20
+ f"Chainlit requires raw Python (.py) files, not {extension}."
21
+ )
22
+
23
+ if not os.path.exists(target):
24
+ raise click.BadParameter(f"File does not exist: {target}")
chainlit/config.py CHANGED
@@ -163,7 +163,6 @@ generated_by = "{__version__}"
163
163
 
164
164
  DEFAULT_HOST = "0.0.0.0"
165
165
  DEFAULT_PORT = 8000
166
- DEFAULT_ROOT_PATH = ""
167
166
 
168
167
 
169
168
  @dataclass()
@@ -172,9 +171,6 @@ class RunSettings:
172
171
  module_name: Optional[str] = None
173
172
  host: str = DEFAULT_HOST
174
173
  port: int = DEFAULT_PORT
175
- ssl_cert: Optional[str] = None
176
- ssl_key: Optional[str] = None
177
- root_path: str = DEFAULT_ROOT_PATH
178
174
  headless: bool = False
179
175
  watch: bool = False
180
176
  no_cache: bool = False
chainlit/context.py CHANGED
@@ -69,8 +69,6 @@ def init_http_context(
69
69
  user_env: Optional[Dict[str, str]] = None,
70
70
  client_type: ClientType = "webapp",
71
71
  ) -> ChainlitContext:
72
- from chainlit.data import get_data_layer
73
-
74
72
  session_id = str(uuid.uuid4())
75
73
  thread_id = thread_id or str(uuid.uuid4())
76
74
  session = HTTPSession(
@@ -83,13 +81,6 @@ def init_http_context(
83
81
  )
84
82
  context = ChainlitContext(session)
85
83
  context_var.set(context)
86
-
87
- if data_layer := get_data_layer():
88
- if user_id := getattr(user, "id", None):
89
- asyncio.create_task(
90
- data_layer.update_thread(thread_id=thread_id, user_id=user_id)
91
- )
92
-
93
84
  return context
94
85
 
95
86