chainlit 1.1.300__tar.gz → 1.1.300rc0__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.300 → chainlit-1.1.300rc0}/PKG-INFO +9 -18
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/README.md +6 -13
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/__init__.py +1 -3
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/cli/__init__.py +6 -53
- chainlit-1.1.300rc0/chainlit/cli/utils.py +24 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/config.py +0 -4
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/context.py +0 -9
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/copilot/dist/index.js +204 -204
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/data/__init__.py +3 -6
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/data/sql_alchemy.py +3 -3
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/element.py +9 -33
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/emitter.py +7 -8
- chainlit-1.1.300/chainlit/frontend/dist/assets/DailyMotion-578b63e6.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/DailyMotion-e54bf0dc.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/Facebook-b825e5bb.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/Facebook-a767c817.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/FilePlayer-bcba3b4e.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/FilePlayer-5d19f3d1.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/Kaltura-fc1c9497.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/Kaltura-93bef413.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/Mixcloud-4cfb2724.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/Mixcloud-d5d27c2a.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/Mux-aa92055c.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/Mux-ad063035.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/Preview-9f55905a.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/Preview-a9a0e47e.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/SoundCloud-f991fe03.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/SoundCloud-1698c4da.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/Streamable-53128f49.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/Streamable-e5832da9.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/Twitch-fce8b9f5.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/Twitch-cd321ef4.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/Vidyard-e35c6102.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/Vidyard-8646c638.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/Vimeo-fff35f8e.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/Vimeo-0e590e3a.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/Wistia-ec07dc64.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/Wistia-76f0c9b0.js +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/YouTube-ad068e2a.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/YouTube-a94756f4.js +1 -1
- chainlit-1.1.300rc0/chainlit/frontend/dist/assets/index-51fef15f.js +727 -0
- chainlit-1.1.300/chainlit/frontend/dist/assets/index-aaf974a9.css → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/index-53c62926.css +1 -1
- chainlit-1.1.300/chainlit/frontend/dist/assets/react-plotly-b2c6442b.js → chainlit-1.1.300rc0/chainlit/frontend/dist/assets/react-plotly-d9ffbf69.js +1 -1
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/frontend/dist/index.html +3 -2
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/message.py +8 -13
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/oauth_providers.py +0 -118
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/server.py +57 -182
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/slack/app.py +2 -2
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/socket.py +20 -26
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/step.py +9 -24
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/translations/en-US.json +1 -1
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/types.py +17 -7
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/user.py +1 -9
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/utils.py +0 -43
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/pyproject.toml +4 -12
- chainlit-1.1.300/chainlit/data/dynamodb.py +0 -586
- chainlit-1.1.300/chainlit/frontend/dist/assets/index-d40d41cc.js +0 -727
- chainlit-1.1.300/chainlit/teams/__init__.py +0 -6
- chainlit-1.1.300/chainlit/teams/app.py +0 -332
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/__main__.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/action.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/auth.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/cache.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/chat_settings.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/copilot/dist/assets/logo_dark-2a3cf740.svg +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/copilot/dist/assets/logo_light-b078e7bc.svg +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/data/acl.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/data/storage_clients.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/discord/__init__.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/discord/app.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/frontend/dist/assets/logo_dark-2a3cf740.svg +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/frontend/dist/assets/logo_light-b078e7bc.svg +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/frontend/dist/favicon.svg +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/haystack/__init__.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/haystack/callbacks.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/hello.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/input_widget.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/langchain/__init__.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/langchain/callbacks.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/langflow/__init__.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/llama_index/__init__.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/llama_index/callbacks.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/logger.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/markdown.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/openai/__init__.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/py.typed +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/secret.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/session.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/slack/__init__.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/sync.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/telemetry.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/translations.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/chainlit/user_session.py +0 -0
- {chainlit-1.1.300 → chainlit-1.1.300rc0}/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.300rc0
|
|
4
4
|
Summary: Build Conversational AI.
|
|
5
5
|
Home-page: https://github.com/Chainlit/chainlit
|
|
6
6
|
License: Apache-2.0 license
|
|
@@ -18,19 +18,17 @@ 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)
|
|
21
22
|
Requires-Dist: filetype (>=1.2.0,<2.0.0)
|
|
22
23
|
Requires-Dist: httpx (>=0.23.0)
|
|
23
24
|
Requires-Dist: lazify (>=0.4.0,<0.5.0)
|
|
24
|
-
Requires-Dist: literalai (==0.0.
|
|
25
|
+
Requires-Dist: literalai (==0.0.602)
|
|
25
26
|
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"
|
|
28
27
|
Requires-Dist: packaging (>=23.1,<24.0)
|
|
29
28
|
Requires-Dist: pydantic (>=1,<3)
|
|
30
29
|
Requires-Dist: pyjwt (>=2.8.0,<3.0.0)
|
|
31
30
|
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
|
|
32
31
|
Requires-Dist: python-multipart (>=0.0.9,<0.0.10)
|
|
33
|
-
Requires-Dist: python-socketio (>=5.11.0,<6.0.0)
|
|
34
32
|
Requires-Dist: starlette (>=0.37.2,<0.38.0)
|
|
35
33
|
Requires-Dist: syncer (>=2.0.3,<3.0.0)
|
|
36
34
|
Requires-Dist: tomli (>=2.0.1,<3.0.0)
|
|
@@ -44,8 +42,6 @@ Description-Content-Type: text/markdown
|
|
|
44
42
|
|
|
45
43
|
[](https://discord.gg/k73SQ3FyUh)
|
|
46
44
|
[](https://twitter.com/chainlit_io)
|
|
47
|
-

|
|
48
|
-
[](https://github.com/chainlit/chainlit/graphs/contributors)
|
|
49
45
|
[](https://github.com/Chainlit/chainlit/actions/workflows/ci.yaml)
|
|
50
46
|
|
|
51
47
|
**Build production-ready Conversational AI applications in minutes, not weeks ⚡️**
|
|
@@ -64,9 +60,7 @@ Full documentation is available [here](https://docs.chainlit.io). You can ask Ch
|
|
|
64
60
|
> Contact us [here](https://forms.gle/BX3UNBLmTF75KgZVA) for **Enterprise Support**.
|
|
65
61
|
> 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.
|
|
66
62
|
|
|
67
|
-
|
|
68
|
-
<img src="https://github.com/Chainlit/chainlit/assets/13104895/0c2cc7a9-766c-41d3-aae2-117a2d0eb8ed" width="80%" />
|
|
69
|
-
</p>
|
|
63
|
+
https://github.com/Chainlit/chainlit/assets/13104895/8882af90-fdfa-4b24-8200-1ee96c6c7490
|
|
70
64
|
|
|
71
65
|
## Installation
|
|
72
66
|
|
|
@@ -89,10 +83,8 @@ Create a new file `demo.py` with the following code:
|
|
|
89
83
|
import chainlit as cl
|
|
90
84
|
|
|
91
85
|
|
|
92
|
-
@cl.step
|
|
93
|
-
|
|
94
|
-
# Fake tool
|
|
95
|
-
await cl.sleep(2)
|
|
86
|
+
@cl.step
|
|
87
|
+
def tool():
|
|
96
88
|
return "Response from the tool!"
|
|
97
89
|
|
|
98
90
|
|
|
@@ -109,12 +101,11 @@ async def main(message: cl.Message):
|
|
|
109
101
|
None.
|
|
110
102
|
"""
|
|
111
103
|
|
|
112
|
-
final_answer = await cl.Message(content="").send()
|
|
113
|
-
|
|
114
104
|
# Call the tool
|
|
115
|
-
|
|
105
|
+
tool()
|
|
116
106
|
|
|
117
|
-
|
|
107
|
+
# Send the final answer.
|
|
108
|
+
await cl.Message(content="This is the final answer").send()
|
|
118
109
|
```
|
|
119
110
|
|
|
120
111
|
Now run it!
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://discord.gg/k73SQ3FyUh)
|
|
4
4
|
[](https://twitter.com/chainlit_io)
|
|
5
|
-

|
|
6
|
-
[](https://github.com/chainlit/chainlit/graphs/contributors)
|
|
7
5
|
[](https://github.com/Chainlit/chainlit/actions/workflows/ci.yaml)
|
|
8
6
|
|
|
9
7
|
**Build production-ready Conversational AI applications in minutes, not weeks ⚡️**
|
|
@@ -22,9 +20,7 @@ Full documentation is available [here](https://docs.chainlit.io). You can ask Ch
|
|
|
22
20
|
> Contact us [here](https://forms.gle/BX3UNBLmTF75KgZVA) for **Enterprise Support**.
|
|
23
21
|
> 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.
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
<img src="https://github.com/Chainlit/chainlit/assets/13104895/0c2cc7a9-766c-41d3-aae2-117a2d0eb8ed" width="80%" />
|
|
27
|
-
</p>
|
|
23
|
+
https://github.com/Chainlit/chainlit/assets/13104895/8882af90-fdfa-4b24-8200-1ee96c6c7490
|
|
28
24
|
|
|
29
25
|
## Installation
|
|
30
26
|
|
|
@@ -47,10 +43,8 @@ Create a new file `demo.py` with the following code:
|
|
|
47
43
|
import chainlit as cl
|
|
48
44
|
|
|
49
45
|
|
|
50
|
-
@cl.step
|
|
51
|
-
|
|
52
|
-
# Fake tool
|
|
53
|
-
await cl.sleep(2)
|
|
46
|
+
@cl.step
|
|
47
|
+
def tool():
|
|
54
48
|
return "Response from the tool!"
|
|
55
49
|
|
|
56
50
|
|
|
@@ -67,12 +61,11 @@ async def main(message: cl.Message):
|
|
|
67
61
|
None.
|
|
68
62
|
"""
|
|
69
63
|
|
|
70
|
-
final_answer = await cl.Message(content="").send()
|
|
71
|
-
|
|
72
64
|
# Call the tool
|
|
73
|
-
|
|
65
|
+
tool()
|
|
74
66
|
|
|
75
|
-
|
|
67
|
+
# Send the final answer.
|
|
68
|
+
await cl.Message(content="This is the final answer").send()
|
|
76
69
|
```
|
|
77
70
|
|
|
78
71
|
Now run it!
|
|
@@ -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
|
|
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",
|
|
@@ -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
|
-
|
|
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
|
|
|
@@ -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}")
|
|
@@ -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
|
|
@@ -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
|
|