Open gadenbuie opened 2 days ago
the message's content_type is ultimately determined from the role.
There's a bit more to this. With role: "user"
we do currently fix it to "semi-markdown"
, but for role: "assistant"
you can switch from markdown to html by marking the content string with ui.HTML()
Also, providing control over the user's content type from .append_message()
doesn't feel quite right since user messages are automatically appended purely client-side (i.e., the only reason you should be appending user messages from the server is to restore a conversation). That said, it doesn't seem unreasonable to think we could provide some control over this in the ui.Chat()
constructor
Also, providing control over the user's content type from
.append_message()
doesn't feel quite right since user messages are automatically appended purely client-side
elmer appends messages server-side via shinychat which might have been copied from chatlas? idk, but it does happen. But also if you want to do something very custom where you mess with user input or assemble it from other UI elements, you'd want to have more control.
Currently,
chat.append_message()
allows a message to be a dictionary with items"role"
and"content"
and the message'scontent_type
is ultimately determined from therole
.I believe we should make it possible to customize the
content_type
directly in themessage
dictionary.Here's a small reprex from
shiny/api-examples/chat/app-core.py
:Put any text in the prompt in the browser and then run this in the dev console:
Ideally, the content type of the two added message could be customized based on the
content_type
of the message dictionary.