chainlit 1.0.0rc1__tar.gz → 1.0.0rc3__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.0.0rc1 → chainlit-1.0.0rc3}/PKG-INFO +4 -3
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/data/__init__.py +10 -2
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/element.py +4 -1
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/emitter.py +18 -9
- chainlit-1.0.0rc1/chainlit/frontend/dist/assets/index-6aee009a.js → chainlit-1.0.0rc3/chainlit/frontend/dist/assets/index-15bb372a.js +116 -116
- chainlit-1.0.0rc1/chainlit/frontend/dist/assets/index-8942cb2d.css → chainlit-1.0.0rc3/chainlit/frontend/dist/assets/index-d088547c.css +1 -1
- chainlit-1.0.0rc1/chainlit/frontend/dist/assets/react-plotly-2f07c02a.js → chainlit-1.0.0rc3/chainlit/frontend/dist/assets/react-plotly-c9578a93.js +1 -1
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/frontend/dist/index.html +2 -2
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/message.py +2 -2
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/playground/providers/langchain.py +1 -1
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/playground/providers/openai.py +0 -2
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/server.py +5 -2
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/session.py +1 -1
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/socket.py +3 -2
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/step.py +17 -2
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/pyproject.toml +5 -5
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/README.md +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/__init__.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/__main__.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/action.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/auth.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/cache.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/chat_settings.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/cli/__init__.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/cli/utils.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/config.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/context.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/data/acl.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/frontend/dist/assets/logo_dark-bc7401f6.svg +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/frontend/dist/assets/logo_light-f19fc2ea.svg +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/frontend/dist/favicon.svg +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/haystack/__init__.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/haystack/callbacks.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/hello.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/input_widget.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/langchain/__init__.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/langchain/callbacks.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/langflow/__init__.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/llama_index/__init__.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/llama_index/callbacks.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/logger.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/markdown.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/oauth_providers.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/playground/__init__.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/playground/config.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/playground/provider.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/playground/providers/__init__.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/playground/providers/anthropic.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/playground/providers/huggingface.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/playground/providers/vertexai.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/py.typed +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/secret.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/sync.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/telemetry.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/types.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/user.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/user_session.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/utils.py +0 -0
- {chainlit-1.0.0rc1 → chainlit-1.0.0rc3}/chainlit/version.py +0 -0
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: chainlit
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0rc3
|
|
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
|
|
7
7
|
Keywords: LLM,Agents,gen ai,chat ui,chatbot ui,langchain
|
|
8
8
|
Author: Chainlit
|
|
9
|
-
Requires-Python: >=3.8.1,<
|
|
9
|
+
Requires-Python: >=3.8.1,<4.0.0
|
|
10
10
|
Classifier: License :: Other/Proprietary License
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.9
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
16
|
Requires-Dist: aiofiles (>=23.1.0,<24.0.0)
|
|
16
17
|
Requires-Dist: asyncer (>=0.0.2,<0.0.3)
|
|
17
|
-
Requires-Dist: chainlit_client (==0.1.
|
|
18
|
+
Requires-Dist: chainlit_client (==0.1.0rc7)
|
|
18
19
|
Requires-Dist: click (>=8.1.3,<9.0.0)
|
|
19
20
|
Requires-Dist: dataclasses_json (>=0.5.7,<0.6.0)
|
|
20
21
|
Requires-Dist: fastapi (>=0.100,<0.101)
|
|
@@ -3,6 +3,7 @@ import os
|
|
|
3
3
|
from collections import deque
|
|
4
4
|
from typing import TYPE_CHECKING, Dict, List, Optional
|
|
5
5
|
|
|
6
|
+
from chainlit.config import config
|
|
6
7
|
from chainlit.context import context
|
|
7
8
|
from chainlit.logger import logger
|
|
8
9
|
from chainlit.session import WebsocketSession
|
|
@@ -28,7 +29,7 @@ def queue_until_user_message():
|
|
|
28
29
|
async def wrapper(self, *args, **kwargs):
|
|
29
30
|
if (
|
|
30
31
|
isinstance(context.session, WebsocketSession)
|
|
31
|
-
and not context.session.
|
|
32
|
+
and not context.session.has_first_interaction
|
|
32
33
|
):
|
|
33
34
|
# Queue the method invocation waiting for the first user message
|
|
34
35
|
queues = context.session.thread_queues
|
|
@@ -127,6 +128,7 @@ class ChainlitDataLayer:
|
|
|
127
128
|
"chainlitKey": None,
|
|
128
129
|
"display": metadata.get("display", "side"),
|
|
129
130
|
"language": metadata.get("language"),
|
|
131
|
+
"page": metadata.get("page"),
|
|
130
132
|
"size": metadata.get("size"),
|
|
131
133
|
"type": metadata.get("type", "file"),
|
|
132
134
|
"forId": attachment.step_id,
|
|
@@ -229,11 +231,15 @@ class ChainlitDataLayer:
|
|
|
229
231
|
"language": element.language,
|
|
230
232
|
"display": element.display,
|
|
231
233
|
"type": element.type,
|
|
234
|
+
"page": getattr(element, "page", None),
|
|
232
235
|
}
|
|
233
236
|
|
|
237
|
+
if not element.for_id:
|
|
238
|
+
return
|
|
239
|
+
|
|
234
240
|
await self.client.api.create_attachment(
|
|
235
241
|
thread_id=element.thread_id,
|
|
236
|
-
step_id=element.for_id
|
|
242
|
+
step_id=element.for_id,
|
|
237
243
|
mime=element.mime,
|
|
238
244
|
name=element.name,
|
|
239
245
|
url=element.url,
|
|
@@ -332,6 +338,8 @@ class ChainlitDataLayer:
|
|
|
332
338
|
steps = [] # List[StepDict]
|
|
333
339
|
if thread.steps:
|
|
334
340
|
for step in thread.steps:
|
|
341
|
+
if config.ui.hide_cot and step.parent_id:
|
|
342
|
+
continue
|
|
335
343
|
for attachment in step.attachments:
|
|
336
344
|
elements.append(self.attachment_to_element_dict(attachment))
|
|
337
345
|
steps.append(self.step_to_step_dict(step))
|
|
@@ -37,6 +37,7 @@ class ElementDict(TypedDict):
|
|
|
37
37
|
display: ElementDisplay
|
|
38
38
|
size: Optional[ElementSize]
|
|
39
39
|
language: Optional[str]
|
|
40
|
+
page: Optional[int]
|
|
40
41
|
forId: Optional[str]
|
|
41
42
|
mime: Optional[str]
|
|
42
43
|
|
|
@@ -46,7 +47,7 @@ class Element:
|
|
|
46
47
|
# The type of the element. This will be used to determine how to display the element in the UI.
|
|
47
48
|
type: ClassVar[ElementType]
|
|
48
49
|
# Name of the element, this will be used to reference the element in the UI.
|
|
49
|
-
name: str
|
|
50
|
+
name: str = ""
|
|
50
51
|
# The ID of the element. This is set automatically when the element is sent to the UI.
|
|
51
52
|
id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
|
52
53
|
# The key of the element hosted on Chainlit.
|
|
@@ -91,6 +92,7 @@ class Element:
|
|
|
91
92
|
"display": self.display,
|
|
92
93
|
"objectKey": getattr(self, "object_key", None),
|
|
93
94
|
"size": getattr(self, "size", None),
|
|
95
|
+
"page": getattr(self, "page", None),
|
|
94
96
|
"language": getattr(self, "language", None),
|
|
95
97
|
"forId": getattr(self, "for_id", None),
|
|
96
98
|
"mime": getattr(self, "mime", None),
|
|
@@ -201,6 +203,7 @@ class Text(Element):
|
|
|
201
203
|
class Pdf(Element):
|
|
202
204
|
"""Useful to send a pdf to the UI."""
|
|
203
205
|
|
|
206
|
+
page: Optional[int] = None
|
|
204
207
|
type: ClassVar[ElementType] = "pdf"
|
|
205
208
|
|
|
206
209
|
|
|
@@ -64,8 +64,7 @@ class BaseChainlitEmitter:
|
|
|
64
64
|
"""Stub method to clear the prompt from the UI."""
|
|
65
65
|
pass
|
|
66
66
|
|
|
67
|
-
async def init_thread(self,
|
|
68
|
-
"""Signal the UI that a new thread (with a user message) exists"""
|
|
67
|
+
async def init_thread(self, interaction: str):
|
|
69
68
|
pass
|
|
70
69
|
|
|
71
70
|
async def process_user_message(self, payload: UIMessagePayload) -> Message:
|
|
@@ -167,8 +166,7 @@ class ChainlitEmitter(BaseChainlitEmitter):
|
|
|
167
166
|
|
|
168
167
|
return self.emit("clear_ask", {})
|
|
169
168
|
|
|
170
|
-
async def
|
|
171
|
-
"""Signal the UI that a new thread (with a user message) exists"""
|
|
169
|
+
async def flush_thread_queues(self, interaction: str):
|
|
172
170
|
if data_layer := get_data_layer():
|
|
173
171
|
if isinstance(self.session.user, PersistedUser):
|
|
174
172
|
user_id = self.session.user.id
|
|
@@ -177,11 +175,13 @@ class ChainlitEmitter(BaseChainlitEmitter):
|
|
|
177
175
|
await data_layer.update_thread(
|
|
178
176
|
thread_id=self.session.thread_id,
|
|
179
177
|
user_id=user_id,
|
|
180
|
-
metadata={"name":
|
|
178
|
+
metadata={"name": interaction},
|
|
181
179
|
)
|
|
182
180
|
await self.session.flush_method_queue()
|
|
183
181
|
|
|
184
|
-
|
|
182
|
+
async def init_thread(self, interaction: str):
|
|
183
|
+
await self.flush_thread_queues(interaction)
|
|
184
|
+
await self.emit("first_interaction", interaction)
|
|
185
185
|
|
|
186
186
|
async def process_user_message(self, payload: UIMessagePayload):
|
|
187
187
|
step_dict = payload["message"]
|
|
@@ -195,9 +195,9 @@ class ChainlitEmitter(BaseChainlitEmitter):
|
|
|
195
195
|
|
|
196
196
|
asyncio.create_task(message._create())
|
|
197
197
|
|
|
198
|
-
if not self.session.
|
|
199
|
-
self.session.
|
|
200
|
-
asyncio.create_task(self.init_thread(message.
|
|
198
|
+
if not self.session.has_first_interaction:
|
|
199
|
+
self.session.has_first_interaction = True
|
|
200
|
+
asyncio.create_task(self.init_thread(message.content))
|
|
201
201
|
|
|
202
202
|
if file_refs:
|
|
203
203
|
files = [
|
|
@@ -237,11 +237,13 @@ class ChainlitEmitter(BaseChainlitEmitter):
|
|
|
237
237
|
] = None
|
|
238
238
|
|
|
239
239
|
if user_res:
|
|
240
|
+
interaction = None
|
|
240
241
|
if spec.type == "text":
|
|
241
242
|
message_dict_res = cast(StepDict, user_res)
|
|
242
243
|
await self.process_user_message(
|
|
243
244
|
{"message": message_dict_res, "fileReferences": None}
|
|
244
245
|
)
|
|
246
|
+
interaction = message_dict_res["output"]
|
|
245
247
|
final_res = message_dict_res
|
|
246
248
|
elif spec.type == "file":
|
|
247
249
|
file_refs = cast(List[FileReference], user_res)
|
|
@@ -251,6 +253,7 @@ class ChainlitEmitter(BaseChainlitEmitter):
|
|
|
251
253
|
if file["id"] in self.session.files
|
|
252
254
|
]
|
|
253
255
|
final_res = files
|
|
256
|
+
interaction = ",".join([file["name"] for file in files])
|
|
254
257
|
if get_data_layer():
|
|
255
258
|
coros = [
|
|
256
259
|
File(
|
|
@@ -266,6 +269,12 @@ class ChainlitEmitter(BaseChainlitEmitter):
|
|
|
266
269
|
elif spec.type == "action":
|
|
267
270
|
action_res = cast(AskActionResponse, user_res)
|
|
268
271
|
final_res = action_res
|
|
272
|
+
interaction = action_res["value"]
|
|
273
|
+
|
|
274
|
+
if not self.session.has_first_interaction and interaction:
|
|
275
|
+
self.session.has_first_interaction = True
|
|
276
|
+
await self.init_thread(interaction=interaction)
|
|
277
|
+
|
|
269
278
|
await self.clear_ask()
|
|
270
279
|
return final_res
|
|
271
280
|
except TimeoutError as e:
|