chainlit 1.1.304__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.

Files changed (37) hide show
  1. chainlit/__init__.py +5 -0
  2. chainlit/chat_context.py +64 -0
  3. chainlit/config.py +3 -0
  4. chainlit/copilot/dist/index.js +138 -138
  5. chainlit/discord/app.py +2 -4
  6. chainlit/emitter.py +4 -2
  7. chainlit/frontend/dist/assets/{DailyMotion-4f715d15.js → DailyMotion-4ebdfef1.js} +1 -1
  8. chainlit/frontend/dist/assets/{Facebook-25f45c09.js → Facebook-40982be3.js} +1 -1
  9. chainlit/frontend/dist/assets/{FilePlayer-04482650.js → FilePlayer-5b3a4ad0.js} +1 -1
  10. chainlit/frontend/dist/assets/{Kaltura-37152a96.js → Kaltura-6c5cb748.js} +1 -1
  11. chainlit/frontend/dist/assets/{Mixcloud-914b75ee.js → Mixcloud-7a304880.js} +1 -1
  12. chainlit/frontend/dist/assets/{Mux-fb751398.js → Mux-1bd85c69.js} +1 -1
  13. chainlit/frontend/dist/assets/{Preview-85fbb8da.js → Preview-e91eb05e.js} +1 -1
  14. chainlit/frontend/dist/assets/{SoundCloud-8afad6c0.js → SoundCloud-2f2116b2.js} +1 -1
  15. chainlit/frontend/dist/assets/{Streamable-08844d93.js → Streamable-b92c07ce.js} +1 -1
  16. chainlit/frontend/dist/assets/{Twitch-1b95f5c8.js → Twitch-58a2eb9a.js} +1 -1
  17. chainlit/frontend/dist/assets/{Vidyard-5028fa2f.js → Vidyard-ad5bffa0.js} +1 -1
  18. chainlit/frontend/dist/assets/{Vimeo-ca732959.js → Vimeo-8fb43e9c.js} +1 -1
  19. chainlit/frontend/dist/assets/{Wistia-74e58d71.js → Wistia-d03e6237.js} +1 -1
  20. chainlit/frontend/dist/assets/{YouTube-bdf4ca10.js → YouTube-6b7d1dae.js} +1 -1
  21. chainlit/frontend/dist/assets/index-4f01eb67.js +727 -0
  22. chainlit/frontend/dist/assets/{react-plotly-cf9b99cc.js → react-plotly-ef3ac5f0.js} +1 -1
  23. chainlit/frontend/dist/index.html +1 -1
  24. chainlit/langchain/callbacks.py +2 -4
  25. chainlit/llama_index/callbacks.py +13 -27
  26. chainlit/message.py +4 -1
  27. chainlit/mistralai/__init__.py +53 -0
  28. chainlit/server.py +1 -1
  29. chainlit/slack/app.py +3 -5
  30. chainlit/socket.py +36 -0
  31. chainlit/types.py +0 -1
  32. chainlit/utils.py +1 -0
  33. {chainlit-1.1.304.dist-info → chainlit-1.1.306.dist-info}/METADATA +2 -2
  34. {chainlit-1.1.304.dist-info → chainlit-1.1.306.dist-info}/RECORD +36 -34
  35. chainlit/frontend/dist/assets/index-621140f9.js +0 -727
  36. {chainlit-1.1.304.dist-info → chainlit-1.1.306.dist-info}/WHEEL +0 -0
  37. {chainlit-1.1.304.dist-info → chainlit-1.1.306.dist-info}/entry_points.txt +0 -0
chainlit/__init__.py CHANGED
@@ -19,10 +19,12 @@ if TYPE_CHECKING:
19
19
  )
20
20
  from chainlit.llama_index.callbacks import LlamaIndexCallbackHandler
21
21
  from chainlit.openai import instrument_openai
22
+ from chainlit.mistralai import instrument_mistralai
22
23
 
23
24
  import chainlit.input_widget as input_widget
24
25
  from chainlit.action import Action
25
26
  from chainlit.cache import cache
27
+ from chainlit.chat_context import chat_context
26
28
  from chainlit.chat_settings import ChatSettings
27
29
  from chainlit.config import config
28
30
  from chainlit.context import context
@@ -360,6 +362,7 @@ __getattr__ = make_module_getattr(
360
362
  "LlamaIndexCallbackHandler": "chainlit.llama_index.callbacks",
361
363
  "HaystackAgentCallbackHandler": "chainlit.haystack.callbacks",
362
364
  "instrument_openai": "chainlit.openai",
365
+ "instrument_mistralai": "chainlit.mistralai",
363
366
  }
364
367
  )
365
368
 
@@ -367,6 +370,7 @@ __all__ = [
367
370
  "ChatProfile",
368
371
  "Starter",
369
372
  "user_session",
373
+ "chat_context",
370
374
  "CopilotFunction",
371
375
  "AudioChunk",
372
376
  "Action",
@@ -416,6 +420,7 @@ __all__ = [
416
420
  "LlamaIndexCallbackHandler",
417
421
  "HaystackAgentCallbackHandler",
418
422
  "instrument_openai",
423
+ "instrument_mistralai",
419
424
  ]
420
425
 
421
426
 
@@ -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()