Buckets:

download
raw
966 Bytes
import functools
from collections import deque
from chainlit.context import context
from chainlit.session import WebsocketSession
def queue_until_user_message():
def decorator(method):
@functools.wraps(method)
async def wrapper(self, *args, **kwargs):
if (
isinstance(context.session, WebsocketSession)
and not context.session.has_first_interaction
):
# Queue the method invocation waiting for the first user message
queues = context.session.thread_queues
method_name = method.__name__
if method_name not in queues:
queues[method_name] = deque()
queues[method_name].append((method, self, args, kwargs))
else:
# Otherwise, Execute the method immediately
return await method(self, *args, **kwargs)
return wrapper
return decorator

Xet Storage Details

Size:
966 Bytes
·
Xet hash:
72772947ab6db5ab804f5bf8cdfb9a825611c1df4a91a1c24d2a939736e7df55

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.