chainlit 2.0.0__tar.gz → 2.0.dev0__tar.gz

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 (125) hide show
  1. {chainlit-2.0.0 → chainlit-2.0.dev0}/PKG-INFO +39 -27
  2. {chainlit-2.0.0 → chainlit-2.0.dev0}/README.md +31 -11
  3. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/__init__.py +57 -56
  4. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/action.py +10 -12
  5. chainlit-2.0.0/chainlit/auth/__init__.py → chainlit-2.0.dev0/chainlit/auth.py +34 -26
  6. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/cache.py +6 -4
  7. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/callbacks.py +7 -52
  8. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/chat_context.py +2 -2
  9. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/chat_settings.py +1 -3
  10. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/cli/__init__.py +2 -15
  11. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/config.py +70 -41
  12. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/context.py +9 -8
  13. chainlit-2.0.dev0/chainlit/copilot/dist/index.js +4541 -0
  14. chainlit-2.0.dev0/chainlit/data/__init__.py +25 -0
  15. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/data/acl.py +2 -3
  16. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/data/base.py +15 -1
  17. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/data/dynamodb.py +4 -7
  18. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/data/literalai.py +6 -4
  19. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/data/sql_alchemy.py +9 -10
  20. chainlit-2.0.0/chainlit/data/storage_clients/azure.py → chainlit-2.0.dev0/chainlit/data/storage_clients.py +33 -2
  21. chainlit-2.0.dev0/chainlit/discord/__init__.py +6 -0
  22. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/discord/app.py +1 -2
  23. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/element.py +9 -41
  24. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/emitter.py +21 -17
  25. chainlit-2.0.dev0/chainlit/frontend/dist/assets/DailyMotion-b4b7af47.js +1 -0
  26. chainlit-2.0.dev0/chainlit/frontend/dist/assets/Facebook-572972a0.js +1 -0
  27. chainlit-2.0.dev0/chainlit/frontend/dist/assets/FilePlayer-85c69ca8.js +1 -0
  28. chainlit-2.0.dev0/chainlit/frontend/dist/assets/Kaltura-dfc24672.js +1 -0
  29. chainlit-2.0.dev0/chainlit/frontend/dist/assets/Mixcloud-705011f4.js +1 -0
  30. chainlit-2.0.dev0/chainlit/frontend/dist/assets/Mux-4201a9e6.js +1 -0
  31. chainlit-2.0.dev0/chainlit/frontend/dist/assets/Preview-23ba40a6.js +1 -0
  32. chainlit-2.0.dev0/chainlit/frontend/dist/assets/SoundCloud-1a582d51.js +1 -0
  33. chainlit-2.0.dev0/chainlit/frontend/dist/assets/Streamable-5017c4ba.js +1 -0
  34. chainlit-2.0.dev0/chainlit/frontend/dist/assets/Twitch-bb2de2fa.js +1 -0
  35. chainlit-2.0.dev0/chainlit/frontend/dist/assets/Vidyard-54e269b1.js +1 -0
  36. chainlit-2.0.dev0/chainlit/frontend/dist/assets/Vimeo-d92c37dd.js +1 -0
  37. chainlit-2.0.dev0/chainlit/frontend/dist/assets/Wistia-25a1363b.js +1 -0
  38. chainlit-2.0.dev0/chainlit/frontend/dist/assets/YouTube-616e8cb7.js +1 -0
  39. chainlit-2.0.dev0/chainlit/frontend/dist/assets/index-aaf974a9.css +1 -0
  40. chainlit-2.0.dev0/chainlit/frontend/dist/assets/index-f5df2072.js +1027 -0
  41. chainlit-2.0.0/chainlit/frontend/dist/assets/react-plotly-BpxUS-ab.js → chainlit-2.0.dev0/chainlit/frontend/dist/assets/react-plotly-f0315f86.js +94 -94
  42. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/frontend/dist/index.html +3 -2
  43. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/haystack/callbacks.py +4 -5
  44. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/input_widget.py +4 -6
  45. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/langchain/callbacks.py +47 -56
  46. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/langflow/__init__.py +0 -1
  47. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/llama_index/callbacks.py +7 -7
  48. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/message.py +10 -8
  49. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/mistralai/__init__.py +2 -3
  50. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/oauth_providers.py +12 -113
  51. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/openai/__init__.py +7 -6
  52. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/secret.py +1 -1
  53. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/server.py +181 -491
  54. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/session.py +5 -7
  55. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/slack/__init__.py +3 -3
  56. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/slack/app.py +2 -3
  57. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/socket.py +103 -78
  58. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/step.py +29 -21
  59. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/sync.py +1 -2
  60. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/teams/__init__.py +3 -3
  61. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/teams/app.py +0 -1
  62. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/types.py +4 -20
  63. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/user.py +1 -2
  64. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/utils.py +2 -3
  65. chainlit-2.0.dev0/chainlit/version.py +7 -0
  66. {chainlit-2.0.0 → chainlit-2.0.dev0}/pyproject.toml +15 -35
  67. chainlit-2.0.0/chainlit/auth/cookie.py +0 -123
  68. chainlit-2.0.0/chainlit/auth/jwt.py +0 -37
  69. chainlit-2.0.0/chainlit/copilot/dist/index.js +0 -12200
  70. chainlit-2.0.0/chainlit/data/__init__.py +0 -113
  71. chainlit-2.0.0/chainlit/data/chainlit_data_layer.py +0 -584
  72. chainlit-2.0.0/chainlit/data/storage_clients/__init__.py +0 -0
  73. chainlit-2.0.0/chainlit/data/storage_clients/azure_blob.py +0 -80
  74. chainlit-2.0.0/chainlit/data/storage_clients/base.py +0 -22
  75. chainlit-2.0.0/chainlit/data/storage_clients/gcs.py +0 -78
  76. chainlit-2.0.0/chainlit/data/storage_clients/s3.py +0 -49
  77. chainlit-2.0.0/chainlit/discord/__init__.py +0 -6
  78. chainlit-2.0.0/chainlit/frontend/dist/assets/DailyMotion-DgRzV5GZ.js +0 -1
  79. chainlit-2.0.0/chainlit/frontend/dist/assets/Dataframe-DVgwSMU2.js +0 -22
  80. chainlit-2.0.0/chainlit/frontend/dist/assets/Facebook-C0vx6HWv.js +0 -1
  81. chainlit-2.0.0/chainlit/frontend/dist/assets/FilePlayer-CdhzeHPP.js +0 -1
  82. chainlit-2.0.0/chainlit/frontend/dist/assets/Kaltura-5iVmeUct.js +0 -1
  83. chainlit-2.0.0/chainlit/frontend/dist/assets/Mixcloud-C2zi77Ex.js +0 -1
  84. chainlit-2.0.0/chainlit/frontend/dist/assets/Mux-Vkebogdf.js +0 -1
  85. chainlit-2.0.0/chainlit/frontend/dist/assets/Preview-DwY_sEIl.js +0 -1
  86. chainlit-2.0.0/chainlit/frontend/dist/assets/SoundCloud-CREBXAWo.js +0 -1
  87. chainlit-2.0.0/chainlit/frontend/dist/assets/Streamable-B5Lu25uy.js +0 -1
  88. chainlit-2.0.0/chainlit/frontend/dist/assets/Twitch-y9iKCcM1.js +0 -1
  89. chainlit-2.0.0/chainlit/frontend/dist/assets/Vidyard-ClYvcuEu.js +0 -1
  90. chainlit-2.0.0/chainlit/frontend/dist/assets/Vimeo-D6HvM2jt.js +0 -1
  91. chainlit-2.0.0/chainlit/frontend/dist/assets/Wistia-Cu4zZ2Ci.js +0 -1
  92. chainlit-2.0.0/chainlit/frontend/dist/assets/YouTube-D10tR6CJ.js +0 -1
  93. chainlit-2.0.0/chainlit/frontend/dist/assets/index-CI4qFOt5.js +0 -8665
  94. chainlit-2.0.0/chainlit/frontend/dist/assets/index-CrrqM0nZ.css +0 -1
  95. chainlit-2.0.0/chainlit/translations/nl-NL.json +0 -229
  96. chainlit-2.0.0/chainlit/version.py +0 -8
  97. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/__main__.py +0 -0
  98. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/_utils.py +0 -0
  99. /chainlit-2.0.0/chainlit/copilot/dist/assets/logo_dark-IkGJ_IwC.svg → /chainlit-2.0.dev0/chainlit/copilot/dist/assets/logo_dark-2a3cf740.svg +0 -0
  100. /chainlit-2.0.0/chainlit/copilot/dist/assets/logo_light-Bb_IPh6r.svg → /chainlit-2.0.dev0/chainlit/copilot/dist/assets/logo_light-b078e7bc.svg +0 -0
  101. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/data/utils.py +0 -0
  102. /chainlit-2.0.0/chainlit/frontend/dist/assets/logo_dark-IkGJ_IwC.svg → /chainlit-2.0.dev0/chainlit/frontend/dist/assets/logo_dark-2a3cf740.svg +0 -0
  103. /chainlit-2.0.0/chainlit/frontend/dist/assets/logo_light-Bb_IPh6r.svg → /chainlit-2.0.dev0/chainlit/frontend/dist/assets/logo_light-b078e7bc.svg +0 -0
  104. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/frontend/dist/favicon.svg +0 -0
  105. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/haystack/__init__.py +0 -0
  106. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/hello.py +0 -0
  107. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/langchain/__init__.py +0 -0
  108. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/llama_index/__init__.py +0 -0
  109. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/logger.py +0 -0
  110. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/markdown.py +0 -0
  111. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/py.typed +0 -0
  112. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/telemetry.py +0 -0
  113. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/translations/bn.json +0 -0
  114. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/translations/en-US.json +0 -0
  115. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/translations/gu.json +0 -0
  116. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/translations/he-IL.json +0 -0
  117. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/translations/hi.json +0 -0
  118. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/translations/kn.json +0 -0
  119. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/translations/ml.json +0 -0
  120. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/translations/mr.json +0 -0
  121. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/translations/ta.json +0 -0
  122. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/translations/te.json +0 -0
  123. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/translations/zh-CN.json +0 -0
  124. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/translations.py +0 -0
  125. {chainlit-2.0.0 → chainlit-2.0.dev0}/chainlit/user_session.py +0 -0
@@ -1,30 +1,23 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: chainlit
3
- Version: 2.0.0
3
+ Version: 2.0.dev0
4
4
  Summary: Build Conversational AI.
5
- Home-page: https://chainlit.io/
6
- License: Apache-2.0
5
+ Home-page: https://github.com/Chainlit/chainlit
6
+ License: Apache-2.0 license
7
7
  Keywords: LLM,Agents,gen ai,chat ui,chatbot ui,openai,copilot,langchain,conversational ai
8
- Author: Willy Douhard
8
+ Author: Chainlit
9
9
  Requires-Python: >=3.9,<4.0.0
10
- Classifier: Environment :: Web Environment
11
- Classifier: Framework :: FastAPI
12
- Classifier: License :: OSI Approved :: Apache Software License
13
- Classifier: Programming Language :: JavaScript
10
+ Classifier: License :: Other/Proprietary License
14
11
  Classifier: Programming Language :: Python :: 3
15
12
  Classifier: Programming Language :: Python :: 3.9
16
13
  Classifier: Programming Language :: Python :: 3.10
17
14
  Classifier: Programming Language :: Python :: 3.11
18
15
  Classifier: Programming Language :: Python :: 3.12
19
- Classifier: Topic :: Communications :: Chat
20
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
- Classifier: Topic :: Software Development :: User Interfaces
23
16
  Requires-Dist: aiofiles (>=23.1.0,<24.0.0)
24
17
  Requires-Dist: asyncer (>=0.0.7,<0.0.8)
25
18
  Requires-Dist: click (>=8.1.3,<9.0.0)
26
19
  Requires-Dist: dataclasses_json (>=0.6.7,<0.7.0)
27
- Requires-Dist: fastapi (>=0.115.3,<0.116)
20
+ Requires-Dist: fastapi (>=0.110.1,<0.113)
28
21
  Requires-Dist: filetype (>=1.2.0,<2.0.0)
29
22
  Requires-Dist: httpx (>=0.23.0)
30
23
  Requires-Dist: lazify (>=0.4.0,<0.5.0)
@@ -35,15 +28,14 @@ Requires-Dist: packaging (>=23.1,<24.0)
35
28
  Requires-Dist: pydantic (>=1,<3)
36
29
  Requires-Dist: pyjwt (>=2.8.0,<3.0.0)
37
30
  Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
38
- Requires-Dist: python-multipart (>=0.0.18,<0.0.19)
31
+ Requires-Dist: python-multipart (>=0.0.9,<0.0.10)
39
32
  Requires-Dist: python-socketio (>=5.11.0,<6.0.0)
40
- Requires-Dist: starlette (>=0.41.2,<0.42.0)
33
+ Requires-Dist: starlette (>=0.37.2,<0.38.0)
41
34
  Requires-Dist: syncer (>=2.0.3,<3.0.0)
42
35
  Requires-Dist: tomli (>=2.0.1,<3.0.0)
43
36
  Requires-Dist: uptrace (>=1.22.0,<2.0.0)
44
37
  Requires-Dist: uvicorn (>=0.25.0,<0.26.0)
45
38
  Requires-Dist: watchfiles (>=0.20.0,<0.21.0)
46
- Project-URL: Documentation, https://docs.chainlit.io/
47
39
  Project-URL: Repository, https://github.com/Chainlit/chainlit
48
40
  Description-Content-Type: text/markdown
49
41
 
@@ -59,10 +51,22 @@ Description-Content-Type: text/markdown
59
51
 
60
52
  Chainlit is an open-source async Python framework which allows developers to build scalable Conversational AI or agentic applications.
61
53
 
54
+ - ✅ ChatGPT-like application
55
+ - ✅ Embedded Chatbot & Software Copilot
56
+ - ✅ Slack & Discord
57
+ - ✅ Custom frontend (build your own agentic experience)
58
+ - ✅ API Endpoint
59
+
62
60
  Full documentation is available [here](https://docs.chainlit.io). You can ask Chainlit related questions to [Chainlit Help](https://help.chainlit.io/), an app built using Chainlit!
63
61
 
64
- https://github.com/user-attachments/assets/b3738aba-55c0-42fa-ac00-6efd1ee0d148
62
+ > [!NOTE]
63
+ > Check out [Literal AI](https://literalai.com), our product to monitor and evaluate LLM applications! It works with any Python or TypeScript applications and [seamlessly](https://docs.chainlit.io/data-persistence/overview) with Chainlit by adding a `LITERAL_API_KEY` in your project.
64
+ >
65
+ > Chainlit is developed and maintained by the Literal AI team, which is currently focused on expanding the capabilities of Literal AI. While we continue to support and maintain Chainlit, we are also committed to enabling the community to contribute, particularly in areas like integrations and data layers.
65
66
 
67
+ <p align="center">
68
+ <img src="https://github.com/Chainlit/chainlit/assets/13104895/0c2cc7a9-766c-41d3-aae2-117a2d0eb8ed" alt="Chainlit user interface" width="80%"></img>
69
+ </p>
66
70
 
67
71
  ## Installation
68
72
 
@@ -75,16 +79,6 @@ chainlit hello
75
79
 
76
80
  If this opens the `hello app` in your browser, you're all set!
77
81
 
78
- ### Development version
79
-
80
- The latest in-development version can be installed straight from GitHub with:
81
-
82
- ```sh
83
- pip install git+https://github.com/Chainlit/chainlit.git#subdirectory=backend/
84
- ```
85
-
86
- (Requires Node and pnpm installed on the system.)
87
-
88
82
  ## 🚀 Quickstart
89
83
 
90
84
  ### 🐍 Pure Python
@@ -130,6 +124,24 @@ chainlit run demo.py -w
130
124
 
131
125
  <img src="/images/quick-start.png" alt="Quick Start"></img>
132
126
 
127
+ ## 🎉 Key Features and Integrations
128
+
129
+ Full documentation is available [here](https://docs.chainlit.io). Key features:
130
+
131
+ - [💬 Multi Modal chats](https://docs.chainlit.io/advanced-features/multi-modal)
132
+ - [💭 Chain of Thought visualization](https://docs.chainlit.io/concepts/step)
133
+ - [💾 Data persistence + human feedback](https://docs.chainlit.io/data-persistence/overview)
134
+ - [🐛 Debug Mode](https://docs.chainlit.io/data-persistence/enterprise#debug-mode)
135
+ - [👤 Authentication](https://docs.chainlit.io/authentication/overview)
136
+
137
+ Chainlit is compatible with all Python programs and libraries. That being said, it comes with integrations for:
138
+
139
+ - [LangChain](https://docs.chainlit.io/integrations/langchain)
140
+ - [Llama Index](https://docs.chainlit.io/integrations/llama-index)
141
+ - [Autogen](https://github.com/Chainlit/cookbook/tree/main/pyautogen)
142
+ - [OpenAI Assistant](https://github.com/Chainlit/cookbook/tree/main/openai-assistant)
143
+ - [Haystack](https://docs.chainlit.io/integrations/haystack)
144
+
133
145
  ## 📚 More Examples - Cookbook
134
146
 
135
147
  You can find various examples of Chainlit apps [here](https://github.com/Chainlit/cookbook) that leverage tools and services such as OpenAI, Anthropiс, LangChain, LlamaIndex, ChromaDB, Pinecone and more.
@@ -10,10 +10,22 @@
10
10
 
11
11
  Chainlit is an open-source async Python framework which allows developers to build scalable Conversational AI or agentic applications.
12
12
 
13
+ - ✅ ChatGPT-like application
14
+ - ✅ Embedded Chatbot & Software Copilot
15
+ - ✅ Slack & Discord
16
+ - ✅ Custom frontend (build your own agentic experience)
17
+ - ✅ API Endpoint
18
+
13
19
  Full documentation is available [here](https://docs.chainlit.io). You can ask Chainlit related questions to [Chainlit Help](https://help.chainlit.io/), an app built using Chainlit!
14
20
 
15
- https://github.com/user-attachments/assets/b3738aba-55c0-42fa-ac00-6efd1ee0d148
21
+ > [!NOTE]
22
+ > Check out [Literal AI](https://literalai.com), our product to monitor and evaluate LLM applications! It works with any Python or TypeScript applications and [seamlessly](https://docs.chainlit.io/data-persistence/overview) with Chainlit by adding a `LITERAL_API_KEY` in your project.
23
+ >
24
+ > Chainlit is developed and maintained by the Literal AI team, which is currently focused on expanding the capabilities of Literal AI. While we continue to support and maintain Chainlit, we are also committed to enabling the community to contribute, particularly in areas like integrations and data layers.
16
25
 
26
+ <p align="center">
27
+ <img src="https://github.com/Chainlit/chainlit/assets/13104895/0c2cc7a9-766c-41d3-aae2-117a2d0eb8ed" alt="Chainlit user interface" width="80%"></img>
28
+ </p>
17
29
 
18
30
  ## Installation
19
31
 
@@ -26,16 +38,6 @@ chainlit hello
26
38
 
27
39
  If this opens the `hello app` in your browser, you're all set!
28
40
 
29
- ### Development version
30
-
31
- The latest in-development version can be installed straight from GitHub with:
32
-
33
- ```sh
34
- pip install git+https://github.com/Chainlit/chainlit.git#subdirectory=backend/
35
- ```
36
-
37
- (Requires Node and pnpm installed on the system.)
38
-
39
41
  ## 🚀 Quickstart
40
42
 
41
43
  ### 🐍 Pure Python
@@ -81,6 +83,24 @@ chainlit run demo.py -w
81
83
 
82
84
  <img src="/images/quick-start.png" alt="Quick Start"></img>
83
85
 
86
+ ## 🎉 Key Features and Integrations
87
+
88
+ Full documentation is available [here](https://docs.chainlit.io). Key features:
89
+
90
+ - [💬 Multi Modal chats](https://docs.chainlit.io/advanced-features/multi-modal)
91
+ - [💭 Chain of Thought visualization](https://docs.chainlit.io/concepts/step)
92
+ - [💾 Data persistence + human feedback](https://docs.chainlit.io/data-persistence/overview)
93
+ - [🐛 Debug Mode](https://docs.chainlit.io/data-persistence/enterprise#debug-mode)
94
+ - [👤 Authentication](https://docs.chainlit.io/authentication/overview)
95
+
96
+ Chainlit is compatible with all Python programs and libraries. That being said, it comes with integrations for:
97
+
98
+ - [LangChain](https://docs.chainlit.io/integrations/langchain)
99
+ - [Llama Index](https://docs.chainlit.io/integrations/llama-index)
100
+ - [Autogen](https://github.com/Chainlit/cookbook/tree/main/pyautogen)
101
+ - [OpenAI Assistant](https://github.com/Chainlit/cookbook/tree/main/openai-assistant)
102
+ - [Haystack](https://docs.chainlit.io/integrations/haystack)
103
+
84
104
  ## 📚 More Examples - Cookbook
85
105
 
86
106
  You can find various examples of Chainlit apps [here](https://github.com/Chainlit/cookbook) that leverage tools and services such as OpenAI, Anthropiс, LangChain, LlamaIndex, ChromaDB, Pinecone and more.
@@ -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
 
@@ -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"]
@@ -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
 
@@ -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
@@ -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:
@@ -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