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

Make it easy to prompt user for input in ChatFeed #7148

Merged
merged 11 commits into from
Aug 22, 2024
Merged

Conversation

ahuang11
Copy link
Contributor

@ahuang11 ahuang11 commented Aug 15, 2024

image

Closes #7138

Inspired by https://discourse.holoviz.org/t/panel-chat-interface/7505?u=ahuang11

Wondering if the method should be renamed to simply prompt or prompt_user or require_input

Screen.Recording.2024-08-14.at.5.11.51.PM.mov
import panel as pn

pn.extension()


def prompt_callback(form, instance):
    instance.stream(f"I like {form.value} too!", user="Assistant")


async def callback(message, user, instance):
    if "ice cream" in message.lower():
        form = pn.widgets.TextInput(
            name="Favorite Ice Cream", placeholder="Enter your favorite ice cream"
        )
        instance.prompt_input(
            form, prompt_callback, predicate=lambda form: form.value
        )
        return
    return f"I don't care about {message}"


chat = pn.chat.ChatInterface(callback=callback)

chat.show()

I think this can also be generalized to allow editing existing ChatMessages.

Would like your feedback on this @MarcSkovMadsen and @philippjfr

@ahuang11 ahuang11 changed the title Initial implementation of prompting for input Make it easy to prompt for input in Chat Aug 15, 2024
panel/chat/feed.py Outdated Show resolved Hide resolved
panel/chat/feed.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 97.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.19%. Comparing base (45809a8) to head (69ca93c).
Report is 2 commits behind head on main.

Files Patch % Lines
panel/tests/chat/test_feed.py 96.55% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7148      +/-   ##
==========================================
+ Coverage   82.16%   82.19%   +0.03%     
==========================================
  Files         328      328              
  Lines       49075    49206     +131     
==========================================
+ Hits        40321    40446     +125     
- Misses       8754     8760       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

cdeil and others added 6 commits August 15, 2024 18:00
Bumps [ws](https://github.com/websockets/ws) from 8.17.0 to 8.18.0.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](websockets/ws@8.17.0...8.18.0)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@ahuang11
Copy link
Contributor Author

Screen.Recording.2024-08-16.at.10.02.16.PM.mov

@ahuang11 ahuang11 requested a review from philippjfr August 17, 2024 05:02
@ahuang11 ahuang11 changed the title Make it easy to prompt for input in Chat Make it easy to prompt user for input in ChatFeed Aug 17, 2024
@ahuang11 ahuang11 marked this pull request as ready for review August 17, 2024 05:02
panel/chat/feed.py Outdated Show resolved Hide resolved
@philippjfr philippjfr merged commit 3b0d8c2 into main Aug 22, 2024
16 checks passed
@philippjfr philippjfr deleted the prompt_input branch August 22, 2024 14:09
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

Successfully merging this pull request may close these issues.

ChatInterface prompt for user input method
3 participants