Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove session parameter from ui.Chat() #1517

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions shiny/ui/_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Callable,
Iterable,
Literal,
Optional,
Sequence,
Tuple,
Union,
Expand All @@ -22,7 +21,7 @@
from .. import _utils, reactive
from .._docstring import add_example
from .._namespaces import resolve_id
from ..session import Session, require_active_session, session_context
from ..session import require_active_session, session_context
from ..types import MISSING, MISSING_TYPE, NotifyException
from ..ui.css import CssUnit, as_css_unit
from ._chat_normalize import normalize_message, normalize_message_chunk
Expand Down Expand Up @@ -128,9 +127,6 @@ async def _():
attempted to be loaded the tokenizers library (if available). A custom tokenizer
can be provided by following the `TokenEncoding` (tiktoken or tozenizer)
protocol. If token limits are of no concern, provide `None`.
session
The :class:`~shiny.Session` instance that the chat should appear in. If not
provided, the session is inferred via :func:`~shiny.session.get_current_session`.
"""

def __init__(
Expand All @@ -140,7 +136,6 @@ def __init__(
messages: Sequence[ChatMessage] = (),
on_error: Literal["auto", "actual", "sanitize", "unhandled"] = "auto",
tokenizer: TokenEncoding | MISSING_TYPE | None = MISSING,
session: Optional[Session] = None,
):

self.id = id
Expand All @@ -151,7 +146,9 @@ def __init__(
self._tokenizer = get_default_tokenizer()
else:
self._tokenizer = tokenizer
self._session = require_active_session(session)
# TODO: remove the `None` when this PR lands:
# https://github.com/posit-dev/py-shiny/pull/793/files
self._session = require_active_session(None)

# Default to sanitizing until we know the app isn't sanitizing errors
if on_error == "auto":
Expand Down
Loading