diff --git a/CHANGELOG.md b/CHANGELOG.md index ec6d0cc..fad9aa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### New features +* Added `.app(*, echo=)` support. This allows for chatlas to change the echo behavior when running the Shiny app. (#31) + ### Bug fixes +* Fix broken `Chat`'s Shiny app when `.app(*, stream=True)` by using async chat tools. (#31) * Update formatting of exported markdown to use `repr()` instead of `str()` when exporting tool call results. (#30) ## [0.3.0] - 2024-12-20 diff --git a/chatlas/_chat.py b/chatlas/_chat.py index 9989404..a75f43d 100644 --- a/chatlas/_chat.py +++ b/chatlas/_chat.py @@ -388,6 +388,7 @@ def app( port: int = 0, launch_browser: bool = True, bg_thread: Optional[bool] = None, + echo: Optional[Literal["text", "all", "none"]] = None, kwargs: Optional[SubmitInputArgsT] = None, ): """ @@ -404,6 +405,8 @@ def app( bg_thread Whether to run the app in a background thread. If `None`, the app will run in a background thread if the current environment is a notebook. + echo + Whether to echo text content, all content (i.e., tool calls), or no content. Defaults to `"none"` when `stream=True` and `"text"` when `stream=False`. kwargs Additional keyword arguments to pass to the method used for requesting the response. @@ -438,10 +441,22 @@ async def _(): return if stream: await chat.append_message_stream( - self.stream(user_input, kwargs=kwargs) + await self.stream_async( + user_input, + kwargs=kwargs, + echo=echo or "none", + ) ) else: - await chat.append_message(str(self.chat(user_input, kwargs=kwargs))) + await chat.append_message( + str( + self.chat( + user_input, + kwargs=kwargs, + echo=echo or "text", + ) + ) + ) app = App(app_ui, server)