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

feat: Update and submit user value #32

Open
schloerke opened this issue Jan 9, 2025 · 1 comment
Open

feat: Update and submit user value #32

schloerke opened this issue Jan 9, 2025 · 1 comment

Comments

@schloerke
Copy link
Contributor

While this feature is directly related towards shiny.ui.Chat, I'm posting the issue here as it is targeted towards chatlas.

Goal: Set and submit user value and display streaming result as if the user had done it.

Using await chat.chat_async("NEW_MSG") does not update the Shiny UI, but it'd be really cool if it did.

Current work around:

@reactive.effect
@reactive.event(trigger)
async def _():
    chat_ui.update_user_input(value="who is the tallest skywalker")

    add_chat_entry = ui.HTML("""
    <script>
        setTimeout(async () => {
            const enterEvent = new KeyboardEvent('keydown', {
                key: 'Enter',
                code: 'Enter',
                keyCode: 13,
                which: 13,
            });

            // Dispatch the 'Enter' event on the input element
            console.log("Dispatching Enter event");
            document.querySelector("textarea#chat_user_input").dispatchEvent(enterEvent);
        }, 500);
    </script>
            """)
    ui.insert_ui(add_chat_entry, "body")
@gadenbuie
Copy link
Contributor

IIUC, the feature you want is to be able to compose a user message for the user and submit it, having it be reflected both in the UI and in the response, right?

If so, to connect some dots, I also had a similar need and opened a request in ellmer + shinychat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants