diff options
| author | Agando <roduccomm@gmail.com> | 2026-11-09 15:02:17 +0100 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-11-09 15:02:17 +0100 |
| commit | ba15e7a4bf9dc4ab6b312f40c2e0199d4e5a8255 (patch) | |
| tree | 0f834eb7b76b2eefd4c61dae50231c6c1c4385e7 /src/config.example.js | |
feat(chat-widget): shippable widget package replacing the demo as the paid download
The store sold a €149 package whose download_url was the sales demo page. This is the widget
alone: 601 lines, no CDN, no operator host, no model name, config extracted to config.example.js,
wx- prefixed ids so embeds cannot collide. Verified in headless Chromium against a mock gateway
(streaming, chips, link detection, unconfigured state).
Diffstat (limited to 'src/config.example.js')
| -rw-r--r-- | src/config.example.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/config.example.js b/src/config.example.js new file mode 100644 index 0000000..84d2a01 --- /dev/null +++ b/src/config.example.js @@ -0,0 +1,70 @@ +/* ========================================================================== + * WebX11 Chat Widget — configuration + * -------------------------------------------------------------------------- + * Copy this file to `config.js` next to widget.html and edit the values. + * Everything is optional except `endpoint`. + * + * ABOUT THE ENDPOINT + * `endpoint` must be YOUR OWN gateway, i.e. an HTTP URL on your server that + * forwards the request to your model backend (Ollama, an Ollama-compatible + * API, or your own proxy) and adds your API key server-side. + * + * The widget runs in the visitor's browser, so anything you put in this + * file is public. NEVER put an API key, token or password here — not in + * this example file, not in your config.js, not in widget.html. Keep the + * key on the server (environment variable, secrets file, systemd unit) + * and let the gateway attach it to the upstream request. + * + * The endpoint must also allow your website's origin (CORS). See + * docs/USAGE.md → Troubleshooting. + * ========================================================================== */ + +window.WX_WIDGET_CONFIG = { + + /* Base URL of your gateway: protocol + host + the path prefix your proxy + * exposes, e.g. 'https://YOUR-HOST/ollama'. The widget appends + * '/api/generate' for you. If you prefer, give the full generate URL + * ('https://YOUR-HOST/ollama/api/generate') and it is used as-is. + * A relative path such as '/ollama' works when the widget is served from + * the same origin as the gateway. */ + endpoint: 'https://YOUR-HOST/ollama', + + /* Model name as your backend knows it. Ollama tags look like + * 'llama3.2:latest'. This is a public identifier, not a secret. */ + model: 'llama3.2:latest', + + /* Header and greeting */ + title: 'Chat with us', + welcomeMessage: 'Hi! How can I help you today?', + inputPlaceholder: 'Type your message…', + + /* Brand colour (any #rgb or #rrggbb). Text on the accent colour is + * switched between dark and light automatically. */ + accentColor: '#00e5a0', + + /* 'right' (default) or 'left' */ + position: 'right', + + /* Show the "Model: …" line under the header. Set to false to hide it. */ + statusLine: true, + + /* The assistant's instructions. Write this for your own business. */ + systemPrompt: + 'You are a helpful assistant for this website. ' + + 'Answer briefly and accurately. If you do not know something, say so ' + + 'and suggest contacting the site owner.', + + /* Optional: load the system prompt from a plain-text URL instead of the + * inline string above. Leave empty to use systemPrompt. */ + promptUrl: '', + promptVersion: '', + + /* Prepended to the visitor's message before it is sent. */ + questionPrefix: 'User Question:', + + /* Quick-reply buttons: [label, message sent when clicked] */ + chips: [ + ['What do you offer?', 'What do you offer?'], + ['Contact', 'How can I contact you?'] + ] +}; |