chainlit 1.1.305__py3-none-any.whl → 1.1.306__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 +3 -2
- chainlit/chat_context.py +64 -0
- chainlit/config.py +3 -0
- chainlit/copilot/dist/index.js +138 -138
- chainlit/discord/app.py +2 -4
- chainlit/emitter.py +4 -2
- chainlit/frontend/dist/assets/{DailyMotion-4f715d15.js → DailyMotion-4ebdfef1.js} +1 -1
- chainlit/frontend/dist/assets/{Facebook-25f45c09.js → Facebook-40982be3.js} +1 -1
- chainlit/frontend/dist/assets/{FilePlayer-04482650.js → FilePlayer-5b3a4ad0.js} +1 -1
- chainlit/frontend/dist/assets/{Kaltura-37152a96.js → Kaltura-6c5cb748.js} +1 -1
- chainlit/frontend/dist/assets/{Mixcloud-914b75ee.js → Mixcloud-7a304880.js} +1 -1
- chainlit/frontend/dist/assets/{Mux-fb751398.js → Mux-1bd85c69.js} +1 -1
- chainlit/frontend/dist/assets/{Preview-85fbb8da.js → Preview-e91eb05e.js} +1 -1
- chainlit/frontend/dist/assets/{SoundCloud-8afad6c0.js → SoundCloud-2f2116b2.js} +1 -1
- chainlit/frontend/dist/assets/{Streamable-08844d93.js → Streamable-b92c07ce.js} +1 -1
- chainlit/frontend/dist/assets/{Twitch-1b95f5c8.js → Twitch-58a2eb9a.js} +1 -1
- chainlit/frontend/dist/assets/{Vidyard-5028fa2f.js → Vidyard-ad5bffa0.js} +1 -1
- chainlit/frontend/dist/assets/{Vimeo-ca732959.js → Vimeo-8fb43e9c.js} +1 -1
- chainlit/frontend/dist/assets/{Wistia-74e58d71.js → Wistia-d03e6237.js} +1 -1
- chainlit/frontend/dist/assets/{YouTube-bdf4ca10.js → YouTube-6b7d1dae.js} +1 -1
- chainlit/frontend/dist/assets/index-4f01eb67.js +727 -0
- chainlit/frontend/dist/assets/{react-plotly-cf9b99cc.js → react-plotly-ef3ac5f0.js} +1 -1
- chainlit/frontend/dist/index.html +1 -1
- chainlit/langchain/callbacks.py +2 -4
- chainlit/llama_index/callbacks.py +13 -27
- chainlit/message.py +4 -1
- chainlit/server.py +1 -1
- chainlit/slack/app.py +3 -5
- chainlit/socket.py +36 -0
- chainlit/types.py +0 -1
- chainlit/utils.py +1 -0
- {chainlit-1.1.305.dist-info → chainlit-1.1.306.dist-info}/METADATA +1 -1
- {chainlit-1.1.305.dist-info → chainlit-1.1.306.dist-info}/RECORD +35 -34
- chainlit/frontend/dist/assets/index-621140f9.js +0 -727
- {chainlit-1.1.305.dist-info → chainlit-1.1.306.dist-info}/WHEEL +0 -0
- {chainlit-1.1.305.dist-info → chainlit-1.1.306.dist-info}/entry_points.txt +0 -0
chainlit/__init__.py
CHANGED
|
@@ -21,11 +21,10 @@ if TYPE_CHECKING:
|
|
|
21
21
|
from chainlit.openai import instrument_openai
|
|
22
22
|
from chainlit.mistralai import instrument_mistralai
|
|
23
23
|
|
|
24
|
-
from literalai import ChatGeneration, CompletionGeneration, GenerationMessage
|
|
25
|
-
|
|
26
24
|
import chainlit.input_widget as input_widget
|
|
27
25
|
from chainlit.action import Action
|
|
28
26
|
from chainlit.cache import cache
|
|
27
|
+
from chainlit.chat_context import chat_context
|
|
29
28
|
from chainlit.chat_settings import ChatSettings
|
|
30
29
|
from chainlit.config import config
|
|
31
30
|
from chainlit.context import context
|
|
@@ -60,6 +59,7 @@ from chainlit.user import PersistedUser, User
|
|
|
60
59
|
from chainlit.user_session import user_session
|
|
61
60
|
from chainlit.utils import make_module_getattr, wrap_user_function
|
|
62
61
|
from chainlit.version import __version__
|
|
62
|
+
from literalai import ChatGeneration, CompletionGeneration, GenerationMessage
|
|
63
63
|
|
|
64
64
|
if env_found:
|
|
65
65
|
logger.info("Loaded .env file")
|
|
@@ -370,6 +370,7 @@ __all__ = [
|
|
|
370
370
|
"ChatProfile",
|
|
371
371
|
"Starter",
|
|
372
372
|
"user_session",
|
|
373
|
+
"chat_context",
|
|
373
374
|
"CopilotFunction",
|
|
374
375
|
"AudioChunk",
|
|
375
376
|
"Action",
|
chainlit/chat_context.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING, Dict, List
|
|
2
|
+
|
|
3
|
+
from chainlit.context import context
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from chainlit.message import Message
|
|
7
|
+
|
|
8
|
+
chat_contexts: Dict[str, List["Message"]] = {}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ChatContext:
|
|
12
|
+
def get(self) -> List["Message"]:
|
|
13
|
+
if not context.session:
|
|
14
|
+
return []
|
|
15
|
+
|
|
16
|
+
if context.session.id not in chat_contexts:
|
|
17
|
+
# Create a new chat context
|
|
18
|
+
chat_contexts[context.session.id] = []
|
|
19
|
+
|
|
20
|
+
return chat_contexts[context.session.id].copy()
|
|
21
|
+
|
|
22
|
+
def add(self, message: "Message"):
|
|
23
|
+
if not context.session:
|
|
24
|
+
return
|
|
25
|
+
|
|
26
|
+
if context.session.id not in chat_contexts:
|
|
27
|
+
chat_contexts[context.session.id] = []
|
|
28
|
+
|
|
29
|
+
if message not in chat_contexts[context.session.id]:
|
|
30
|
+
chat_contexts[context.session.id].append(message)
|
|
31
|
+
|
|
32
|
+
return message
|
|
33
|
+
|
|
34
|
+
def remove(self, message: "Message") -> bool:
|
|
35
|
+
if not context.session:
|
|
36
|
+
return False
|
|
37
|
+
|
|
38
|
+
if context.session.id not in chat_contexts:
|
|
39
|
+
return False
|
|
40
|
+
|
|
41
|
+
if message in chat_contexts[context.session.id]:
|
|
42
|
+
chat_contexts[context.session.id].remove(message)
|
|
43
|
+
return True
|
|
44
|
+
|
|
45
|
+
return False
|
|
46
|
+
|
|
47
|
+
def clear(self) -> None:
|
|
48
|
+
if context.session and context.session.id in chat_contexts:
|
|
49
|
+
chat_contexts[context.session.id] = []
|
|
50
|
+
|
|
51
|
+
def to_openai(self):
|
|
52
|
+
messages = []
|
|
53
|
+
for message in self.get():
|
|
54
|
+
if message.type == "assistant_message":
|
|
55
|
+
messages.append({"role": "assistant", "content": message.content})
|
|
56
|
+
elif message.type == "user_message":
|
|
57
|
+
messages.append({"role": "user", "content": message.content})
|
|
58
|
+
else:
|
|
59
|
+
messages.append({"role": "system", "content": message.content})
|
|
60
|
+
|
|
61
|
+
return messages
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
chat_context = ChatContext()
|
chainlit/config.py
CHANGED
|
@@ -91,6 +91,8 @@ auto_tag_thread = true
|
|
|
91
91
|
# Sample rate of the audio
|
|
92
92
|
sample_rate = 44100
|
|
93
93
|
|
|
94
|
+
edit_message = true
|
|
95
|
+
|
|
94
96
|
[UI]
|
|
95
97
|
# Name of the assistant.
|
|
96
98
|
name = "Assistant"
|
|
@@ -238,6 +240,7 @@ class FeaturesSettings(DataClassJsonMixin):
|
|
|
238
240
|
latex: bool = False
|
|
239
241
|
unsafe_allow_html: bool = False
|
|
240
242
|
auto_tag_thread: bool = True
|
|
243
|
+
edit_message:bool = True
|
|
241
244
|
|
|
242
245
|
|
|
243
246
|
@dataclass()
|