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.
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.
colorScheme property – Sets or gets the colour scheme of the chat.height property – Sets or gets the chat's height.proxyUrl property – Sets or gets a URL to POST the request to instead of calling the provider directly.sendRequest property – Sets or gets a callback that fully controls transport: function(payload, widget) .starterPrompts property – Sets or gets an array of suggested prompt strings displayed as clickable chips when the conversation is empty.subtitle property – Sets or gets the header subtitle text shown under the title.theme property – Sets the widget's theme.title property – Sets or gets the header title text (also used as the popup launcher tooltip).welcomeMessage property – Sets or gets the welcome text (Markdown supported) shown in the empty state above the starter prompts.width property – Sets or gets the chat's width.appendDelta method – Appends a chunk of streamed text into the current assistant bubble.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.
$(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
});
});
<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>