This assistant runs entirely in the browser - a sendRequest callback streams a canned reply token by token. Try the starter prompts, ask for a code example to see the copy button, and press the button while it is typing to test stop generation.

jQuery Chat: Mock Assistant

jqxChat streaming UI shown with an offline mock backend (no API key needed).

A live JavaScript/jQuery example of jqxChat, the jQWidgets Chat component, with its complete source code below. It is one of 5 jqxChat demos for jQuery.

jqxChat API used in this demo

Source code

To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $.

The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxchat.js.

It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers), mockassistant.js.

script.js

$(document).ready(function () {
    // No apiKey / proxyUrl: a "sendRequest" callback drives everything
    // locally. jqxChatMock (mockassistant.js) streams a canned reply
    // via widget.appendDelta(), so the full UI works with no network.
    $('#chat').jqxChat({
        colorScheme: 'auto',
        theme: 'light',
        width: 460,
        height: 620,
        title: 'Demo Assistant',
        subtitle: 'Offline - no API key required',
        welcomeMessage: 'Ask me anything about **jQWidgets**, or pick a suggestion below.',
        starterPrompts: [
            'What is jQWidgets?',
            'Show me a code example',
            'How does markdown rendering work?',
            'Tell me about theming'
        ],
        sendRequest: jqxChatMock
    });
});

body.html

<p class="hint">
    This assistant runs <strong>entirely in the browser</strong> - a <code>sendRequest</code> callback streams a
    canned reply token by token. Try the starter prompts, ask for a code example to see the copy button, and press
    the button while it is typing to test <strong>stop generation</strong>.
</p>
<div id="chat"></div>

More jQuery Chat demos