chainlit 1.0.504__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/data/__init__.py CHANGED
@@ -2,16 +2,35 @@ import functools
2
2
  import json
3
3
  import os
4
4
  from collections import deque
5
- from typing import TYPE_CHECKING, Dict, List, Literal, Optional, Union, cast, Protocol, Any
5
+ from typing import (
6
+ TYPE_CHECKING,
7
+ Any,
8
+ Dict,
9
+ List,
10
+ Literal,
11
+ Optional,
12
+ Protocol,
13
+ Union,
14
+ cast,
15
+ )
6
16
 
7
17
  import aiofiles
8
18
  from chainlit.config import config
9
19
  from chainlit.context import context
10
20
  from chainlit.logger import logger
11
21
  from chainlit.session import WebsocketSession
12
- from chainlit.types import Feedback, Pagination, ThreadDict, ThreadFilter, PageInfo, PaginatedResponse
22
+ from chainlit.types import (
23
+ Feedback,
24
+ PageInfo,
25
+ PaginatedResponse,
26
+ Pagination,
27
+ ThreadDict,
28
+ ThreadFilter,
29
+ )
13
30
  from chainlit.user import PersistedUser, User
14
- from literalai import Attachment, PaginatedResponse as LiteralPaginatedResponse, Score as LiteralScore, Step as LiteralStep
31
+ from literalai import Attachment
32
+ from literalai import Score as LiteralScore
33
+ from literalai import Step as LiteralStep
15
34
  from literalai.filter import threads_filters as LiteralThreadsFilters
16
35
  from literalai.step import StepDict as LiteralStepDict
17
36
 
@@ -226,7 +245,7 @@ class ChainlitDataLayer(BaseDataLayer):
226
245
  return PersistedUser(
227
246
  id=_user.id or "",
228
247
  identifier=_user.identifier or "",
229
- metadata=_user.metadata,
248
+ metadata=user.metadata,
230
249
  createdAt=_user.created_at or "",
231
250
  )
232
251
 
@@ -411,7 +430,7 @@ class ChainlitDataLayer(BaseDataLayer):
411
430
  }
412
431
  )
413
432
 
414
- literal_response: LiteralPaginatedResponse = await self.client.api.list_threads(
433
+ literal_response = await self.client.api.list_threads(
415
434
  first=pagination.first,
416
435
  after=pagination.cursor,
417
436
  filters=literal_filters,
@@ -421,8 +440,8 @@ class ChainlitDataLayer(BaseDataLayer):
421
440
  pageInfo=PageInfo(
422
441
  hasNextPage=literal_response.pageInfo.hasNextPage,
423
442
  startCursor=literal_response.pageInfo.startCursor,
424
- endCursor=literal_response.pageInfo.endCursor
425
- ),
443
+ endCursor=literal_response.pageInfo.endCursor,
444
+ ),
426
445
  data=literal_response.data,
427
446
  )
428
447
 
@@ -470,11 +489,20 @@ class ChainlitDataLayer(BaseDataLayer):
470
489
  tags=tags,
471
490
  )
472
491
 
492
+
473
493
  class BaseStorageClient(Protocol):
474
494
  """Base class for non-text data persistence like Azure Data Lake, S3, Google Storage, etc."""
475
- async def upload_file(self, object_key: str, data: Union[bytes, str], mime: str = 'application/octet-stream', overwrite: bool = True) -> Dict[str, Any]:
495
+
496
+ async def upload_file(
497
+ self,
498
+ object_key: str,
499
+ data: Union[bytes, str],
500
+ mime: str = "application/octet-stream",
501
+ overwrite: bool = True,
502
+ ) -> Dict[str, Any]:
476
503
  pass
477
504
 
505
+
478
506
  if api_key := os.environ.get("LITERAL_API_KEY"):
479
507
  # support legacy LITERAL_SERVER variable as fallback
480
508
  server = os.environ.get("LITERAL_API_URL") or os.environ.get("LITERAL_SERVER")