chainlit 1.1.202__tar.gz → 1.1.300__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.
- {chainlit-1.1.202 → chainlit-1.1.300}/PKG-INFO +22 -14
- {chainlit-1.1.202 → chainlit-1.1.300}/README.md +17 -11
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/__init__.py +22 -4
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/cli/__init__.py +53 -6
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/config.py +25 -18
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/context.py +9 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/copilot/dist/index.js +443 -410
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/data/__init__.py +19 -5
- chainlit-1.1.300/chainlit/data/dynamodb.py +586 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/data/sql_alchemy.py +47 -28
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/discord/app.py +4 -2
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/element.py +36 -20
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/emitter.py +8 -7
- chainlit-1.1.202/chainlit/frontend/dist/assets/DailyMotion-53376209.js → chainlit-1.1.300/chainlit/frontend/dist/assets/DailyMotion-578b63e6.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/Facebook-aee41f5b.js → chainlit-1.1.300/chainlit/frontend/dist/assets/Facebook-b825e5bb.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/FilePlayer-b2cdb30f.js → chainlit-1.1.300/chainlit/frontend/dist/assets/FilePlayer-bcba3b4e.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/Kaltura-51db0377.js → chainlit-1.1.300/chainlit/frontend/dist/assets/Kaltura-fc1c9497.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/Mixcloud-cb900886.js → chainlit-1.1.300/chainlit/frontend/dist/assets/Mixcloud-4cfb2724.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/Mux-79ac59e6.js → chainlit-1.1.300/chainlit/frontend/dist/assets/Mux-aa92055c.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/Preview-cfe7584c.js → chainlit-1.1.300/chainlit/frontend/dist/assets/Preview-9f55905a.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/SoundCloud-a985707c.js → chainlit-1.1.300/chainlit/frontend/dist/assets/SoundCloud-f991fe03.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/Streamable-3d89aab5.js → chainlit-1.1.300/chainlit/frontend/dist/assets/Streamable-53128f49.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/Twitch-bf016588.js → chainlit-1.1.300/chainlit/frontend/dist/assets/Twitch-fce8b9f5.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/Vidyard-1891ecd7.js → chainlit-1.1.300/chainlit/frontend/dist/assets/Vidyard-e35c6102.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/Vimeo-0645662c.js → chainlit-1.1.300/chainlit/frontend/dist/assets/Vimeo-fff35f8e.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/Wistia-3b449fe2.js → chainlit-1.1.300/chainlit/frontend/dist/assets/Wistia-ec07dc64.js +1 -1
- chainlit-1.1.202/chainlit/frontend/dist/assets/YouTube-5ea2381e.js → chainlit-1.1.300/chainlit/frontend/dist/assets/YouTube-ad068e2a.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/index-aaf974a9.css +1 -0
- chainlit-1.1.300/chainlit/frontend/dist/assets/index-d40d41cc.js +727 -0
- chainlit-1.1.202/chainlit/frontend/dist/assets/react-plotly-2ff19c9f.js → chainlit-1.1.300/chainlit/frontend/dist/assets/react-plotly-b2c6442b.js +1 -1
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/frontend/dist/index.html +2 -3
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/langchain/callbacks.py +4 -2
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/llama_index/callbacks.py +2 -2
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/message.py +30 -25
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/oauth_providers.py +118 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/server.py +208 -83
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/slack/app.py +2 -3
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/socket.py +27 -23
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/step.py +44 -30
- chainlit-1.1.300/chainlit/teams/__init__.py +6 -0
- chainlit-1.1.300/chainlit/teams/app.py +332 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/translations/en-US.json +2 -4
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/types.py +17 -17
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/user.py +9 -1
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/utils.py +47 -3
- {chainlit-1.1.202 → chainlit-1.1.300}/pyproject.toml +30 -21
- chainlit-1.1.202/chainlit/cli/utils.py +0 -24
- chainlit-1.1.202/chainlit/frontend/dist/assets/index-a0c5a67e.js +0 -698
- chainlit-1.1.202/chainlit/frontend/dist/assets/index-d088547c.css +0 -1
- chainlit-1.1.202/chainlit/playground/__init__.py +0 -2
- chainlit-1.1.202/chainlit/playground/config.py +0 -36
- chainlit-1.1.202/chainlit/playground/provider.py +0 -108
- chainlit-1.1.202/chainlit/playground/providers/__init__.py +0 -11
- chainlit-1.1.202/chainlit/playground/providers/anthropic.py +0 -118
- chainlit-1.1.202/chainlit/playground/providers/huggingface.py +0 -75
- chainlit-1.1.202/chainlit/playground/providers/langchain.py +0 -89
- chainlit-1.1.202/chainlit/playground/providers/openai.py +0 -386
- chainlit-1.1.202/chainlit/playground/providers/vertexai.py +0 -171
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/__main__.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/action.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/auth.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/cache.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/chat_settings.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/copilot/dist/assets/logo_dark-2a3cf740.svg +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/copilot/dist/assets/logo_light-b078e7bc.svg +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/data/acl.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/data/storage_clients.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/discord/__init__.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/frontend/dist/assets/logo_dark-2a3cf740.svg +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/frontend/dist/assets/logo_light-b078e7bc.svg +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/frontend/dist/favicon.svg +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/haystack/__init__.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/haystack/callbacks.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/hello.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/input_widget.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/langchain/__init__.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/langflow/__init__.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/llama_index/__init__.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/logger.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/markdown.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/openai/__init__.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/py.typed +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/secret.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/session.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/slack/__init__.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/sync.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/telemetry.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/translations.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/user_session.py +0 -0
- {chainlit-1.1.202 → chainlit-1.1.300}/chainlit/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: chainlit
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.300
|
|
4
4
|
Summary: Build Conversational AI.
|
|
5
5
|
Home-page: https://github.com/Chainlit/chainlit
|
|
6
6
|
License: Apache-2.0 license
|
|
@@ -18,17 +18,19 @@ Requires-Dist: asyncer (>=0.0.2,<0.0.3)
|
|
|
18
18
|
Requires-Dist: click (>=8.1.3,<9.0.0)
|
|
19
19
|
Requires-Dist: dataclasses_json (>=0.5.7,<0.6.0)
|
|
20
20
|
Requires-Dist: fastapi (>=0.110.1,<0.111.0)
|
|
21
|
-
Requires-Dist: fastapi-socketio (>=0.0.10,<0.0.11)
|
|
22
21
|
Requires-Dist: filetype (>=1.2.0,<2.0.0)
|
|
23
22
|
Requires-Dist: httpx (>=0.23.0)
|
|
24
23
|
Requires-Dist: lazify (>=0.4.0,<0.5.0)
|
|
25
|
-
Requires-Dist: literalai (==0.0.
|
|
24
|
+
Requires-Dist: literalai (==0.0.604)
|
|
26
25
|
Requires-Dist: nest-asyncio (>=1.5.6,<2.0.0)
|
|
26
|
+
Requires-Dist: numpy (>=1.24.4,<2.0.0) ; python_version < "3.9"
|
|
27
|
+
Requires-Dist: numpy (>=1.26,<2.0) ; python_version >= "3.9"
|
|
27
28
|
Requires-Dist: packaging (>=23.1,<24.0)
|
|
28
29
|
Requires-Dist: pydantic (>=1,<3)
|
|
29
30
|
Requires-Dist: pyjwt (>=2.8.0,<3.0.0)
|
|
30
31
|
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
|
|
31
32
|
Requires-Dist: python-multipart (>=0.0.9,<0.0.10)
|
|
33
|
+
Requires-Dist: python-socketio (>=5.11.0,<6.0.0)
|
|
32
34
|
Requires-Dist: starlette (>=0.37.2,<0.38.0)
|
|
33
35
|
Requires-Dist: syncer (>=2.0.3,<3.0.0)
|
|
34
36
|
Requires-Dist: tomli (>=2.0.1,<3.0.0)
|
|
@@ -42,13 +44,12 @@ Description-Content-Type: text/markdown
|
|
|
42
44
|
|
|
43
45
|
[](https://discord.gg/k73SQ3FyUh)
|
|
44
46
|
[](https://twitter.com/chainlit_io)
|
|
47
|
+

|
|
48
|
+
[](https://github.com/chainlit/chainlit/graphs/contributors)
|
|
45
49
|
[](https://github.com/Chainlit/chainlit/actions/workflows/ci.yaml)
|
|
46
50
|
|
|
47
51
|
**Build production-ready Conversational AI applications in minutes, not weeks ⚡️**
|
|
48
52
|
|
|
49
|
-
> [!NOTE]
|
|
50
|
-
> You can ask Chainlit related questions to [Chainlit Help](https://help.chainlit.io/)! Also available on the Discord `@Chainlit Help`. Proudly built with Chainlit!
|
|
51
|
-
|
|
52
53
|
Chainlit is an open-source async Python framework which allows developers to build scalable Conversational AI or agentic applications.
|
|
53
54
|
|
|
54
55
|
- ✅ ChatGPT-like application
|
|
@@ -57,11 +58,15 @@ Chainlit is an open-source async Python framework which allows developers to bui
|
|
|
57
58
|
- ✅ Custom frontend (build your own agentic experience)
|
|
58
59
|
- ✅ API Endpoint
|
|
59
60
|
|
|
60
|
-
Full documentation is available [here](https://docs.chainlit.io).
|
|
61
|
+
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!
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
> [!NOTE]
|
|
64
|
+
> Contact us [here](https://forms.gle/BX3UNBLmTF75KgZVA) for **Enterprise Support**.
|
|
65
|
+
> 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.
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
<p align="center">
|
|
68
|
+
<img src="https://github.com/Chainlit/chainlit/assets/13104895/0c2cc7a9-766c-41d3-aae2-117a2d0eb8ed" width="80%" />
|
|
69
|
+
</p>
|
|
65
70
|
|
|
66
71
|
## Installation
|
|
67
72
|
|
|
@@ -84,8 +89,10 @@ Create a new file `demo.py` with the following code:
|
|
|
84
89
|
import chainlit as cl
|
|
85
90
|
|
|
86
91
|
|
|
87
|
-
@cl.step
|
|
88
|
-
def tool():
|
|
92
|
+
@cl.step(type="tool")
|
|
93
|
+
async def tool():
|
|
94
|
+
# Fake tool
|
|
95
|
+
await cl.sleep(2)
|
|
89
96
|
return "Response from the tool!"
|
|
90
97
|
|
|
91
98
|
|
|
@@ -102,11 +109,12 @@ async def main(message: cl.Message):
|
|
|
102
109
|
None.
|
|
103
110
|
"""
|
|
104
111
|
|
|
112
|
+
final_answer = await cl.Message(content="").send()
|
|
113
|
+
|
|
105
114
|
# Call the tool
|
|
106
|
-
tool()
|
|
115
|
+
final_answer.content = await tool()
|
|
107
116
|
|
|
108
|
-
|
|
109
|
-
await cl.Message(content="This is the final answer").send()
|
|
117
|
+
await final_answer.update()
|
|
110
118
|
```
|
|
111
119
|
|
|
112
120
|
Now run it!
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://discord.gg/k73SQ3FyUh)
|
|
4
4
|
[](https://twitter.com/chainlit_io)
|
|
5
|
+

|
|
6
|
+
[](https://github.com/chainlit/chainlit/graphs/contributors)
|
|
5
7
|
[](https://github.com/Chainlit/chainlit/actions/workflows/ci.yaml)
|
|
6
8
|
|
|
7
9
|
**Build production-ready Conversational AI applications in minutes, not weeks ⚡️**
|
|
8
10
|
|
|
9
|
-
> [!NOTE]
|
|
10
|
-
> You can ask Chainlit related questions to [Chainlit Help](https://help.chainlit.io/)! Also available on the Discord `@Chainlit Help`. Proudly built with Chainlit!
|
|
11
|
-
|
|
12
11
|
Chainlit is an open-source async Python framework which allows developers to build scalable Conversational AI or agentic applications.
|
|
13
12
|
|
|
14
13
|
- ✅ ChatGPT-like application
|
|
@@ -17,11 +16,15 @@ Chainlit is an open-source async Python framework which allows developers to bui
|
|
|
17
16
|
- ✅ Custom frontend (build your own agentic experience)
|
|
18
17
|
- ✅ API Endpoint
|
|
19
18
|
|
|
20
|
-
Full documentation is available [here](https://docs.chainlit.io).
|
|
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!
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
> [!NOTE]
|
|
22
|
+
> Contact us [here](https://forms.gle/BX3UNBLmTF75KgZVA) for **Enterprise Support**.
|
|
23
|
+
> 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
|
|
|
24
|
-
|
|
25
|
+
<p align="center">
|
|
26
|
+
<img src="https://github.com/Chainlit/chainlit/assets/13104895/0c2cc7a9-766c-41d3-aae2-117a2d0eb8ed" width="80%" />
|
|
27
|
+
</p>
|
|
25
28
|
|
|
26
29
|
## Installation
|
|
27
30
|
|
|
@@ -44,8 +47,10 @@ Create a new file `demo.py` with the following code:
|
|
|
44
47
|
import chainlit as cl
|
|
45
48
|
|
|
46
49
|
|
|
47
|
-
@cl.step
|
|
48
|
-
def tool():
|
|
50
|
+
@cl.step(type="tool")
|
|
51
|
+
async def tool():
|
|
52
|
+
# Fake tool
|
|
53
|
+
await cl.sleep(2)
|
|
49
54
|
return "Response from the tool!"
|
|
50
55
|
|
|
51
56
|
|
|
@@ -62,11 +67,12 @@ async def main(message: cl.Message):
|
|
|
62
67
|
None.
|
|
63
68
|
"""
|
|
64
69
|
|
|
70
|
+
final_answer = await cl.Message(content="").send()
|
|
71
|
+
|
|
65
72
|
# Call the tool
|
|
66
|
-
tool()
|
|
73
|
+
final_answer.content = await tool()
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
await cl.Message(content="This is the final answer").send()
|
|
75
|
+
await final_answer.update()
|
|
70
76
|
```
|
|
71
77
|
|
|
72
78
|
Now run it!
|
|
@@ -28,7 +28,7 @@ from chainlit.config import config
|
|
|
28
28
|
from chainlit.context import context
|
|
29
29
|
from chainlit.element import (
|
|
30
30
|
Audio,
|
|
31
|
-
|
|
31
|
+
Component,
|
|
32
32
|
File,
|
|
33
33
|
Image,
|
|
34
34
|
Pdf,
|
|
@@ -52,7 +52,7 @@ from chainlit.oauth_providers import get_configured_oauth_providers
|
|
|
52
52
|
from chainlit.step import Step, step
|
|
53
53
|
from chainlit.sync import make_async, run_sync
|
|
54
54
|
from chainlit.telemetry import trace
|
|
55
|
-
from chainlit.types import AudioChunk, ChatProfile, ThreadDict
|
|
55
|
+
from chainlit.types import AudioChunk, ChatProfile, Starter, ThreadDict
|
|
56
56
|
from chainlit.user import PersistedUser, User
|
|
57
57
|
from chainlit.user_session import user_session
|
|
58
58
|
from chainlit.utils import make_module_getattr, wrap_user_function
|
|
@@ -115,7 +115,7 @@ def oauth_callback(
|
|
|
115
115
|
|
|
116
116
|
Example:
|
|
117
117
|
@cl.oauth_callback
|
|
118
|
-
async def oauth_callback(provider_id: str, token: str, raw_user_data: Dict[str, str], default_app_user: User) -> Optional[User]:
|
|
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]:
|
|
119
119
|
|
|
120
120
|
Returns:
|
|
121
121
|
Callable[[str, str, Dict[str, str], User], Optional[User]]: The decorated authentication callback.
|
|
@@ -208,6 +208,22 @@ def set_chat_profiles(
|
|
|
208
208
|
return func
|
|
209
209
|
|
|
210
210
|
|
|
211
|
+
@trace
|
|
212
|
+
def set_starters(func: Callable[[Optional["User"]], List["Starter"]]) -> Callable:
|
|
213
|
+
"""
|
|
214
|
+
Programmatic declaration of the available starter (can depend on the User from the session if authentication is setup).
|
|
215
|
+
|
|
216
|
+
Args:
|
|
217
|
+
func (Callable[[Optional["User"]], List["Starter"]]): The function declaring the starters.
|
|
218
|
+
|
|
219
|
+
Returns:
|
|
220
|
+
Callable[[Optional["User"]], List["Starter"]]: The decorated function.
|
|
221
|
+
"""
|
|
222
|
+
|
|
223
|
+
config.code.set_starters = wrap_user_function(func)
|
|
224
|
+
return func
|
|
225
|
+
|
|
226
|
+
|
|
211
227
|
@trace
|
|
212
228
|
def on_chat_end(func: Callable) -> Callable:
|
|
213
229
|
"""
|
|
@@ -348,6 +364,8 @@ __getattr__ = make_module_getattr(
|
|
|
348
364
|
)
|
|
349
365
|
|
|
350
366
|
__all__ = [
|
|
367
|
+
"ChatProfile",
|
|
368
|
+
"Starter",
|
|
351
369
|
"user_session",
|
|
352
370
|
"CopilotFunction",
|
|
353
371
|
"AudioChunk",
|
|
@@ -359,7 +377,7 @@ __all__ = [
|
|
|
359
377
|
"Plotly",
|
|
360
378
|
"Image",
|
|
361
379
|
"Text",
|
|
362
|
-
"
|
|
380
|
+
"Component",
|
|
363
381
|
"Pyplot",
|
|
364
382
|
"File",
|
|
365
383
|
"Task",
|
|
@@ -7,13 +7,12 @@ import uvicorn
|
|
|
7
7
|
|
|
8
8
|
nest_asyncio.apply()
|
|
9
9
|
|
|
10
|
-
from chainlit.auth import ensure_jwt_secret
|
|
11
10
|
from chainlit.cache import init_lc_cache
|
|
12
|
-
from chainlit.cli.utils import check_file
|
|
13
11
|
from chainlit.config import (
|
|
14
12
|
BACKEND_ROOT,
|
|
15
13
|
DEFAULT_HOST,
|
|
16
14
|
DEFAULT_PORT,
|
|
15
|
+
DEFAULT_ROOT_PATH,
|
|
17
16
|
config,
|
|
18
17
|
init_config,
|
|
19
18
|
lint_translations,
|
|
@@ -22,8 +21,8 @@ from chainlit.config import (
|
|
|
22
21
|
from chainlit.logger import logger
|
|
23
22
|
from chainlit.markdown import init_markdown
|
|
24
23
|
from chainlit.secret import random_secret
|
|
25
|
-
from chainlit.server import app, register_wildcard_route_handler
|
|
26
24
|
from chainlit.telemetry import trace_event
|
|
25
|
+
from chainlit.utils import check_file, ensure_jwt_secret
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
# Create the main command group for Chainlit CLI
|
|
@@ -35,8 +34,14 @@ def cli():
|
|
|
35
34
|
|
|
36
35
|
# Define the function to run Chainlit with provided options
|
|
37
36
|
def run_chainlit(target: str):
|
|
37
|
+
from chainlit.server import combined_asgi_app as app
|
|
38
|
+
|
|
38
39
|
host = os.environ.get("CHAINLIT_HOST", DEFAULT_HOST)
|
|
39
40
|
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)
|
|
40
45
|
|
|
41
46
|
ws_per_message_deflate_env = os.environ.get(
|
|
42
47
|
"UVICORN_WS_PER_MESSAGE_DEFLATE", "true"
|
|
@@ -47,8 +52,13 @@ def run_chainlit(target: str):
|
|
|
47
52
|
"yes",
|
|
48
53
|
] # Convert to boolean
|
|
49
54
|
|
|
55
|
+
ws_protocol = os.environ.get(
|
|
56
|
+
"UVICORN_WS_PROTOCOL", "auto"
|
|
57
|
+
)
|
|
58
|
+
|
|
50
59
|
config.run.host = host
|
|
51
60
|
config.run.port = port
|
|
61
|
+
config.run.root_path = root_path
|
|
52
62
|
|
|
53
63
|
check_file(target)
|
|
54
64
|
# Load the module provided by the user
|
|
@@ -57,8 +67,6 @@ def run_chainlit(target: str):
|
|
|
57
67
|
|
|
58
68
|
ensure_jwt_secret()
|
|
59
69
|
|
|
60
|
-
register_wildcard_route_handler()
|
|
61
|
-
|
|
62
70
|
# Create the chainlit.md file if it doesn't exist
|
|
63
71
|
init_markdown(config.root)
|
|
64
72
|
|
|
@@ -73,8 +81,11 @@ def run_chainlit(target: str):
|
|
|
73
81
|
app,
|
|
74
82
|
host=host,
|
|
75
83
|
port=port,
|
|
84
|
+
ws=ws_protocol,
|
|
76
85
|
log_level=log_level,
|
|
77
86
|
ws_per_message_deflate=ws_per_message_deflate,
|
|
87
|
+
ssl_keyfile=ssl_keyfile,
|
|
88
|
+
ssl_certfile=ssl_certfile,
|
|
78
89
|
)
|
|
79
90
|
server = uvicorn.Server(config)
|
|
80
91
|
await server.serve()
|
|
@@ -126,13 +137,47 @@ def run_chainlit(target: str):
|
|
|
126
137
|
envvar="NO_CACHE",
|
|
127
138
|
help="Useful to disable third parties cache, such as langchain.",
|
|
128
139
|
)
|
|
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
|
+
)
|
|
129
152
|
@click.option("--host", help="Specify a different host to run the server on")
|
|
130
153
|
@click.option("--port", help="Specify a different port to run the server on")
|
|
131
|
-
|
|
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
|
+
):
|
|
132
168
|
if host:
|
|
133
169
|
os.environ["CHAINLIT_HOST"] = host
|
|
134
170
|
if port:
|
|
135
171
|
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
|
|
136
181
|
if ci:
|
|
137
182
|
logger.info("Running in CI mode")
|
|
138
183
|
|
|
@@ -150,6 +195,8 @@ def chainlit_run(target, watch, headless, debug, ci, no_cache, host, port):
|
|
|
150
195
|
config.run.no_cache = no_cache
|
|
151
196
|
config.run.ci = ci
|
|
152
197
|
config.run.watch = watch
|
|
198
|
+
config.run.ssl_cert = ssl_cert
|
|
199
|
+
config.run.ssl_key = ssl_key
|
|
153
200
|
|
|
154
201
|
run_chainlit(target)
|
|
155
202
|
|
|
@@ -4,7 +4,7 @@ import site
|
|
|
4
4
|
import sys
|
|
5
5
|
from importlib import util
|
|
6
6
|
from pathlib import Path
|
|
7
|
-
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union
|
|
7
|
+
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Literal, Optional, Union
|
|
8
8
|
|
|
9
9
|
import tomli
|
|
10
10
|
from chainlit.logger import logger
|
|
@@ -18,7 +18,7 @@ if TYPE_CHECKING:
|
|
|
18
18
|
from chainlit.action import Action
|
|
19
19
|
from chainlit.element import ElementBased
|
|
20
20
|
from chainlit.message import Message
|
|
21
|
-
from chainlit.types import AudioChunk, ChatProfile, ThreadDict
|
|
21
|
+
from chainlit.types import AudioChunk, ChatProfile, Starter, ThreadDict
|
|
22
22
|
from chainlit.user import User
|
|
23
23
|
from fastapi import Request, Response
|
|
24
24
|
|
|
@@ -61,9 +61,6 @@ allow_origins = ["*"]
|
|
|
61
61
|
# follow_symlink = false
|
|
62
62
|
|
|
63
63
|
[features]
|
|
64
|
-
# Show the prompt playground
|
|
65
|
-
prompt_playground = true
|
|
66
|
-
|
|
67
64
|
# 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)
|
|
68
65
|
unsafe_allow_html = false
|
|
69
66
|
|
|
@@ -95,21 +92,15 @@ auto_tag_thread = true
|
|
|
95
92
|
sample_rate = 44100
|
|
96
93
|
|
|
97
94
|
[UI]
|
|
98
|
-
# Name of the
|
|
99
|
-
name = "
|
|
100
|
-
|
|
101
|
-
# Show the readme while the thread is empty.
|
|
102
|
-
show_readme_as_default = true
|
|
95
|
+
# Name of the assistant.
|
|
96
|
+
name = "Assistant"
|
|
103
97
|
|
|
104
|
-
# Description of the
|
|
98
|
+
# Description of the assistant. This is used for HTML tags.
|
|
105
99
|
# description = ""
|
|
106
100
|
|
|
107
101
|
# Large size content are by default collapsed for a cleaner ui
|
|
108
102
|
default_collapse_content = true
|
|
109
103
|
|
|
110
|
-
# The default value for the expand messages settings.
|
|
111
|
-
default_expand_messages = false
|
|
112
|
-
|
|
113
104
|
# Hide the chain of thought details from the user in the UI.
|
|
114
105
|
hide_cot = false
|
|
115
106
|
|
|
@@ -136,6 +127,7 @@ hide_cot = false
|
|
|
136
127
|
# custom_build = "./public/build"
|
|
137
128
|
|
|
138
129
|
[UI.theme]
|
|
130
|
+
default = "dark"
|
|
139
131
|
#layout = "wide"
|
|
140
132
|
#font_family = "Inter, sans-serif"
|
|
141
133
|
# Override default MUI light theme. (Check theme.ts)
|
|
@@ -147,6 +139,9 @@ hide_cot = false
|
|
|
147
139
|
#main = "#F80061"
|
|
148
140
|
#dark = "#980039"
|
|
149
141
|
#light = "#FFE7EB"
|
|
142
|
+
[UI.theme.light.text]
|
|
143
|
+
#primary = "#212121"
|
|
144
|
+
#secondary = "#616161"
|
|
150
145
|
|
|
151
146
|
# Override default MUI dark theme. (Check theme.ts)
|
|
152
147
|
[UI.theme.dark]
|
|
@@ -157,7 +152,9 @@ hide_cot = false
|
|
|
157
152
|
#main = "#F80061"
|
|
158
153
|
#dark = "#980039"
|
|
159
154
|
#light = "#FFE7EB"
|
|
160
|
-
|
|
155
|
+
[UI.theme.dark.text]
|
|
156
|
+
#primary = "#EEEEEE"
|
|
157
|
+
#secondary = "#BDBDBD"
|
|
161
158
|
|
|
162
159
|
[meta]
|
|
163
160
|
generated_by = "{__version__}"
|
|
@@ -166,6 +163,7 @@ generated_by = "{__version__}"
|
|
|
166
163
|
|
|
167
164
|
DEFAULT_HOST = "0.0.0.0"
|
|
168
165
|
DEFAULT_PORT = 8000
|
|
166
|
+
DEFAULT_ROOT_PATH = ""
|
|
169
167
|
|
|
170
168
|
|
|
171
169
|
@dataclass()
|
|
@@ -174,6 +172,9 @@ class RunSettings:
|
|
|
174
172
|
module_name: Optional[str] = None
|
|
175
173
|
host: str = DEFAULT_HOST
|
|
176
174
|
port: int = DEFAULT_PORT
|
|
175
|
+
ssl_cert: Optional[str] = None
|
|
176
|
+
ssl_key: Optional[str] = None
|
|
177
|
+
root_path: str = DEFAULT_ROOT_PATH
|
|
177
178
|
headless: bool = False
|
|
178
179
|
watch: bool = False
|
|
179
180
|
no_cache: bool = False
|
|
@@ -188,16 +189,24 @@ class PaletteOptions(DataClassJsonMixin):
|
|
|
188
189
|
dark: Optional[str] = ""
|
|
189
190
|
|
|
190
191
|
|
|
192
|
+
@dataclass()
|
|
193
|
+
class TextOptions(DataClassJsonMixin):
|
|
194
|
+
primary: Optional[str] = ""
|
|
195
|
+
secondary: Optional[str] = ""
|
|
196
|
+
|
|
197
|
+
|
|
191
198
|
@dataclass()
|
|
192
199
|
class Palette(DataClassJsonMixin):
|
|
193
200
|
primary: Optional[PaletteOptions] = None
|
|
194
201
|
background: Optional[str] = ""
|
|
195
202
|
paper: Optional[str] = ""
|
|
203
|
+
text: Optional[TextOptions] = None
|
|
196
204
|
|
|
197
205
|
|
|
198
206
|
@dataclass()
|
|
199
207
|
class Theme(DataClassJsonMixin):
|
|
200
208
|
font_family: Optional[str] = None
|
|
209
|
+
default: Optional[Literal["light", "dark"]] = "dark"
|
|
201
210
|
layout: Optional[Literal["default", "wide"]] = "default"
|
|
202
211
|
light: Optional[Palette] = None
|
|
203
212
|
dark: Optional[Palette] = None
|
|
@@ -224,7 +233,6 @@ class AudioFeature(DataClassJsonMixin):
|
|
|
224
233
|
|
|
225
234
|
@dataclass()
|
|
226
235
|
class FeaturesSettings(DataClassJsonMixin):
|
|
227
|
-
prompt_playground: bool = True
|
|
228
236
|
spontaneous_file_upload: Optional[SpontaneousFileUploadFeature] = None
|
|
229
237
|
audio: Optional[AudioFeature] = Field(default_factory=AudioFeature)
|
|
230
238
|
latex: bool = False
|
|
@@ -235,12 +243,10 @@ class FeaturesSettings(DataClassJsonMixin):
|
|
|
235
243
|
@dataclass()
|
|
236
244
|
class UISettings(DataClassJsonMixin):
|
|
237
245
|
name: str
|
|
238
|
-
show_readme_as_default: bool = True
|
|
239
246
|
description: str = ""
|
|
240
247
|
hide_cot: bool = False
|
|
241
248
|
# Large size content are by default collapsed for a cleaner ui
|
|
242
249
|
default_collapse_content: bool = True
|
|
243
|
-
default_expand_messages: bool = False
|
|
244
250
|
github: Optional[str] = None
|
|
245
251
|
theme: Optional[Theme] = None
|
|
246
252
|
# Optional custom CSS file that allows you to customize the UI
|
|
@@ -279,6 +285,7 @@ class CodeSettings:
|
|
|
279
285
|
set_chat_profiles: Optional[Callable[[Optional["User"]], List["ChatProfile"]]] = (
|
|
280
286
|
None
|
|
281
287
|
)
|
|
288
|
+
set_starters: Optional[Callable[[Optional["User"]], List["Starter"]]] = None
|
|
282
289
|
|
|
283
290
|
|
|
284
291
|
@dataclass()
|
|
@@ -69,6 +69,8 @@ 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
|
+
|
|
72
74
|
session_id = str(uuid.uuid4())
|
|
73
75
|
thread_id = thread_id or str(uuid.uuid4())
|
|
74
76
|
session = HTTPSession(
|
|
@@ -81,6 +83,13 @@ def init_http_context(
|
|
|
81
83
|
)
|
|
82
84
|
context = ChainlitContext(session)
|
|
83
85
|
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
|
+
|
|
84
93
|
return context
|
|
85
94
|
|
|
86
95
|
|