|
|
|
|
|
|
|
|
|
from h2o_wave import main, app, Q, ui, data |
|
|
|
|
|
MAX_MESSAGES = 500 |
|
|
|
|
|
@app('/demo') |
|
async def serve(q: Q): |
|
if not q.client.initialized: |
|
|
|
cyclic_buffer = data(fields='msg fromUser', size=-MAX_MESSAGES) |
|
q.page['example'] = ui.chatbot_card(box='1 1 5 5', data=cyclic_buffer, name='chatbot') |
|
q.page['meta'] = ui.meta_card(box='', theme='h2o-dark') |
|
q.client.initialized = True |
|
|
|
|
|
if q.args.chatbot: |
|
|
|
q.page['example'].data[-1] = [q.args.chatbot, True] |
|
|
|
q.page['example'].data[-1] = ['I am a fake chatbot. Sorry, I cannot help you.', False] |
|
|
|
await q.page.save() |
|
|