chainlit 2.0.dev0__py3-none-any.whl → 2.0.dev2__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 (66) hide show
  1. chainlit/__init__.py +1 -0
  2. chainlit/auth.py +9 -3
  3. chainlit/cache.py +2 -5
  4. chainlit/cli/__init__.py +1 -1
  5. chainlit/config.py +6 -1
  6. chainlit/context.py +6 -8
  7. chainlit/copilot/dist/index.js +459 -398
  8. chainlit/data/base.py +0 -14
  9. chainlit/data/dynamodb.py +2 -1
  10. chainlit/data/sql_alchemy.py +3 -3
  11. chainlit/data/storage_clients/__init__.py +0 -0
  12. chainlit/data/{storage_clients.py → storage_clients/azure.py} +1 -33
  13. chainlit/data/storage_clients/base.py +16 -0
  14. chainlit/data/storage_clients/s3.py +36 -0
  15. chainlit/discord/__init__.py +4 -4
  16. chainlit/element.py +29 -1
  17. chainlit/frontend/dist/assets/DailyMotion-D1ipkdPJ.js +1 -0
  18. chainlit/frontend/dist/assets/Facebook-d4TLeTik.js +1 -0
  19. chainlit/frontend/dist/assets/FilePlayer-BcU7tttX.js +1 -0
  20. chainlit/frontend/dist/assets/Kaltura-DdaRjZrh.js +1 -0
  21. chainlit/frontend/dist/assets/Mixcloud-BaJoMsaU.js +1 -0
  22. chainlit/frontend/dist/assets/Mux-DxPCM5d3.js +1 -0
  23. chainlit/frontend/dist/assets/Preview-tUK_Z9pZ.js +1 -0
  24. chainlit/frontend/dist/assets/SoundCloud-K8-lFZC6.js +1 -0
  25. chainlit/frontend/dist/assets/Streamable-hB-AQ54w.js +1 -0
  26. chainlit/frontend/dist/assets/Twitch-pmuNY0J5.js +1 -0
  27. chainlit/frontend/dist/assets/Vidyard-BSUm6trV.js +1 -0
  28. chainlit/frontend/dist/assets/Vimeo-JIPn71zS.js +1 -0
  29. chainlit/frontend/dist/assets/Wistia-D75KkqOG.js +1 -0
  30. chainlit/frontend/dist/assets/YouTube-CPlwqNm_.js +1 -0
  31. chainlit/frontend/dist/assets/index-CuSbXjG5.js +1091 -0
  32. chainlit/frontend/dist/assets/{react-plotly-f0315f86.js → react-plotly-DALmanjC.js} +94 -94
  33. chainlit/frontend/dist/index.html +2 -3
  34. chainlit/message.py +2 -3
  35. chainlit/oauth_providers.py +43 -9
  36. chainlit/openai/__init__.py +3 -5
  37. chainlit/server.py +21 -10
  38. chainlit/slack/__init__.py +3 -3
  39. chainlit/step.py +10 -18
  40. chainlit/teams/__init__.py +3 -3
  41. chainlit/version.py +3 -2
  42. {chainlit-2.0.dev0.dist-info → chainlit-2.0.dev2.dist-info}/METADATA +25 -7
  43. chainlit-2.0.dev2.dist-info/RECORD +99 -0
  44. chainlit/frontend/dist/assets/DailyMotion-b4b7af47.js +0 -1
  45. chainlit/frontend/dist/assets/Facebook-572972a0.js +0 -1
  46. chainlit/frontend/dist/assets/FilePlayer-85c69ca8.js +0 -1
  47. chainlit/frontend/dist/assets/Kaltura-dfc24672.js +0 -1
  48. chainlit/frontend/dist/assets/Mixcloud-705011f4.js +0 -1
  49. chainlit/frontend/dist/assets/Mux-4201a9e6.js +0 -1
  50. chainlit/frontend/dist/assets/Preview-23ba40a6.js +0 -1
  51. chainlit/frontend/dist/assets/SoundCloud-1a582d51.js +0 -1
  52. chainlit/frontend/dist/assets/Streamable-5017c4ba.js +0 -1
  53. chainlit/frontend/dist/assets/Twitch-bb2de2fa.js +0 -1
  54. chainlit/frontend/dist/assets/Vidyard-54e269b1.js +0 -1
  55. chainlit/frontend/dist/assets/Vimeo-d92c37dd.js +0 -1
  56. chainlit/frontend/dist/assets/Wistia-25a1363b.js +0 -1
  57. chainlit/frontend/dist/assets/YouTube-616e8cb7.js +0 -1
  58. chainlit/frontend/dist/assets/index-f5df2072.js +0 -1027
  59. chainlit-2.0.dev0.dist-info/RECORD +0 -96
  60. /chainlit/copilot/dist/assets/{logo_dark-2a3cf740.svg → logo_dark-IkGJ_IwC.svg} +0 -0
  61. /chainlit/copilot/dist/assets/{logo_light-b078e7bc.svg → logo_light-Bb_IPh6r.svg} +0 -0
  62. /chainlit/frontend/dist/assets/{index-aaf974a9.css → index-CwmincdQ.css} +0 -0
  63. /chainlit/frontend/dist/assets/{logo_dark-2a3cf740.svg → logo_dark-IkGJ_IwC.svg} +0 -0
  64. /chainlit/frontend/dist/assets/{logo_light-b078e7bc.svg → logo_light-Bb_IPh6r.svg} +0 -0
  65. {chainlit-2.0.dev0.dist-info → chainlit-2.0.dev2.dist-info}/WHEEL +0 -0
  66. {chainlit-2.0.dev0.dist-info → chainlit-2.0.dev2.dist-info}/entry_points.txt +0 -0
chainlit/__init__.py CHANGED
@@ -23,6 +23,7 @@ from chainlit.context import context
23
23
  from chainlit.element import (
24
24
  Audio,
25
25
  Component,
26
+ Dataframe,
26
27
  File,
27
28
  Image,
28
29
  Pdf,
chainlit/auth.py CHANGED
@@ -52,7 +52,9 @@ def create_jwt(data: User) -> str:
52
52
  to_encode: Dict[str, Any] = data.to_dict()
53
53
  to_encode.update(
54
54
  {
55
- "exp": datetime.utcnow() + timedelta(minutes=60 * 24 * 15), # 15 days
55
+ "exp": datetime.utcnow() + timedelta(
56
+ seconds=config.project.user_session_timeout
57
+ ),
56
58
  }
57
59
  )
58
60
  encoded_jwt = jwt.encode(to_encode, get_jwt_secret(), algorithm="HS256")
@@ -69,8 +71,10 @@ async def authenticate_user(token: str = Depends(reuseable_oauth)):
69
71
  )
70
72
  del dict["exp"]
71
73
  user = User(**dict)
72
- except Exception:
73
- raise HTTPException(status_code=401, detail="Invalid authentication token")
74
+ except Exception as e:
75
+ raise HTTPException(
76
+ status_code=401, detail="Invalid authentication token"
77
+ ) from e
74
78
  if data_layer := get_data_layer():
75
79
  try:
76
80
  persisted_user = await data_layer.get_user(user.identifier)
@@ -79,6 +83,8 @@ async def authenticate_user(token: str = Depends(reuseable_oauth)):
79
83
  except Exception:
80
84
  return user
81
85
 
86
+ if user and user.display_name:
87
+ persisted_user.display_name = user.display_name
82
88
  return persisted_user
83
89
  else:
84
90
  return user
chainlit/cache.py CHANGED
@@ -1,3 +1,4 @@
1
+ import importlib.util
1
2
  import os
2
3
  import threading
3
4
 
@@ -8,11 +9,7 @@ from chainlit.logger import logger
8
9
  def init_lc_cache():
9
10
  use_cache = config.project.cache is True and config.run.no_cache is False
10
11
 
11
- if use_cache:
12
- try:
13
- import langchain
14
- except ImportError:
15
- return
12
+ if use_cache and importlib.util.find_spec("langchain") is not None:
16
13
  from langchain.cache import SQLiteCache
17
14
  from langchain.globals import set_llm_cache
18
15
 
chainlit/cli/__init__.py CHANGED
@@ -186,7 +186,7 @@ def chainlit_run(
186
186
  # This is required to have OpenAI LLM providers available for the CI run
187
187
  os.environ["OPENAI_API_KEY"] = "sk-FAKE-OPENAI-API-KEY"
188
188
  # This is required for authentication tests
189
- os.environ["CHAINLIT_AUTH_SECRET"] = "SUPER_SECRET"
189
+ os.environ["CHAINLIT_AUTH_SECRET"] = "SUPER_SECRET" # nosec B105
190
190
  else:
191
191
  trace_event("chainlit run")
192
192
 
chainlit/config.py CHANGED
@@ -62,6 +62,9 @@ user_env = []
62
62
  # Duration (in seconds) during which the session is saved when the connection is lost
63
63
  session_timeout = 3600
64
64
 
65
+ # Duration (in seconds) of the user session expiry
66
+ user_session_timeout = 1296000 # 15 days
67
+
65
68
  # Enable third parties caching (e.g LangChain cache)
66
69
  cache = false
67
70
 
@@ -306,6 +309,8 @@ class ProjectSettings(DataClassJsonMixin):
306
309
  # Path to the local chat db
307
310
  # Duration (in seconds) during which the session is saved when the connection is lost
308
311
  session_timeout: int = 3600
312
+ # Duration (in seconds) of the user session expiry
313
+ user_session_timeout: int = 1296000 # 15 days
309
314
  # Enable third parties caching (e.g LangChain cache)
310
315
  cache: bool = False
311
316
  # Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
@@ -447,7 +452,7 @@ def load_settings():
447
452
 
448
453
  if not meta or meta.get("generated_by") <= "0.3.0":
449
454
  raise ValueError(
450
- "Your config file is outdated. Please delete it and restart the app to regenerate it."
455
+ f"Your config file '{config_file}' is outdated. Please delete it and restart the app to regenerate it."
451
456
  )
452
457
 
453
458
  lc_cache_path = os.path.join(config_dir, ".langchain.db")
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 self.active_steps:
31
- return self.active_steps[-1]
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 self.active_steps:
34
+ if previous_steps := local_steps.get():
36
35
  return next(
37
- (step for step in self.active_steps if step.name in CL_RUN_NAMES), None
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
@@ -105,8 +103,8 @@ def init_http_context(
105
103
  def get_context() -> ChainlitContext:
106
104
  try:
107
105
  return context_var.get()
108
- except LookupError:
109
- raise ChainlitContextException()
106
+ except LookupError as e:
107
+ raise ChainlitContextException() from e
110
108
 
111
109
 
112
110
  context: ChainlitContext = LazyProxy(get_context, enable_cache=False)