-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
94bf37f
commit 4a7237b
Showing
11 changed files
with
188 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Chatbot / Events/ Feedback | ||
# Use thumbs up/down to provide feedback on the chatbot response. | ||
# #chatbot #events #feedback | ||
# --- | ||
from h2o_wave import main, app, Q, ui, data | ||
|
||
@app('/demo') | ||
async def serve(q: Q): | ||
if not q.client.initialized: | ||
q.page['example'] = ui.chatbot_card( | ||
box='1 1 5 5', | ||
data=data(fields='content from_user', t='list'), | ||
name='chatbot', | ||
events=['feedback'] | ||
) | ||
q.page['feedback'] = ui.form_card( | ||
box='1 6 5 2', | ||
items=[ | ||
ui.text_xl('Feedback'), | ||
ui.text(name='text', content='No feedback yet.'), | ||
] | ||
) | ||
q.client.initialized = True | ||
|
||
if q.args.chatbot: | ||
# Append user message. | ||
q.page['example'].data += [q.args.chatbot, True] | ||
# Append bot response. | ||
q.page['example'].data += ['I am a fake chatbot. Sorry, I cannot help you.', False] | ||
# Handle feedback event. | ||
elif q.events.chatbot and q.events.chatbot.feedback: | ||
# Process the feedback. | ||
q.page['feedback'].text.content = f'{q.events.chatbot.feedback}' | ||
|
||
await q.page.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters