posit-dev / posit-dev/chatlas

feat: Update and submit user value

Open
#32 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
176
Forks
28
Avg merge
18h 42m
Merged PRs (30d)
16

Description

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")

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the chat.chat_async("NEW_MSG") path and the Shiny UI integration around chat_ui.update_user_input and textarea#chat_user_input. Compare the current workaround with the desired behavior, then verify that programmatic user values update the UI and display the streaming response as if submitted interactively.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.