@headwai/chat-bubble 4.0.0 → 6.1.0-rc.publish-npm-package.df2535f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.dev.md +82 -25
- package/README.md +9 -38
- package/dist-widget/chat-bubble.js +85 -85
- package/package.json +2 -2
package/README.dev.md
CHANGED
|
@@ -15,7 +15,6 @@ The chat bubble is based on a Svelte integration for the [deep-chat](https://www
|
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
git clone <your-repo-url>
|
|
18
|
-
cd chat-bubble
|
|
19
18
|
```
|
|
20
19
|
|
|
21
20
|
2. Install dependencies:
|
|
@@ -61,9 +60,8 @@ Create a `.env` by copying `.env.example` file in your project root with the fol
|
|
|
61
60
|
<script>
|
|
62
61
|
// Runtime configuration override
|
|
63
62
|
window.HEADWAI_CHAT_BUBBLE_CONFIG = {
|
|
64
|
-
apiUrl: 'https://
|
|
65
|
-
|
|
66
|
-
modelId: 'gpt-4',
|
|
63
|
+
apiUrl: 'https://company.localchat.at',
|
|
64
|
+
assistantId: 'customer-support-assistant-id',
|
|
67
65
|
};
|
|
68
66
|
</script>
|
|
69
67
|
```
|
|
@@ -73,8 +71,7 @@ Create a `.env` by copying `.env.example` file in your project root with the fol
|
|
|
73
71
|
```html
|
|
74
72
|
<div
|
|
75
73
|
data-chat-bubble
|
|
76
|
-
data-chat-bubble-api-url="https://
|
|
77
|
-
data-chat-bubble-api-key="key1"
|
|
74
|
+
data-chat-bubble-api-url="https://company.localchat.at"
|
|
78
75
|
data-chat-bubble-user-message-background-color="#ff9500"
|
|
79
76
|
data-chat-bubble-ai-message-background-color="#00c851"
|
|
80
77
|
data-chat-bubble-user-message-text-color="#ffffff"
|
|
@@ -104,9 +101,8 @@ This project builds a standalone widget that can be integrated into any website.
|
|
|
104
101
|
|
|
105
102
|
```bash
|
|
106
103
|
# Production .env file
|
|
107
|
-
VITE_CHAT_BUBBLE_API_URL=https://
|
|
108
|
-
|
|
109
|
-
VITE_CHAT_BUBBLE_MODEL_ID=gpt-4
|
|
104
|
+
VITE_CHAT_BUBBLE_API_URL=https://company.localchat.at
|
|
105
|
+
VITE_CHAT_BUBBLE_ASSISTANT_ID=customer-support-assistant-id
|
|
110
106
|
```
|
|
111
107
|
|
|
112
108
|
2. **Bump package version**
|
|
@@ -164,7 +160,7 @@ The chat bubble makes requests to the following API endpoints:
|
|
|
164
160
|
|
|
165
161
|
#### 1. Chat Completions API
|
|
166
162
|
|
|
167
|
-
- **Endpoint**: `{apiUrl}/api/chat
|
|
163
|
+
- **Endpoint**: `{apiUrl}/api/chat/completions`
|
|
168
164
|
- **Method**: WebSocket (streaming)
|
|
169
165
|
- **Purpose**: Main chat conversation endpoint for sending messages and receiving AI responses
|
|
170
166
|
- **Authentication**: Bearer token via `Authorization` header
|
|
@@ -173,7 +169,7 @@ The chat bubble makes requests to the following API endpoints:
|
|
|
173
169
|
|
|
174
170
|
#### 2. Chat Creation API
|
|
175
171
|
|
|
176
|
-
- **Endpoint**: `{apiUrl}/api/
|
|
172
|
+
- **Endpoint**: `{apiUrl}/api/v1/chats/new`
|
|
177
173
|
- **Method**: POST
|
|
178
174
|
- **Purpose**: Create a new chat session when starting a conversation
|
|
179
175
|
- **Authentication**: Bearer token via `Authorization` header
|
|
@@ -181,7 +177,7 @@ The chat bubble makes requests to the following API endpoints:
|
|
|
181
177
|
|
|
182
178
|
#### 3. Chat Storage API
|
|
183
179
|
|
|
184
|
-
- **Endpoint**: `{apiUrl}/api/
|
|
180
|
+
- **Endpoint**: `{apiUrl}/api/v1/chats/{chatId}`
|
|
185
181
|
- **Method**: POST
|
|
186
182
|
- **Purpose**: Store/update chat history and conversation state
|
|
187
183
|
- **Authentication**: Bearer token via `Authorization` header
|
|
@@ -189,7 +185,7 @@ The chat bubble makes requests to the following API endpoints:
|
|
|
189
185
|
|
|
190
186
|
#### 4. Feedback API
|
|
191
187
|
|
|
192
|
-
- **Endpoint**: `{apiUrl}/api/
|
|
188
|
+
- **Endpoint**: `{apiUrl}/api/v1/evaluations/feedback`
|
|
193
189
|
- **Method**: POST
|
|
194
190
|
- **Purpose**: Submit user feedback (thumbs up/down) for AI responses
|
|
195
191
|
- **Authentication**: Bearer token via `Authorization` header
|
|
@@ -201,11 +197,10 @@ The chat bubble can be configured using environment variables, data attributes,
|
|
|
201
197
|
|
|
202
198
|
#### Core API Configuration
|
|
203
199
|
|
|
204
|
-
| Attribute
|
|
205
|
-
|
|
|
206
|
-
| `apiUrl`
|
|
207
|
-
| `
|
|
208
|
-
| `modelId` | `VITE_CHAT_BUBBLE_MODEL_ID` | `data-chat-bubble-model-id` | AI model identifier to use for responses | `test-model` |
|
|
200
|
+
| Attribute | Environment Variable | Data Attribute | Purpose | Default |
|
|
201
|
+
| ------------- | ------------------------------- | ------------------------------- | ----------------------------------------- | ------------------- |
|
|
202
|
+
| `apiUrl` | `VITE_CHAT_BUBBLE_API_URL` | `data-chat-bubble-api-url` | Base URL for API endpoints | `https://localhost` |
|
|
203
|
+
| `assistantId` | `VITE_CHAT_BUBBLE_ASSISTANT_ID` | `data-chat-bubble-assistant-id` | Assistant identifier to use for responses | `test-model` |
|
|
209
204
|
|
|
210
205
|
#### Message Configuration
|
|
211
206
|
|
|
@@ -248,7 +243,7 @@ The chat bubble can be configured using environment variables, data attributes,
|
|
|
248
243
|
"content": "message text"
|
|
249
244
|
}
|
|
250
245
|
],
|
|
251
|
-
"model": "
|
|
246
|
+
"model": "customer-support-assistant-id",
|
|
252
247
|
"stream": true,
|
|
253
248
|
"chat_id": "uuid-if-existing",
|
|
254
249
|
"params": {},
|
|
@@ -277,10 +272,11 @@ The chat bubble can be configured using environment variables, data attributes,
|
|
|
277
272
|
|
|
278
273
|
```javascript
|
|
279
274
|
{
|
|
275
|
+
"assistantId": "customer-support-assistant-id",
|
|
280
276
|
"chat": {
|
|
281
277
|
"id": "",
|
|
282
278
|
"title": "New Chatbubble Chat",
|
|
283
|
-
"models": ["
|
|
279
|
+
"models": ["customer-support-assistant-id"],
|
|
284
280
|
"params": {},
|
|
285
281
|
"history": {
|
|
286
282
|
"messages": {"message-id": {...}},
|
|
@@ -293,7 +289,7 @@ The chat bubble can be configured using environment variables, data attributes,
|
|
|
293
289
|
"role": "assistant|user",
|
|
294
290
|
"content": "message content",
|
|
295
291
|
"timestamp": 1704636645,
|
|
296
|
-
"models": ["
|
|
292
|
+
"models": ["customer-support-assistant-id"]
|
|
297
293
|
}],
|
|
298
294
|
"tags": [],
|
|
299
295
|
"timestamp": 1704636645000
|
|
@@ -302,21 +298,83 @@ The chat bubble can be configured using environment variables, data attributes,
|
|
|
302
298
|
}
|
|
303
299
|
```
|
|
304
300
|
|
|
301
|
+
#### Chat Storage Request
|
|
302
|
+
|
|
303
|
+
```javascript
|
|
304
|
+
{
|
|
305
|
+
"assistantId": "customer-support-assistant-id",
|
|
306
|
+
"chat": {
|
|
307
|
+
"models": ["customer-support-assistant-id"],
|
|
308
|
+
"history": {
|
|
309
|
+
"messages": {
|
|
310
|
+
"message-uuid-1": {
|
|
311
|
+
"id": "message-uuid-1",
|
|
312
|
+
"parentId": null,
|
|
313
|
+
"childrenIds": ["message-uuid-2"],
|
|
314
|
+
"role": "user",
|
|
315
|
+
"content": "user message content",
|
|
316
|
+
"timestamp": 1704636645,
|
|
317
|
+
"models": ["customer-support-assistant-id"]
|
|
318
|
+
},
|
|
319
|
+
"message-uuid-2": {
|
|
320
|
+
"id": "message-uuid-2",
|
|
321
|
+
"parentId": "message-uuid-1",
|
|
322
|
+
"childrenIds": [],
|
|
323
|
+
"role": "assistant",
|
|
324
|
+
"content": "assistant response content",
|
|
325
|
+
"model": "customer-support-assistant-id",
|
|
326
|
+
"modelId": "customer-support-assistant-id",
|
|
327
|
+
"modelIdx": 0,
|
|
328
|
+
"timestamp": 1704636645,
|
|
329
|
+
"sources": []
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
"currentId": "message-uuid-2"
|
|
333
|
+
},
|
|
334
|
+
"messages": [
|
|
335
|
+
{
|
|
336
|
+
"id": "message-uuid-1",
|
|
337
|
+
"parentId": null,
|
|
338
|
+
"childrenIds": ["message-uuid-2"],
|
|
339
|
+
"role": "user",
|
|
340
|
+
"content": "user message content",
|
|
341
|
+
"timestamp": 1704636645,
|
|
342
|
+
"models": ["customer-support-assistant-id"]
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"id": "message-uuid-2",
|
|
346
|
+
"parentId": "message-uuid-1",
|
|
347
|
+
"childrenIds": [],
|
|
348
|
+
"role": "assistant",
|
|
349
|
+
"content": "assistant response content",
|
|
350
|
+
"model": "customer-support-assistant-id",
|
|
351
|
+
"modelId": "customer-support-assistant-id",
|
|
352
|
+
"modelIdx": 0,
|
|
353
|
+
"timestamp": 1704636645,
|
|
354
|
+
"sources": []
|
|
355
|
+
}
|
|
356
|
+
],
|
|
357
|
+
"params": {}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
305
362
|
#### Feedback Request
|
|
306
363
|
|
|
307
364
|
```javascript
|
|
308
365
|
{
|
|
366
|
+
"assistantId": "customer-support-assistant-id",
|
|
309
367
|
"type": "rating",
|
|
310
368
|
"data": {
|
|
311
369
|
"rating": 1, // 1 for positive, -1 for negative
|
|
312
|
-
"model_id": "
|
|
370
|
+
"model_id": "customer-support-assistant-id"
|
|
313
371
|
},
|
|
314
372
|
"meta": {
|
|
315
|
-
"model_id": "
|
|
373
|
+
"model_id": "customer-support-assistant-id",
|
|
316
374
|
"message_id": "message-uuid",
|
|
317
375
|
"message_index": 2,
|
|
318
376
|
"chat_id": "chat-uuid",
|
|
319
|
-
"base_models": {"
|
|
377
|
+
"base_models": {"customer-support-assistant-id": "customer-support-assistant-id"}
|
|
320
378
|
},
|
|
321
379
|
"snapshot": {
|
|
322
380
|
"chat": {
|
|
@@ -352,7 +410,6 @@ This component is designed to work with OpenAI-compatible APIs. The request and
|
|
|
352
410
|
### Common Issues
|
|
353
411
|
|
|
354
412
|
**CORS Errors**: Ensure your API endpoint allows requests from your domain
|
|
355
|
-
**Authentication Failures**: Verify your API key is correct and has proper permissions
|
|
356
413
|
**Environment Variables Not Loading**: Ensure variables are prefixed with `VITE_CHAT_BUBBLE_`
|
|
357
414
|
**CDN Version Delays**: Sometimes the `@latest` tag on jsDelivr CDN takes time to propagate to all edge servers and may not deliver the newest version immediately. If you need the latest features or fixes, specify the exact version number instead of using `@latest`:
|
|
358
415
|
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
## Features
|
|
4
4
|
|
|
5
5
|
- 🚀 Easy integration
|
|
6
|
-
- 💬 Connect to any LocalChat
|
|
6
|
+
- 💬 Connect to any LocalChat Assistant
|
|
7
7
|
- 📋 Review conversations in LocalChat
|
|
8
8
|
- 📱 Responsive design
|
|
9
9
|
- 🎨 Customizable UI components
|
|
@@ -23,8 +23,7 @@ Add the Headwai Chat Bubble to the respective .html file.
|
|
|
23
23
|
// Runtime configuration override
|
|
24
24
|
window.HEADWAI_CHAT_BUBBLE_CONFIG = {
|
|
25
25
|
apiUrl: 'https://company.localchat.at', // required
|
|
26
|
-
|
|
27
|
-
modelId: 'customer-support-model-id', // required
|
|
26
|
+
assistantId: 'customer-support-assistant-id', // required
|
|
28
27
|
maxMessages: 0, // optional - 0 means unlimited
|
|
29
28
|
placeholderText: 'Ask your question here!', // optional - default: 'Enter your questions here'
|
|
30
29
|
faviconPath: 'https://cdn.company.at/icons/favicon.svg', // optional - default: '/icons/favicon.svg'
|
|
@@ -86,8 +85,7 @@ For multiple instances use data attributes of the `<div>` tag for configuration
|
|
|
86
85
|
<div
|
|
87
86
|
data-chat-bubble
|
|
88
87
|
data-chat-bubble-api-url="https://company.localchat.at"
|
|
89
|
-
data-chat-bubble-
|
|
90
|
-
data-chat-bubble-model-id="customer-support-model-id"
|
|
88
|
+
data-chat-bubble-assistant-id="customer-support-assistant-id"
|
|
91
89
|
data-chat-bubble-max-messages="0"
|
|
92
90
|
data-chat-bubble-placeholder-text="Ask your question here!"
|
|
93
91
|
data-chat-bubble-favicon-path="https://cdn.company.at/icons/favicon.svg"
|
|
@@ -106,8 +104,7 @@ For multiple instances use data attributes of the `<div>` tag for configuration
|
|
|
106
104
|
<div
|
|
107
105
|
data-chat-bubble
|
|
108
106
|
data-chat-bubble-api-url="https://company.localchat.at"
|
|
109
|
-
data-chat-bubble-
|
|
110
|
-
data-chat-bubble-model-id="FAQ-model-id"
|
|
107
|
+
data-chat-bubble-assistant-id="faq-assistant-id"
|
|
111
108
|
data-chat-bubble-max-messages="10"
|
|
112
109
|
data-chat-bubble-placeholder-text="Ask about our FAQ..."
|
|
113
110
|
data-chat-bubble-favicon-path="https://cdn.company.at/icons/faq-icon.svg"
|
|
@@ -144,45 +141,20 @@ The base URL of your LocalChat API endpoint where the chat bubble will send mess
|
|
|
144
141
|
apiUrl: 'https://company.localchat.at';
|
|
145
142
|
```
|
|
146
143
|
|
|
147
|
-
#### `
|
|
144
|
+
#### `assistantId`
|
|
148
145
|
|
|
149
146
|
**Type:** `string` | **Required:** ✅
|
|
150
|
-
The
|
|
147
|
+
The identifier of the AI assistant to use for generating responses. This should match an assistant configured in your LocalChat instance.
|
|
151
148
|
|
|
152
149
|
```javascript
|
|
153
|
-
|
|
150
|
+
assistantId: 'customer-support-assistant-id';
|
|
154
151
|
```
|
|
155
152
|
|
|
156
|
-
**
|
|
157
|
-
|
|
158
|
-
1. **Access Settings**: Login to LocalChat with the dedicated Headwai Chat Bubble user (All conversations will be stored at this user's chats list) and click on the user menu, then select `Settings`.
|
|
159
|
-
|
|
160
|
-
<img src="docs/images/settings.png" alt="LocalChat User Menu" width="50%" />
|
|
161
|
-
|
|
162
|
-
2. **Navigate to Account**: In the Settings sidebar, click on `Account` to access your account settings.
|
|
163
|
-
|
|
164
|
-
<img src="docs/images/api-keys.png" alt="LocalChat Settings Account" width="50%" />
|
|
165
|
-
|
|
166
|
-
3. **Get your API credentials**: In the API keys section, you have two options:
|
|
167
|
-
- **JWT Token**: Copy the existing JWT Token (expires after 7 days)
|
|
168
|
-
- **API Key**: Generate an API Key via `Generate API Key` button. Click the copy button next to the API Key field, or click the refresh button to generate a new permanent API Key
|
|
169
|
-
|
|
170
|
-
**⚠️ Security Note:** When using permanent API Keys, ensure they are stored securely (e.g., environment variables, secure configuration) and never expose them directly in client-side code. If using JWT Tokens, implement an automatic refresh mechanism since they expire after 7 days - consider using a server-side proxy to handle token renewal and keep tokens secure.
|
|
171
|
-
|
|
172
|
-
#### `modelId`
|
|
173
|
-
|
|
174
|
-
**Type:** `string` | **Required:** ✅
|
|
175
|
-
The identifier of the AI model to use for generating responses. This should match a model configured in your LocalChat instance.
|
|
176
|
-
|
|
177
|
-
```javascript
|
|
178
|
-
modelId: 'customer-support-model-id';
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
1. **Navigate to Model**: Login to LocalChat with the dedicated Headwai Chat Bubble user (Or any other user that is allowed to see the desired model) and click on the `Workspace` menu, then select `Models`. Search for the name of the desired model (Or create one). Click onto the edit-`Pen`.
|
|
153
|
+
1. **Navigate to Assistant**: Login to LocalChat with the dedicated Headwai Chat Bubble user (Or any other user that is allowed to see the desired assistant) and click on the `Workspace` menu, then select `Assistants`. Search for the name of the desired assistant (Or create one). Click onto the edit-`Pen`.
|
|
182
154
|
|
|
183
155
|
<img src="docs/images/model-edit.png" alt="LocalChat User Menu" width="50%" />
|
|
184
156
|
|
|
185
|
-
1. **Copy
|
|
157
|
+
1. **Copy Assistant Id**: Now the assistant is displayed with its `name` and right underneath the `assistant-id`. Copy the `assistant-id`.
|
|
186
158
|
|
|
187
159
|
<img src="docs/images/model-id.png" alt="LocalChat User Menu" width="50%" />
|
|
188
160
|
|
|
@@ -338,7 +310,6 @@ When using data attributes for multiple chat bubbles, convert camelCase property
|
|
|
338
310
|
### Common Issues
|
|
339
311
|
|
|
340
312
|
**CORS Errors**: Ensure your API endpoint allows requests from your domain
|
|
341
|
-
**Authentication Failures**: Verify your API key is correct and has proper permissions
|
|
342
313
|
**CDN Version Delays**: Sometimes the `@latest` tag on jsDelivr CDN takes time to propagate to all edge servers and may not deliver the newest version immediately. If you need the latest features or fixes, specify the exact version number instead of using `@latest`:
|
|
343
314
|
|
|
344
315
|
```html
|