Skip to content

Commit

Permalink
Remove session parameter from ui.Chat() (in anticipation of #793)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Jul 10, 2024
1 parent ea6aeea commit 5103fbb
Showing 1 changed file with 4 additions and 7 deletions.
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

0 comments on commit 5103fbb

Please sign in to comment.