chainlit 1.1.300__py3-none-any.whl → 1.1.300rc0__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 +1 -3
- chainlit/cli/__init__.py +6 -53
- chainlit/cli/utils.py +24 -0
- chainlit/config.py +0 -4
- chainlit/context.py +0 -9
- chainlit/copilot/dist/index.js +204 -204
- chainlit/data/__init__.py +3 -6
- chainlit/data/sql_alchemy.py +3 -3
- chainlit/element.py +9 -33
- chainlit/emitter.py +7 -8
- chainlit/frontend/dist/assets/{DailyMotion-578b63e6.js → DailyMotion-e54bf0dc.js} +1 -1
- chainlit/frontend/dist/assets/{Facebook-b825e5bb.js → Facebook-a767c817.js} +1 -1
- chainlit/frontend/dist/assets/{FilePlayer-bcba3b4e.js → FilePlayer-5d19f3d1.js} +1 -1
- chainlit/frontend/dist/assets/{Kaltura-fc1c9497.js → Kaltura-93bef413.js} +1 -1
- chainlit/frontend/dist/assets/{Mixcloud-4cfb2724.js → Mixcloud-d5d27c2a.js} +1 -1
- chainlit/frontend/dist/assets/{Mux-aa92055c.js → Mux-ad063035.js} +1 -1
- chainlit/frontend/dist/assets/{Preview-9f55905a.js → Preview-a9a0e47e.js} +1 -1
- chainlit/frontend/dist/assets/{SoundCloud-f991fe03.js → SoundCloud-1698c4da.js} +1 -1
- chainlit/frontend/dist/assets/{Streamable-53128f49.js → Streamable-e5832da9.js} +1 -1
- chainlit/frontend/dist/assets/{Twitch-fce8b9f5.js → Twitch-cd321ef4.js} +1 -1
- chainlit/frontend/dist/assets/{Vidyard-e35c6102.js → Vidyard-8646c638.js} +1 -1
- chainlit/frontend/dist/assets/{Vimeo-fff35f8e.js → Vimeo-0e590e3a.js} +1 -1
- chainlit/frontend/dist/assets/{Wistia-ec07dc64.js → Wistia-76f0c9b0.js} +1 -1
- chainlit/frontend/dist/assets/{YouTube-ad068e2a.js → YouTube-a94756f4.js} +1 -1
- chainlit/frontend/dist/assets/index-51fef15f.js +727 -0
- chainlit/frontend/dist/assets/{index-aaf974a9.css → index-53c62926.css} +1 -1
- chainlit/frontend/dist/assets/{react-plotly-b2c6442b.js → react-plotly-d9ffbf69.js} +1 -1
- chainlit/frontend/dist/index.html +3 -2
- chainlit/message.py +8 -13
- chainlit/oauth_providers.py +0 -118
- chainlit/server.py +57 -182
- chainlit/slack/app.py +2 -2
- chainlit/socket.py +20 -26
- chainlit/step.py +9 -24
- chainlit/translations/en-US.json +1 -1
- chainlit/types.py +17 -7
- chainlit/user.py +1 -9
- chainlit/utils.py +0 -43
- {chainlit-1.1.300.dist-info → chainlit-1.1.300rc0.dist-info}/METADATA +9 -18
- chainlit-1.1.300rc0.dist-info/RECORD +77 -0
- chainlit/data/dynamodb.py +0 -586
- chainlit/frontend/dist/assets/index-d40d41cc.js +0 -727
- chainlit/teams/__init__.py +0 -6
- chainlit/teams/app.py +0 -332
- chainlit-1.1.300.dist-info/RECORD +0 -79
- {chainlit-1.1.300.dist-info → chainlit-1.1.300rc0.dist-info}/WHEEL +0 -0
- {chainlit-1.1.300.dist-info → chainlit-1.1.300rc0.dist-info}/entry_points.txt +0 -0
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<!-- TAG INJECTION PLACEHOLDER -->
|
|
7
|
+
<link rel="icon" href="/favicon" />
|
|
7
8
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
8
9
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
9
10
|
<!-- FONT START -->
|
|
@@ -21,8 +22,8 @@
|
|
|
21
22
|
<script>
|
|
22
23
|
const global = globalThis;
|
|
23
24
|
</script>
|
|
24
|
-
<script type="module" crossorigin src="/assets/index-
|
|
25
|
-
<link rel="stylesheet" href="/assets/index-
|
|
25
|
+
<script type="module" crossorigin src="/assets/index-51fef15f.js"></script>
|
|
26
|
+
<link rel="stylesheet" href="/assets/index-53c62926.css">
|
|
26
27
|
</head>
|
|
27
28
|
<body>
|
|
28
29
|
<div id="root"></div>
|
chainlit/message.py
CHANGED
|
@@ -7,7 +7,7 @@ from typing import Dict, List, Optional, Union, cast
|
|
|
7
7
|
|
|
8
8
|
from chainlit.action import Action
|
|
9
9
|
from chainlit.config import config
|
|
10
|
-
from chainlit.context import context
|
|
10
|
+
from chainlit.context import context
|
|
11
11
|
from chainlit.data import get_data_layer
|
|
12
12
|
from chainlit.element import ElementBased
|
|
13
13
|
from chainlit.logger import logger
|
|
@@ -21,6 +21,7 @@ from chainlit.types import (
|
|
|
21
21
|
AskSpec,
|
|
22
22
|
FileDict,
|
|
23
23
|
)
|
|
24
|
+
from literalai import BaseGeneration
|
|
24
25
|
from literalai.helper import utc_now
|
|
25
26
|
from literalai.step import MessageStepType
|
|
26
27
|
|
|
@@ -37,22 +38,17 @@ class MessageBase(ABC):
|
|
|
37
38
|
fail_on_persist_error: bool = False
|
|
38
39
|
persisted = False
|
|
39
40
|
is_error = False
|
|
40
|
-
parent_id: Optional[str] = None
|
|
41
41
|
language: Optional[str] = None
|
|
42
42
|
metadata: Optional[Dict] = None
|
|
43
43
|
tags: Optional[List[str]] = None
|
|
44
44
|
wait_for_answer = False
|
|
45
45
|
indent: Optional[int] = None
|
|
46
|
+
generation: Optional[BaseGeneration] = None
|
|
46
47
|
|
|
47
48
|
def __post_init__(self) -> None:
|
|
48
49
|
trace_event(f"init {self.__class__.__name__}")
|
|
49
50
|
self.thread_id = context.session.thread_id
|
|
50
51
|
|
|
51
|
-
previous_steps = local_steps.get() or []
|
|
52
|
-
parent_step = previous_steps[-1] if previous_steps else None
|
|
53
|
-
if parent_step:
|
|
54
|
-
self.parent_id = parent_step.id
|
|
55
|
-
|
|
56
52
|
if not getattr(self, "id", None):
|
|
57
53
|
self.id = str(uuid.uuid4())
|
|
58
54
|
|
|
@@ -61,7 +57,6 @@ class MessageBase(ABC):
|
|
|
61
57
|
type = _dict.get("type", "assistant_message")
|
|
62
58
|
message = Message(
|
|
63
59
|
id=_dict["id"],
|
|
64
|
-
parent_id=_dict.get("parentId"),
|
|
65
60
|
created_at=_dict["createdAt"],
|
|
66
61
|
content=_dict["output"],
|
|
67
62
|
author=_dict.get("name", config.ui.name),
|
|
@@ -76,7 +71,6 @@ class MessageBase(ABC):
|
|
|
76
71
|
_dict: StepDict = {
|
|
77
72
|
"id": self.id,
|
|
78
73
|
"threadId": self.thread_id,
|
|
79
|
-
"parentId": self.parent_id,
|
|
80
74
|
"createdAt": self.created_at,
|
|
81
75
|
"start": self.created_at,
|
|
82
76
|
"end": self.created_at,
|
|
@@ -90,6 +84,7 @@ class MessageBase(ABC):
|
|
|
90
84
|
"isError": self.is_error,
|
|
91
85
|
"waitForAnswer": self.wait_for_answer,
|
|
92
86
|
"indent": self.indent,
|
|
87
|
+
"generation": self.generation.to_dict() if self.generation else None,
|
|
93
88
|
"metadata": self.metadata or {},
|
|
94
89
|
"tags": self.tags,
|
|
95
90
|
}
|
|
@@ -217,14 +212,15 @@ class Message(MessageBase):
|
|
|
217
212
|
elements: Optional[List[ElementBased]] = None,
|
|
218
213
|
disable_feedback: bool = False,
|
|
219
214
|
type: MessageStepType = "assistant_message",
|
|
215
|
+
generation: Optional[BaseGeneration] = None,
|
|
220
216
|
metadata: Optional[Dict] = None,
|
|
221
217
|
tags: Optional[List[str]] = None,
|
|
222
218
|
id: Optional[str] = None,
|
|
223
|
-
parent_id: Optional[str] = None,
|
|
224
219
|
created_at: Union[str, None] = None,
|
|
225
220
|
):
|
|
226
221
|
time.sleep(0.001)
|
|
227
222
|
self.language = language
|
|
223
|
+
self.generation = generation
|
|
228
224
|
if isinstance(content, dict):
|
|
229
225
|
try:
|
|
230
226
|
self.content = json.dumps(content, indent=4, ensure_ascii=False)
|
|
@@ -241,9 +237,6 @@ class Message(MessageBase):
|
|
|
241
237
|
if id:
|
|
242
238
|
self.id = str(id)
|
|
243
239
|
|
|
244
|
-
if parent_id:
|
|
245
|
-
self.parent_id = str(parent_id)
|
|
246
|
-
|
|
247
240
|
if created_at:
|
|
248
241
|
self.created_at = created_at
|
|
249
242
|
|
|
@@ -311,6 +304,8 @@ class ErrorMessage(MessageBase):
|
|
|
311
304
|
Args:
|
|
312
305
|
content (str): Text displayed above the upload button.
|
|
313
306
|
author (str, optional): The author of the message, this will be used in the UI. Defaults to the assistant name (see config).
|
|
307
|
+
parent_id (str, optional): If provided, the message will be nested inside the parent in the UI.
|
|
308
|
+
indent (int, optional): If positive, the message will be nested in the UI.
|
|
314
309
|
"""
|
|
315
310
|
|
|
316
311
|
def __init__(
|
chainlit/oauth_providers.py
CHANGED
|
@@ -4,7 +4,6 @@ import urllib.parse
|
|
|
4
4
|
from typing import Dict, List, Optional, Tuple
|
|
5
5
|
|
|
6
6
|
import httpx
|
|
7
|
-
from chainlit.secret import random_secret
|
|
8
7
|
from chainlit.user import User
|
|
9
8
|
from fastapi import HTTPException
|
|
10
9
|
|
|
@@ -187,60 +186,6 @@ class AzureADOAuthProvider(OAuthProvider):
|
|
|
187
186
|
)
|
|
188
187
|
return token
|
|
189
188
|
|
|
190
|
-
|
|
191
|
-
class AzureADHybridOAuthProvider(OAuthProvider):
|
|
192
|
-
id = "azure-ad-hybrid"
|
|
193
|
-
env = [
|
|
194
|
-
"OAUTH_AZURE_AD_HYBRID_CLIENT_ID",
|
|
195
|
-
"OAUTH_AZURE_AD_HYBRID_CLIENT_SECRET",
|
|
196
|
-
"OAUTH_AZURE_AD_HYBRID_TENANT_ID",
|
|
197
|
-
]
|
|
198
|
-
authorize_url = (
|
|
199
|
-
f"https://login.microsoftonline.com/{os.environ.get('OAUTH_AZURE_AD_HYBRID_TENANT_ID', '')}/oauth2/v2.0/authorize"
|
|
200
|
-
if os.environ.get("OAUTH_AZURE_AD_HYBRID_ENABLE_SINGLE_TENANT")
|
|
201
|
-
else "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
|
|
202
|
-
)
|
|
203
|
-
token_url = (
|
|
204
|
-
f"https://login.microsoftonline.com/{os.environ.get('OAUTH_AZURE_AD_HYBRID_TENANT_ID', '')}/oauth2/v2.0/token"
|
|
205
|
-
if os.environ.get("OAUTH_AZURE_AD_HYBRID_ENABLE_SINGLE_TENANT")
|
|
206
|
-
else "https://login.microsoftonline.com/common/oauth2/v2.0/token"
|
|
207
|
-
)
|
|
208
|
-
|
|
209
|
-
def __init__(self):
|
|
210
|
-
self.client_id = os.environ.get("OAUTH_AZURE_AD_HYBRID_CLIENT_ID")
|
|
211
|
-
self.client_secret = os.environ.get("OAUTH_AZURE_AD_HYBRID_CLIENT_SECRET")
|
|
212
|
-
nonce = random_secret(16)
|
|
213
|
-
self.authorize_params = {
|
|
214
|
-
"tenant": os.environ.get("OAUTH_AZURE_AD_HYBRID_TENANT_ID"),
|
|
215
|
-
"response_type": "code id_token",
|
|
216
|
-
"scope": "https://graph.microsoft.com/User.Read https://graph.microsoft.com/openid",
|
|
217
|
-
"response_mode": "form_post",
|
|
218
|
-
"nonce": nonce,
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
async def get_token(self, code: str, url: str):
|
|
222
|
-
payload = {
|
|
223
|
-
"client_id": self.client_id,
|
|
224
|
-
"client_secret": self.client_secret,
|
|
225
|
-
"code": code,
|
|
226
|
-
"grant_type": "authorization_code",
|
|
227
|
-
"redirect_uri": url,
|
|
228
|
-
}
|
|
229
|
-
async with httpx.AsyncClient() as client:
|
|
230
|
-
response = await client.post(
|
|
231
|
-
self.token_url,
|
|
232
|
-
data=payload,
|
|
233
|
-
)
|
|
234
|
-
response.raise_for_status()
|
|
235
|
-
json = response.json()
|
|
236
|
-
|
|
237
|
-
token = json["access_token"]
|
|
238
|
-
if not token:
|
|
239
|
-
raise HTTPException(
|
|
240
|
-
status_code=400, detail="Failed to get the access token"
|
|
241
|
-
)
|
|
242
|
-
return token
|
|
243
|
-
|
|
244
189
|
async def get_user_info(self, token: str):
|
|
245
190
|
async with httpx.AsyncClient() as client:
|
|
246
191
|
response = await client.get(
|
|
@@ -530,77 +475,14 @@ class AWSCognitoOAuthProvider(OAuthProvider):
|
|
|
530
475
|
return (cognito_user, user)
|
|
531
476
|
|
|
532
477
|
|
|
533
|
-
class GitlabOAuthProvider(OAuthProvider):
|
|
534
|
-
id = "gitlab"
|
|
535
|
-
env = [
|
|
536
|
-
"OAUTH_GITLAB_CLIENT_ID",
|
|
537
|
-
"OAUTH_GITLAB_CLIENT_SECRET",
|
|
538
|
-
"OAUTH_GITLAB_DOMAIN",
|
|
539
|
-
]
|
|
540
|
-
|
|
541
|
-
def __init__(self):
|
|
542
|
-
self.client_id = os.environ.get("OAUTH_GITLAB_CLIENT_ID")
|
|
543
|
-
self.client_secret = os.environ.get("OAUTH_GITLAB_CLIENT_SECRET")
|
|
544
|
-
# Ensure that the domain does not have a trailing slash
|
|
545
|
-
self.domain = f"https://{os.environ.get('OAUTH_GITLAB_DOMAIN', '').rstrip('/')}"
|
|
546
|
-
|
|
547
|
-
self.authorize_url = f"{self.domain}/oauth/authorize"
|
|
548
|
-
|
|
549
|
-
self.authorize_params = {
|
|
550
|
-
"scope": "openid profile email",
|
|
551
|
-
"response_type": "code",
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
async def get_token(self, code: str, url: str):
|
|
555
|
-
payload = {
|
|
556
|
-
"client_id": self.client_id,
|
|
557
|
-
"client_secret": self.client_secret,
|
|
558
|
-
"code": code,
|
|
559
|
-
"grant_type": "authorization_code",
|
|
560
|
-
"redirect_uri": url,
|
|
561
|
-
}
|
|
562
|
-
async with httpx.AsyncClient() as client:
|
|
563
|
-
response = await client.post(
|
|
564
|
-
f"{self.domain}/oauth/token",
|
|
565
|
-
data=payload,
|
|
566
|
-
)
|
|
567
|
-
response.raise_for_status()
|
|
568
|
-
json_content = response.json()
|
|
569
|
-
token = json_content.get("access_token")
|
|
570
|
-
if not token:
|
|
571
|
-
raise HTTPException(
|
|
572
|
-
status_code=400, detail="Failed to get the access token"
|
|
573
|
-
)
|
|
574
|
-
return token
|
|
575
|
-
|
|
576
|
-
async def get_user_info(self, token: str):
|
|
577
|
-
async with httpx.AsyncClient() as client:
|
|
578
|
-
response = await client.get(
|
|
579
|
-
f"{self.domain}/oauth/userinfo",
|
|
580
|
-
headers={"Authorization": f"Bearer {token}"},
|
|
581
|
-
)
|
|
582
|
-
response.raise_for_status()
|
|
583
|
-
gitlab_user = response.json()
|
|
584
|
-
user = User(
|
|
585
|
-
identifier=gitlab_user.get("email"),
|
|
586
|
-
metadata={
|
|
587
|
-
"image": gitlab_user.get("picture", ""),
|
|
588
|
-
"provider": "gitlab",
|
|
589
|
-
},
|
|
590
|
-
)
|
|
591
|
-
return (gitlab_user, user)
|
|
592
|
-
|
|
593
|
-
|
|
594
478
|
providers = [
|
|
595
479
|
GithubOAuthProvider(),
|
|
596
480
|
GoogleOAuthProvider(),
|
|
597
481
|
AzureADOAuthProvider(),
|
|
598
|
-
AzureADHybridOAuthProvider(),
|
|
599
482
|
OktaOAuthProvider(),
|
|
600
483
|
Auth0OAuthProvider(),
|
|
601
484
|
DescopeOAuthProvider(),
|
|
602
485
|
AWSCognitoOAuthProvider(),
|
|
603
|
-
GitlabOAuthProvider(),
|
|
604
486
|
]
|
|
605
487
|
|
|
606
488
|
|