chainlit 0.2.110__py3-none-any.whl → 0.3.0__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.
- chainlit/__init__.py +48 -32
- chainlit/action.py +12 -12
- chainlit/cache.py +20 -0
- chainlit/cli/__init__.py +45 -29
- chainlit/cli/mock.py +48 -0
- chainlit/client.py +111 -89
- chainlit/config.py +22 -3
- chainlit/element.py +95 -124
- chainlit/{sdk.py → emitter.py} +55 -64
- chainlit/frontend/dist/assets/index-0b7e367e.js +717 -0
- chainlit/frontend/dist/assets/index-0cc9e355.css +1 -0
- chainlit/frontend/dist/index.html +3 -3
- chainlit/hello.py +3 -3
- chainlit/lc/__init__.py +11 -0
- chainlit/lc/agent.py +32 -0
- chainlit/lc/callbacks.py +411 -0
- chainlit/message.py +72 -96
- chainlit/server.py +280 -195
- chainlit/session.py +4 -2
- chainlit/sync.py +37 -0
- chainlit/types.py +18 -1
- chainlit/user_session.py +16 -16
- {chainlit-0.2.110.dist-info → chainlit-0.3.0.dist-info}/METADATA +15 -14
- chainlit-0.3.0.dist-info/RECORD +37 -0
- chainlit/frontend/dist/assets/index-36bf9cab.js +0 -713
- chainlit/frontend/dist/assets/index-bdffdaa0.css +0 -1
- chainlit/lc/chainlit_handler.py +0 -271
- chainlit/lc/monkey.py +0 -28
- chainlit/lc/new_monkey.py +0 -167
- chainlit/lc/old_monkey.py +0 -119
- chainlit/lc/utils.py +0 -38
- chainlit/watch.py +0 -54
- chainlit-0.2.110.dist-info/RECORD +0 -38
- {chainlit-0.2.110.dist-info → chainlit-0.3.0.dist-info}/WHEEL +0 -0
- {chainlit-0.2.110.dist-info → chainlit-0.3.0.dist-info}/entry_points.txt +0 -0
chainlit/types.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from typing import List, TypedDict, Optional, Literal, Dict, Union
|
|
2
|
+
from pydantic import BaseModel
|
|
2
3
|
from pydantic.dataclasses import dataclass
|
|
3
4
|
from dataclasses_json import dataclass_json
|
|
4
5
|
|
|
5
|
-
ElementType = Literal["image", "text", "pdf"]
|
|
6
|
+
ElementType = Literal["image", "avatar", "text", "pdf"]
|
|
6
7
|
ElementDisplay = Literal["inline", "side", "page"]
|
|
7
8
|
ElementSize = Literal["small", "medium", "large"]
|
|
8
9
|
|
|
@@ -22,6 +23,7 @@ class AskFileSpec(AskSpec):
|
|
|
22
23
|
"""Specification for asking the user for a file."""
|
|
23
24
|
|
|
24
25
|
accept: Union[List[str], Dict[str, List[str]]]
|
|
26
|
+
max_files: int
|
|
25
27
|
max_size_mb: int
|
|
26
28
|
|
|
27
29
|
|
|
@@ -49,3 +51,18 @@ class LLMSettings:
|
|
|
49
51
|
top_p: int = 1
|
|
50
52
|
frequency_penalty: int = 0
|
|
51
53
|
presence_penalty: int = 0
|
|
54
|
+
|
|
55
|
+
def to_settings_dict(self):
|
|
56
|
+
return {
|
|
57
|
+
"temperature": self.temperature,
|
|
58
|
+
"max_tokens": self.max_tokens,
|
|
59
|
+
"top_p": self.top_p,
|
|
60
|
+
"frequency_penalty": self.frequency_penalty,
|
|
61
|
+
"presence_penalty": self.presence_penalty,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class CompletionRequest(BaseModel):
|
|
66
|
+
prompt: str
|
|
67
|
+
userEnv: Dict[str, str]
|
|
68
|
+
settings: LLMSettings
|
chainlit/user_session.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from typing import Dict
|
|
2
|
-
from chainlit.
|
|
2
|
+
from chainlit.emitter import get_emitter
|
|
3
3
|
|
|
4
4
|
user_sessions: Dict[str, Dict] = {}
|
|
5
5
|
|
|
@@ -11,33 +11,33 @@ class UserSession:
|
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
def get(self, key):
|
|
14
|
-
|
|
15
|
-
if not
|
|
14
|
+
emitter = get_emitter()
|
|
15
|
+
if not emitter:
|
|
16
16
|
return None
|
|
17
17
|
|
|
18
|
-
if
|
|
18
|
+
if emitter.session["id"] not in user_sessions:
|
|
19
19
|
# Create a new user session
|
|
20
|
-
user_sessions[
|
|
20
|
+
user_sessions[emitter.session["id"]] = {}
|
|
21
21
|
|
|
22
|
-
user_session = user_sessions[
|
|
22
|
+
user_session = user_sessions[emitter.session["id"]]
|
|
23
23
|
|
|
24
|
-
# Copy important fields from the
|
|
25
|
-
user_session["id"] =
|
|
26
|
-
user_session["env"] =
|
|
27
|
-
if "agent" in
|
|
28
|
-
user_session["agent"] =
|
|
24
|
+
# Copy important fields from the session
|
|
25
|
+
user_session["id"] = emitter.session["id"]
|
|
26
|
+
user_session["env"] = emitter.session["user_env"]
|
|
27
|
+
if "agent" in emitter.session:
|
|
28
|
+
user_session["agent"] = emitter.session["agent"]
|
|
29
29
|
|
|
30
30
|
return user_session.get(key)
|
|
31
31
|
|
|
32
32
|
def set(self, key, value):
|
|
33
|
-
|
|
34
|
-
if not
|
|
33
|
+
emitter = get_emitter()
|
|
34
|
+
if not emitter:
|
|
35
35
|
return None
|
|
36
36
|
|
|
37
|
-
if
|
|
38
|
-
user_sessions[
|
|
37
|
+
if emitter.session["id"] not in user_sessions:
|
|
38
|
+
user_sessions[emitter.session["id"]] = {}
|
|
39
39
|
|
|
40
|
-
user_session = user_sessions[
|
|
40
|
+
user_session = user_sessions[emitter.session["id"]]
|
|
41
41
|
user_session[key] = value
|
|
42
42
|
|
|
43
43
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: chainlit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A faster way to build chatbot UIs.
|
|
5
5
|
Home-page: https://github.com/Chainlit/chainlit
|
|
6
6
|
License: Apache-2.0 license
|
|
@@ -13,23 +13,24 @@ Classifier: Programming Language :: Python :: 3.8
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.9
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Requires-Dist: aiofiles (>=23.1.0,<24.0.0)
|
|
17
|
+
Requires-Dist: aiohttp (>=3.8.4,<4.0.0)
|
|
18
|
+
Requires-Dist: asyncer (>=0.0.2,<0.0.3)
|
|
16
19
|
Requires-Dist: auth0-python (>=4.1.1,<5.0.0)
|
|
17
20
|
Requires-Dist: click (>=8.1.3,<9.0.0)
|
|
18
21
|
Requires-Dist: dataclasses_json (>=0.5.7,<0.6.0)
|
|
19
|
-
Requires-Dist:
|
|
20
|
-
Requires-Dist:
|
|
21
|
-
Requires-Dist:
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
Requires-Dist: pydantic (>=1.10.6,<2.0.0)
|
|
22
|
+
Requires-Dist: fastapi (>=0.96.0,<0.97.0)
|
|
23
|
+
Requires-Dist: fastapi-socketio (>=0.0.10,<0.0.11)
|
|
24
|
+
Requires-Dist: nest-asyncio (>=1.5.6,<2.0.0)
|
|
25
|
+
Requires-Dist: openai (>=0.27.7,<0.28.0)
|
|
26
|
+
Requires-Dist: pydantic (>=1.10.8,<2.0.0)
|
|
25
27
|
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
|
|
26
28
|
Requires-Dist: python-graphql-client (>=0.4.3,<0.5.0)
|
|
29
|
+
Requires-Dist: syncer (>=2.0.3,<3.0.0)
|
|
27
30
|
Requires-Dist: tomli (>=2.0.1,<3.0.0)
|
|
28
|
-
Requires-Dist: typing-inspect (==0.8.0)
|
|
29
|
-
Requires-Dist: typing_extensions (==4.5.0)
|
|
30
31
|
Requires-Dist: uptrace (>=1.18.0,<2.0.0)
|
|
31
|
-
Requires-Dist:
|
|
32
|
-
Requires-Dist:
|
|
32
|
+
Requires-Dist: uvicorn (>=0.22.0,<0.23.0)
|
|
33
|
+
Requires-Dist: watchfiles (>=0.19.0,<0.20.0)
|
|
33
34
|
Project-URL: Repository, https://github.com/Chainlit/chainlit
|
|
34
35
|
Description-Content-Type: text/markdown
|
|
35
36
|
|
|
@@ -72,12 +73,12 @@ import chainlit as cl
|
|
|
72
73
|
|
|
73
74
|
|
|
74
75
|
@cl.on_message # this function will be called every time a user inputs a message in the UI
|
|
75
|
-
def main(message: str):
|
|
76
|
+
async def main(message: str):
|
|
76
77
|
# this is an intermediate step
|
|
77
|
-
cl.Message(author="Tool 1", content=f"Response from tool1", indent=1).send()
|
|
78
|
+
await cl.Message(author="Tool 1", content=f"Response from tool1", indent=1).send()
|
|
78
79
|
|
|
79
80
|
# send back the final answer
|
|
80
|
-
cl.Message(content=f"This is the final answer").send()
|
|
81
|
+
await cl.Message(content=f"This is the final answer").send()
|
|
81
82
|
```
|
|
82
83
|
|
|
83
84
|
Now run it!
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
chainlit/__init__.py,sha256=eZdyrNXN6N-vcPkb4vnE6_EY8GcrkDq0wS01IZJKwaI,7376
|
|
2
|
+
chainlit/__main__.py,sha256=7Vg3w3T3qDuz4KDu5lQhLH6lQ3cYdume7gHH7Z1V97U,87
|
|
3
|
+
chainlit/action.py,sha256=0EqKgI1Z_81e6cOxvEziOrM8xEqAJhON8IwtVc3j7ag,1316
|
|
4
|
+
chainlit/cache.py,sha256=KE9qMPlL5mCDKz_RvM5rRLKI4nJOmH9kh4QO9bRHIJc,623
|
|
5
|
+
chainlit/cli/__init__.py,sha256=goG89Dq30e1vXTbBFnU9G3YT1dpEye9SGwJJlu0mmIE,3938
|
|
6
|
+
chainlit/cli/auth.py,sha256=G437UK4BvLA4wWPz_KPDwN6_6dnchMtHWr4tqu5XN-M,4093
|
|
7
|
+
chainlit/cli/deploy.py,sha256=dOqgmnVI4xsorwd0g6GgQAIB92oBgli-02HKqs1GWTQ,2594
|
|
8
|
+
chainlit/cli/mock.py,sha256=tWvkbPzm6TeBkAu6b1ia9gL6iTj9OS3YLyxmreTJU6o,1147
|
|
9
|
+
chainlit/cli/utils.py,sha256=Pn6ANnw9GgdUduiMphnb8RiGUPRbzDafkCHM2rOPBj4,716
|
|
10
|
+
chainlit/client.py,sha256=dWZwECFHQpDZrX5l-9mO5S_rcMFrzOYS9Lv3--eDCU8,9838
|
|
11
|
+
chainlit/config.py,sha256=4mSxCiAVuX96pOhuh0BcvSW3MS50X-9M7jqkzfiQrfA,6978
|
|
12
|
+
chainlit/element.py,sha256=WpraGIRx6y7l1I2T1BKqLr6Wn1TYwKXFdaFswAByQ-8,5048
|
|
13
|
+
chainlit/emitter.py,sha256=qEnM2zl52sUEcx2MF0SgIDcgTrT4rSMPd-_CEL9CfM0,5113
|
|
14
|
+
chainlit/frontend/dist/assets/index-0b7e367e.js,sha256=hEuBIKyaAL_j5PrbPprtUZvW_DdGopTzGHMNRrksnbc,2131276
|
|
15
|
+
chainlit/frontend/dist/assets/index-0cc9e355.css,sha256=DMnjVb6nxJcdvKdScCxwxPeAB371lobDj4BALLLNZVU,5666
|
|
16
|
+
chainlit/frontend/dist/assets/logo_dark-bc7401f6.svg,sha256=vHQB9g-n5OqOmuH3Fduuc7ZMg0EmMsGyO9cEnYwLbHg,8889
|
|
17
|
+
chainlit/frontend/dist/assets/logo_light-f19fc2ea.svg,sha256=8Z_C6t-0V9QL9ldmLjaLfp2REcGDuaTeNynj6-6muNI,8891
|
|
18
|
+
chainlit/frontend/dist/favicon.svg,sha256=0Cy8x28obT5eWW3nxZRhsEvu6_zMqrqbg0y6hT3D0Q0,6455
|
|
19
|
+
chainlit/frontend/dist/index.html,sha256=ARfths30105jHH04EDCQEX3nvBVYc-PjtdACeCDwCzk,793
|
|
20
|
+
chainlit/hello.py,sha256=bqKP00i0FKHnZ9fdyVW1a2xDAA1g7IWT0EVzUNky7rA,417
|
|
21
|
+
chainlit/lc/__init__.py,sha256=AHceu8jfttx74FLLhr7TIk5ihOqFFqJde1M33Y_YEFA,292
|
|
22
|
+
chainlit/lc/agent.py,sha256=HLIEpvPCAcqurLa5koH9QV04_FLdIpB3HKrUrRaGeo0,1080
|
|
23
|
+
chainlit/lc/callbacks.py,sha256=yEjQnME1K4v-1nV62wGmLtuvvojIal_Yf76bgzPBPpA,13100
|
|
24
|
+
chainlit/logger.py,sha256=G6-k0WYt7Ghp0QPOZrKlQNAy41X8L7KJyKiHiumxAYw,398
|
|
25
|
+
chainlit/markdown.py,sha256=JRhaKb0BB1G2S1XEaGj95DH75y7jqWdeIPx4u0oDaxw,1623
|
|
26
|
+
chainlit/message.py,sha256=1cdSWtUyZzhvWqf1ScWGsBCnbe4yKDAhv9rlD5d0lls,11968
|
|
27
|
+
chainlit/server.py,sha256=9kRTR2hL1YPnoVOIvNvQxxB1tE-mdAU-i4x4WKCYJeU,13990
|
|
28
|
+
chainlit/session.py,sha256=iAWnxRFn1idCRUPrS2Vhe41b5dr-NyearGqKH8AshuM,884
|
|
29
|
+
chainlit/sync.py,sha256=10HNh8G1fzqDdhTXuHMhK6JpZaNAiwpKWCySn1YlXWQ,950
|
|
30
|
+
chainlit/telemetry.py,sha256=9_Sci6SskIHMq-l2vHq4EG1_JsaxwNWH5MUL3n3M3F8,2342
|
|
31
|
+
chainlit/types.py,sha256=1N3rkMsTujo-_mbYz3xwgy37xFY7tUuonl7F_Pb8iwA,1525
|
|
32
|
+
chainlit/user_session.py,sha256=_mGUmh1ga1qiRDT4m272ykxgUD6kBP52HkVwlUoOzsk,1213
|
|
33
|
+
chainlit/version.py,sha256=iosXhlXclBwBqlADFKEilxAC2wWKbtuBKi87AmPi7s8,196
|
|
34
|
+
chainlit-0.3.0.dist-info/METADATA,sha256=S1CT26bakQfjBlJ4gA0Mu6g6cLoxz8UPu5F1ZpoV61U,3953
|
|
35
|
+
chainlit-0.3.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
36
|
+
chainlit-0.3.0.dist-info/entry_points.txt,sha256=FrkqdjrFl8juSnvBndniyX7XuKojmUwO4ghRh-CFMQc,45
|
|
37
|
+
chainlit-0.3.0.dist-info/RECORD,,
|