chainlit 1.0.503__py3-none-any.whl → 1.0.505__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/emitter.py CHANGED
@@ -2,6 +2,7 @@ import asyncio
2
2
  import uuid
3
3
  from typing import Any, Dict, List, Literal, Optional, Union, cast
4
4
 
5
+ from chainlit.config import config
5
6
  from chainlit.data import get_data_layer
6
7
  from chainlit.element import Element, File
7
8
  from chainlit.logger import logger
@@ -175,22 +176,31 @@ class ChainlitEmitter(BaseChainlitEmitter):
175
176
  else:
176
177
  user_id = None
177
178
  try:
178
- tags = (
179
- [self.session.chat_profile] if self.session.chat_profile else None
179
+ should_tag_thread = (
180
+ self.session.chat_profile and config.features.auto_tag_thread
180
181
  )
181
- await data_layer.update_thread(
182
- thread_id=self.session.thread_id,
183
- name=interaction,
184
- user_id=user_id,
185
- tags=tags,
182
+ tags = [self.session.chat_profile] if should_tag_thread else None
183
+ asyncio.create_task(
184
+ data_layer.update_thread(
185
+ thread_id=self.session.thread_id,
186
+ name=interaction,
187
+ user_id=user_id,
188
+ tags=tags,
189
+ )
186
190
  )
187
191
  except Exception as e:
188
192
  logger.error(f"Error updating thread: {e}")
189
- await self.session.flush_method_queue()
193
+ asyncio.create_task(self.session.flush_method_queue())
190
194
 
191
195
  async def init_thread(self, interaction: str):
192
196
  await self.flush_thread_queues(interaction)
193
- await self.emit("first_interaction", interaction)
197
+ await self.emit(
198
+ "first_interaction",
199
+ {
200
+ "interaction": interaction,
201
+ "thread_id": self.session.thread_id,
202
+ },
203
+ )
194
204
 
195
205
  async def process_user_message(self, payload: UIMessagePayload):
196
206
  step_dict = payload["message"]