Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

* An empty `ui.input_date()` value no longer crashes Shiny. (#1528)
* A handful of fixes for `ui.Chat()`, including:
* A fix for use inside Shiny modules. (#1582)
* `.messages(format="google")` now returns the correct role. (#1622)

* `ui.Chat()` now works as expected inside Shiny modules. (#1582)
* An empty `ui.input_date()` value no longer crashes Shiny. (#1528)

* Fixed bug where calling `.update_filter(None)` on a data frame renderer did not visually reset non-numeric column filters. (It did reset the column's filtering, just not the label). Now it resets filter's label. (#1557)

Expand Down
8 changes: 6 additions & 2 deletions shiny/ui/_chat_provider_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ def as_google_message(message: ChatMessage) -> "GoogleMessage":

import google.generativeai.types as gtypes # pyright: ignore[reportMissingTypeStubs]

if message["role"] == "system":
role = message["role"]

if role == "system":
raise ValueError(
"Google requires a system prompt to be specified in the `GenerativeModel()` constructor."
)
return gtypes.ContentDict(parts=[message["content"]], role=message["role"])
elif role == "assistant":
role = "model"
return gtypes.ContentDict(parts=[message["content"]], role=role)


def as_langchain_message(message: ChatMessage) -> "LangChainMessage":
Expand Down