@headwai/chat-bubble 6.1.0 → 6.3.0
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 +673 -14
- package/dist-widget/chat-bubble.js +85 -131
- package/package.json +3 -3
package/README.dev.md
CHANGED
|
@@ -106,7 +106,22 @@ VITE_CHAT_BUBBLE_ASSISTANT_ID=customer-support-assistant-id
|
|
|
106
106
|
```
|
|
107
107
|
|
|
108
108
|
2. **Bump package version**
|
|
109
|
-
|
|
109
|
+
|
|
110
|
+
Use npm's built-in version command which automatically updates `package.json`, `package-lock.json`, creates a git commit, and tags the release:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Patch version bump (e.g., 6.3.0 -> 6.3.1)
|
|
114
|
+
npm version patch
|
|
115
|
+
|
|
116
|
+
# Minor version bump (e.g., 6.3.0 -> 6.4.0)
|
|
117
|
+
npm version minor
|
|
118
|
+
|
|
119
|
+
# Major version bump (e.g., 6.3.0 -> 7.0.0)
|
|
120
|
+
npm version major
|
|
121
|
+
|
|
122
|
+
# Specific version
|
|
123
|
+
npm version 6.4.0
|
|
124
|
+
```
|
|
110
125
|
|
|
111
126
|
## Publishing to NPM and jsDelivr Access
|
|
112
127
|
|
|
@@ -154,42 +169,682 @@ Once published to NPM, your package is automatically available on jsDelivr:
|
|
|
154
169
|
|
|
155
170
|
## API Reference
|
|
156
171
|
|
|
172
|
+
### Workflow
|
|
173
|
+
|
|
174
|
+
#### Chat
|
|
175
|
+
|
|
176
|
+
1. Create a new chat by calling the Chat Creation API
|
|
177
|
+
2. Use the chatId from the response in the request of the Chat Completions API
|
|
178
|
+
3. Store the messages from the Chat Completions API via the Chat Storage API
|
|
179
|
+
|
|
180
|
+
#### Feedback
|
|
181
|
+
|
|
182
|
+
1. Give feedback by calling the Feedback API
|
|
183
|
+
2. Add the feedback in the Chat Storage API
|
|
184
|
+
|
|
157
185
|
### APIs Called
|
|
158
186
|
|
|
159
187
|
The chat bubble makes requests to the following API endpoints:
|
|
160
188
|
|
|
161
|
-
#### 1. Chat
|
|
189
|
+
#### 1. Chat Creation API
|
|
190
|
+
|
|
191
|
+
- **Endpoint**: `{apiUrl}/api/v1/chats/new`
|
|
192
|
+
- **Method**: POST
|
|
193
|
+
- **Purpose**: Create a new chat session when starting a conversation
|
|
194
|
+
- **Header**:
|
|
195
|
+
The value of the Origin header must include the a white listed domain in the `Publish Model` configuration.
|
|
196
|
+
|
|
197
|
+
Origin: http://localhost:5174
|
|
198
|
+
|
|
199
|
+
##### Create new chat
|
|
200
|
+
|
|
201
|
+
For a brand new chat without any initial messages and the a with the title New Chat
|
|
202
|
+
|
|
203
|
+
- **Request Body**:
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
{
|
|
207
|
+
"assistantId": "customer-support-assistant-id",
|
|
208
|
+
"chat": {
|
|
209
|
+
},
|
|
210
|
+
"folder_id": null
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
- **Response Body**:
|
|
215
|
+
|
|
216
|
+
```javascript
|
|
217
|
+
{
|
|
218
|
+
"id": "3cd6f38c-effc-4038-948a-4fd345ea19b1", //chatId
|
|
219
|
+
"user_id": "e12c1cb7-f768-42a5-bb45-59846d2406fa",
|
|
220
|
+
"title": "New Chat",
|
|
221
|
+
"chat": {},
|
|
222
|
+
"updated_at": 1760361654,
|
|
223
|
+
"created_at": 1760361654,
|
|
224
|
+
"share_id": null,
|
|
225
|
+
"archived": false,
|
|
226
|
+
"pinned": false,
|
|
227
|
+
"meta": {},
|
|
228
|
+
"folder_id": null
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
##### Create new chat with inital message and title
|
|
233
|
+
|
|
234
|
+
- **Request Body**:
|
|
235
|
+
|
|
236
|
+
```javascript
|
|
237
|
+
{
|
|
238
|
+
"assistantId": "customer-support-assistant-id",
|
|
239
|
+
"chat": {
|
|
240
|
+
"id": "",
|
|
241
|
+
"title": "New Chatbubble Chat", // Choose Title
|
|
242
|
+
"models": [
|
|
243
|
+
"customer-support-assistant-id"
|
|
244
|
+
],
|
|
245
|
+
"params": {},
|
|
246
|
+
"history": {
|
|
247
|
+
"messages": {
|
|
248
|
+
"f55b5f5e-d3be-4bb3-8afc-cc3d322ef70f": {
|
|
249
|
+
"id": "f55b5f5e-d3be-4bb3-8afc-cc3d322ef70f",
|
|
250
|
+
"parentId": null,
|
|
251
|
+
"childrenIds": [],
|
|
252
|
+
"role": "assistant",
|
|
253
|
+
"content": "Hey, how can I help you?",
|
|
254
|
+
"timestamp": 1760360854,
|
|
255
|
+
"models": [
|
|
256
|
+
"customer-support-assistant-id"
|
|
257
|
+
],
|
|
258
|
+
"model": "customer-support-assistant-id",
|
|
259
|
+
"modelId": "customer-support-assistant-id",
|
|
260
|
+
"modelIdx": 0
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
"currentId": "f55b5f5e-d3be-4bb3-8afc-cc3d322ef70f"
|
|
264
|
+
},
|
|
265
|
+
"messages": [
|
|
266
|
+
{
|
|
267
|
+
"id": "f55b5f5e-d3be-4bb3-8afc-cc3d322ef70f",
|
|
268
|
+
"parentId": null,
|
|
269
|
+
"childrenIds": [],
|
|
270
|
+
"role": "assistant",
|
|
271
|
+
"content": "Hey, how can I help you?",
|
|
272
|
+
"timestamp": 1760360854,
|
|
273
|
+
"models": [
|
|
274
|
+
"customer-support-assistant-id"
|
|
275
|
+
],
|
|
276
|
+
"model": "customer-support-assistant-id",
|
|
277
|
+
"modelId": "customer-support-assistant-id",
|
|
278
|
+
"modelIdx": 0
|
|
279
|
+
}
|
|
280
|
+
],
|
|
281
|
+
"tags": [],
|
|
282
|
+
"timestamp": 1760360854542
|
|
283
|
+
},
|
|
284
|
+
"folder_id": null
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
- **Response Body**:
|
|
290
|
+
|
|
291
|
+
```javascript
|
|
292
|
+
{
|
|
293
|
+
"id": "1e09dc64-f984-4859-90dd-5552fa8047f7", //chatId
|
|
294
|
+
"user_id": "e12c1cb7-f768-42a5-bb45-59846d2406fa",
|
|
295
|
+
"title": "New Chatbubble Chat",
|
|
296
|
+
"chat": {
|
|
297
|
+
"id": "",
|
|
298
|
+
"title": "New Chatbubble Chat",
|
|
299
|
+
"models": [
|
|
300
|
+
"customer-support-assistant-id"
|
|
301
|
+
],
|
|
302
|
+
"params": {},
|
|
303
|
+
"history": {
|
|
304
|
+
"messages": {
|
|
305
|
+
"f55b5f5e-d3be-4bb3-8afc-cc3d322ef70f": {
|
|
306
|
+
"id": "f55b5f5e-d3be-4bb3-8afc-cc3d322ef70f",
|
|
307
|
+
"parentId": null,
|
|
308
|
+
"childrenIds": [],
|
|
309
|
+
"role": "assistant",
|
|
310
|
+
"content": "Hey, how can I help you?",
|
|
311
|
+
"timestamp": 1760360854,
|
|
312
|
+
"models": [
|
|
313
|
+
"customer-support-assistant-id"
|
|
314
|
+
],
|
|
315
|
+
"model": "customer-support-assistant-id",
|
|
316
|
+
"modelId": "customer-support-assistant-id",
|
|
317
|
+
"modelIdx": 0
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
"currentId": "f55b5f5e-d3be-4bb3-8afc-cc3d322ef70f"
|
|
321
|
+
},
|
|
322
|
+
"messages": [
|
|
323
|
+
{
|
|
324
|
+
"id": "f55b5f5e-d3be-4bb3-8afc-cc3d322ef70f",
|
|
325
|
+
"parentId": null,
|
|
326
|
+
"childrenIds": [],
|
|
327
|
+
"role": "assistant",
|
|
328
|
+
"content": "Hey, how can I help you?",
|
|
329
|
+
"timestamp": 1760360854,
|
|
330
|
+
"models": [
|
|
331
|
+
"customer-support-assistant-id"
|
|
332
|
+
],
|
|
333
|
+
"model": "customer-support-assistant-id",
|
|
334
|
+
"modelId": "customer-support-assistant-id",
|
|
335
|
+
"modelIdx": 0
|
|
336
|
+
}
|
|
337
|
+
],
|
|
338
|
+
"tags": [],
|
|
339
|
+
"timestamp": 1760360854542
|
|
340
|
+
},
|
|
341
|
+
"updated_at": 1760360854,
|
|
342
|
+
"created_at": 1760360854,
|
|
343
|
+
"share_id": null,
|
|
344
|
+
"archived": false,
|
|
345
|
+
"pinned": false,
|
|
346
|
+
"meta": {},
|
|
347
|
+
"folder_id": null
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
#### 2. Chat Completions API
|
|
162
352
|
|
|
163
353
|
- **Endpoint**: `{apiUrl}/api/chat/completions`
|
|
164
354
|
- **Method**: WebSocket (streaming)
|
|
165
355
|
- **Purpose**: Main chat conversation endpoint for sending messages and receiving AI responses
|
|
166
|
-
- **
|
|
167
|
-
|
|
356
|
+
- **Header**:
|
|
357
|
+
The value of the Origin header must include the a white listed domain in the `Publish Assistant` configuration.
|
|
358
|
+
|
|
359
|
+
Origin: http://localhost:5174
|
|
360
|
+
|
|
361
|
+
- **Request Format**:
|
|
362
|
+
|
|
363
|
+
```javascript
|
|
364
|
+
{
|
|
365
|
+
"messages": [ // whole message history
|
|
366
|
+
{
|
|
367
|
+
"role": "user", // user|assistant
|
|
368
|
+
"content": "how are you"
|
|
369
|
+
}
|
|
370
|
+
],
|
|
371
|
+
"model": "customer-support-assistant-id",
|
|
372
|
+
"stream": true, // false for a non streaming answer
|
|
373
|
+
"variables": { // optional
|
|
374
|
+
"{{USER_NAME}}": "David Schneebauer | headwAI GmbH",
|
|
375
|
+
"{{USER_LOCATION}}": "Unknown",
|
|
376
|
+
"{{CURRENT_DATETIME}}": "2025-10-13 13:07:34",
|
|
377
|
+
"{{CURRENT_DATE}}": "2025-10-13",
|
|
378
|
+
"{{CURRENT_TIME}}": "14:07:34",
|
|
379
|
+
"{{CURRENT_WEEKDAY}}": "Monday",
|
|
380
|
+
"{{CURRENT_TIMEZONE}}": "Europe/Lisbon",
|
|
381
|
+
"{{USER_LANGUAGE}}": "en-GB"
|
|
382
|
+
},
|
|
383
|
+
"chat_id": "3cd6f38c-effc-4038-948a-4fd345ea19b1"
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
```
|
|
387
|
+
|
|
168
388
|
- **Response Format**: Server-sent events with OpenAI-compatible streaming format
|
|
169
389
|
|
|
170
|
-
|
|
390
|
+
##### Streaming
|
|
171
391
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
-
|
|
392
|
+
Many chunks (objects like this) are returned, until the `[DONE]` message is sent. The content in `choices.delta.content` needs to be saved and concatenated with content of previous chunks.
|
|
393
|
+
|
|
394
|
+
```javascript
|
|
395
|
+
{
|
|
396
|
+
"id": "chatcmpl-CQTfHBjGODmuDFi1WpPSSePX0kl23",
|
|
397
|
+
"object": "chat.completion.chunk",
|
|
398
|
+
"created": 1760426595,
|
|
399
|
+
"model": "gpt-4-0613",
|
|
400
|
+
"service_tier": "default",
|
|
401
|
+
"system_fingerprint": null,
|
|
402
|
+
"choices": [
|
|
403
|
+
{
|
|
404
|
+
"index": 0,
|
|
405
|
+
"delta": {
|
|
406
|
+
"content": " feelings"
|
|
407
|
+
},
|
|
408
|
+
"logprobs": null,
|
|
409
|
+
"finish_reason": null
|
|
410
|
+
}
|
|
411
|
+
],
|
|
412
|
+
"obfuscation": "8ducrYPe"
|
|
413
|
+
}
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
##### Non Streaming
|
|
417
|
+
|
|
418
|
+
The content is returned in `choices.message.content` as a whole
|
|
419
|
+
|
|
420
|
+
```javascript
|
|
421
|
+
{
|
|
422
|
+
"id": "chatcmpl-CQDZLxuep7oEuWBqIvOdw2j7fk8G4",
|
|
423
|
+
"object": "chat.completion",
|
|
424
|
+
"created": 1760364723,
|
|
425
|
+
"model": "gpt-4-0613",
|
|
426
|
+
"choices": [
|
|
427
|
+
{
|
|
428
|
+
"index": 0,
|
|
429
|
+
"message": {
|
|
430
|
+
"role": "assistant",
|
|
431
|
+
"content": "As an AI, I don't have feelings, but I'm here and ready to assist you. How can I help you today?",
|
|
432
|
+
"refusal": null,
|
|
433
|
+
"annotations": []
|
|
434
|
+
},
|
|
435
|
+
"logprobs": null,
|
|
436
|
+
"finish_reason": "stop"
|
|
437
|
+
}
|
|
438
|
+
],
|
|
439
|
+
"usage": {
|
|
440
|
+
"prompt_tokens": 21,
|
|
441
|
+
"completion_tokens": 39,
|
|
442
|
+
"total_tokens": 60,
|
|
443
|
+
"prompt_tokens_details": {
|
|
444
|
+
"cached_tokens": 0,
|
|
445
|
+
"audio_tokens": 0
|
|
446
|
+
},
|
|
447
|
+
"completion_tokens_details": {
|
|
448
|
+
"reasoning_tokens": 0,
|
|
449
|
+
"audio_tokens": 0,
|
|
450
|
+
"accepted_prediction_tokens": 0,
|
|
451
|
+
"rejected_prediction_tokens": 0
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
"service_tier": "default",
|
|
455
|
+
"system_fingerprint": null
|
|
456
|
+
}
|
|
457
|
+
```
|
|
177
458
|
|
|
178
459
|
#### 3. Chat Storage API
|
|
179
460
|
|
|
180
461
|
- **Endpoint**: `{apiUrl}/api/v1/chats/{chatId}`
|
|
181
462
|
- **Method**: POST
|
|
182
463
|
- **Purpose**: Store/update chat history and conversation state
|
|
183
|
-
- **
|
|
184
|
-
|
|
464
|
+
- **Header**:
|
|
465
|
+
The value of the Origin header must include the a white listed domain in the `Publish Assistant` configuration.
|
|
466
|
+
|
|
467
|
+
Origin: http://localhost:5174
|
|
468
|
+
|
|
469
|
+
- **Request Body**:
|
|
470
|
+
|
|
471
|
+
```javascript
|
|
472
|
+
{
|
|
473
|
+
"assistantId": "customer-support-assistant-id",
|
|
474
|
+
"chat": {
|
|
475
|
+
"models": [
|
|
476
|
+
"customer-support-assistant-id"
|
|
477
|
+
],
|
|
478
|
+
"history": {
|
|
479
|
+
"messages": {
|
|
480
|
+
"2860fdae-4c43-4f59-8217-33dfc92b47d3": {
|
|
481
|
+
"id": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
482
|
+
"parentId": null,
|
|
483
|
+
"childrenIds": [
|
|
484
|
+
"29948ec6-6975-4d3a-b019-ceb8b7f7c698"
|
|
485
|
+
],
|
|
486
|
+
"role": "user",
|
|
487
|
+
"content": "how are you",
|
|
488
|
+
"timestamp": 1760362655,
|
|
489
|
+
"models": [
|
|
490
|
+
"customer-support-assistant-id"
|
|
491
|
+
]
|
|
492
|
+
},
|
|
493
|
+
"29948ec6-6975-4d3a-b019-ceb8b7f7c698": {
|
|
494
|
+
"annotation": { // add only after giving feedback
|
|
495
|
+
"rating": 1 // 1 for postive, -1 for negative
|
|
496
|
+
},
|
|
497
|
+
"id": "29948ec6-6975-4d3a-b019-ceb8b7f7c698",
|
|
498
|
+
"parentId": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
499
|
+
"childrenIds": [],
|
|
500
|
+
"role": "assistant",
|
|
501
|
+
"content": "As an AI, I don't have feelings, but I'm here and ready to assist you. How can I help you today?",
|
|
502
|
+
"model": "customer-support-assistant-id",
|
|
503
|
+
"modelId": "customer-support-assistant-id",
|
|
504
|
+
"modelIdx": 0,
|
|
505
|
+
"timestamp": 1760362655,
|
|
506
|
+
"sources": []
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
"currentId": "29948ec6-6975-4d3a-b019-ceb8b7f7c698"
|
|
510
|
+
},
|
|
511
|
+
"messages": [
|
|
512
|
+
{
|
|
513
|
+
"id": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
514
|
+
"parentId": "f55b5f5e-d3be-4bb3-8afc-cc3d322ef70f",
|
|
515
|
+
"childrenIds": [
|
|
516
|
+
"29948ec6-6975-4d3a-b019-ceb8b7f7c698"
|
|
517
|
+
],
|
|
518
|
+
"role": "user",
|
|
519
|
+
"content": "how are you",
|
|
520
|
+
"timestamp": 1760362655,
|
|
521
|
+
"models": [
|
|
522
|
+
"customer-support-assistant-id"
|
|
523
|
+
]
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
"annotation": { // add only after giving feedback
|
|
527
|
+
"rating": 1 // 1 for postive, -1 for negative
|
|
528
|
+
},
|
|
529
|
+
"id": "29948ec6-6975-4d3a-b019-ceb8b7f7c698",
|
|
530
|
+
"parentId": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
531
|
+
"childrenIds": [],
|
|
532
|
+
"role": "assistant",
|
|
533
|
+
"content": "As an AI, I don't have feelings, but I'm here and ready to assist you. How can I help you today?",
|
|
534
|
+
"model": "customer-support-assistant-id",
|
|
535
|
+
"modelId": "customer-support-assistant-id",
|
|
536
|
+
"modelIdx": 0,
|
|
537
|
+
"timestamp": 1760362655,
|
|
538
|
+
"sources": []
|
|
539
|
+
}
|
|
540
|
+
],
|
|
541
|
+
"params": {}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
- **Response Body**:
|
|
547
|
+
|
|
548
|
+
```javascript
|
|
549
|
+
{
|
|
550
|
+
"id": "3cd6f38c-effc-4038-948a-4fd345ea19b1", //chatId
|
|
551
|
+
"user_id": "e12c1cb7-f768-42a5-bb45-59846d2406fa",
|
|
552
|
+
"title": "New Chat",
|
|
553
|
+
"chat": {
|
|
554
|
+
"models": ["customer-support-assistant-id"],
|
|
555
|
+
"history": {
|
|
556
|
+
"messages": {
|
|
557
|
+
"2860fdae-4c43-4f59-8217-33dfc92b47d3": {
|
|
558
|
+
"id": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
559
|
+
"parentId": null,
|
|
560
|
+
"childrenIds": ["29948ec6-6975-4d3a-b019-ceb8b7f7c698"],
|
|
561
|
+
"role": "user",
|
|
562
|
+
"content": "how are you",
|
|
563
|
+
"timestamp": 1760362655,
|
|
564
|
+
"models": ["customer-support-assistant-id"]
|
|
565
|
+
},
|
|
566
|
+
"29948ec6-6975-4d3a-b019-ceb8b7f7c698": {
|
|
567
|
+
"annotation": { // add only after giving feedback
|
|
568
|
+
"rating": 1 // 1 for postive, -1 for negative
|
|
569
|
+
},
|
|
570
|
+
"id": "29948ec6-6975-4d3a-b019-ceb8b7f7c698",
|
|
571
|
+
"parentId": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
572
|
+
"childrenIds": [],
|
|
573
|
+
"role": "assistant",
|
|
574
|
+
"content": "As an AI, I don't have feelings, but I'm here and ready to assist you. How can I help you today?",
|
|
575
|
+
"model": "customer-support-assistant-id",
|
|
576
|
+
"modelId": "customer-support-assistant-id",
|
|
577
|
+
"modelIdx": 0,
|
|
578
|
+
"timestamp": 1760362655,
|
|
579
|
+
"sources": []
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
"currentId": "29948ec6-6975-4d3a-b019-ceb8b7f7c698"
|
|
583
|
+
},
|
|
584
|
+
"messages": [
|
|
585
|
+
{
|
|
586
|
+
"id": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
587
|
+
"parentId": "f55b5f5e-d3be-4bb3-8afc-cc3d322ef70f",
|
|
588
|
+
"childrenIds": ["29948ec6-6975-4d3a-b019-ceb8b7f7c698"],
|
|
589
|
+
"role": "user",
|
|
590
|
+
"content": "how are you",
|
|
591
|
+
"timestamp": 1760362655,
|
|
592
|
+
"models": ["customer-support-assistant-id"]
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
"annotation": { // add only after giving feedback
|
|
596
|
+
"rating": 1 // 1 for postive, -1 for negative
|
|
597
|
+
},
|
|
598
|
+
"id": "29948ec6-6975-4d3a-b019-ceb8b7f7c698",
|
|
599
|
+
"parentId": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
600
|
+
"childrenIds": [],
|
|
601
|
+
"role": "assistant",
|
|
602
|
+
"content": "As an AI, I don't have feelings, but I'm here and ready to assist you. How can I help you today?",
|
|
603
|
+
"model": "customer-support-assistant-id",
|
|
604
|
+
"modelId": "customer-support-assistant-id",
|
|
605
|
+
"modelIdx": 0,
|
|
606
|
+
"timestamp": 1760362655,
|
|
607
|
+
"sources": []
|
|
608
|
+
}
|
|
609
|
+
],
|
|
610
|
+
"params": {}
|
|
611
|
+
},
|
|
612
|
+
"updated_at": 1760433576,
|
|
613
|
+
"created_at": 1760361654,
|
|
614
|
+
"share_id": null,
|
|
615
|
+
"archived": false,
|
|
616
|
+
"pinned": false,
|
|
617
|
+
"meta": {},
|
|
618
|
+
"folder_id": null
|
|
619
|
+
}
|
|
620
|
+
```
|
|
185
621
|
|
|
186
622
|
#### 4. Feedback API
|
|
187
623
|
|
|
188
624
|
- **Endpoint**: `{apiUrl}/api/v1/evaluations/feedback`
|
|
189
625
|
- **Method**: POST
|
|
190
626
|
- **Purpose**: Submit user feedback (thumbs up/down) for AI responses
|
|
191
|
-
- **
|
|
192
|
-
|
|
627
|
+
- **Request Body**:
|
|
628
|
+
|
|
629
|
+
```javascript
|
|
630
|
+
{
|
|
631
|
+
"assistantId": "customer-support-assistant-id",
|
|
632
|
+
"type": "rating",
|
|
633
|
+
"data": {
|
|
634
|
+
"rating": 1, // 1 for postive, -1 for negative
|
|
635
|
+
"model_id": "customer-support-assistant-id"
|
|
636
|
+
},
|
|
637
|
+
"meta": {
|
|
638
|
+
"model_id": "customer-support-assistant-id",
|
|
639
|
+
"message_id": "29948ec6-6975-4d3a-b019-ceb8b7f7c698",
|
|
640
|
+
"message_index": 1,
|
|
641
|
+
"chat_id": "3cd6f38c-effc-4038-948a-4fd345ea19b1",
|
|
642
|
+
"base_models": {
|
|
643
|
+
"customer-support-assistant-id": "customer-support-assistant-id"
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
"snapshot": {
|
|
647
|
+
"chat": {
|
|
648
|
+
"id": "3cd6f38c-effc-4038-948a-4fd345ea19b1",
|
|
649
|
+
"user_id": null,
|
|
650
|
+
"title": "New Chat",
|
|
651
|
+
"chat": {
|
|
652
|
+
"id": "",
|
|
653
|
+
"title": "New Chat",
|
|
654
|
+
"models": [
|
|
655
|
+
"customer-support-assistant-id"
|
|
656
|
+
],
|
|
657
|
+
"params": {},
|
|
658
|
+
"history": {
|
|
659
|
+
"messages": {
|
|
660
|
+
"2860fdae-4c43-4f59-8217-33dfc92b47d3": {
|
|
661
|
+
"id": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
662
|
+
"parentId": null,
|
|
663
|
+
"childrenIds": [
|
|
664
|
+
"29948ec6-6975-4d3a-b019-ceb8b7f7c698"
|
|
665
|
+
],
|
|
666
|
+
"role": "user",
|
|
667
|
+
"content": "how are you",
|
|
668
|
+
"timestamp": 1760362655,
|
|
669
|
+
"models": [
|
|
670
|
+
"customer-support-assistant-id"
|
|
671
|
+
]
|
|
672
|
+
},
|
|
673
|
+
"29948ec6-6975-4d3a-b019-ceb8b7f7c698": {
|
|
674
|
+
"id": "29948ec6-6975-4d3a-b019-ceb8b7f7c698",
|
|
675
|
+
"parentId": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
676
|
+
"childrenIds": [],
|
|
677
|
+
"role": "assistant",
|
|
678
|
+
"content": "As an AI, I don't have feelings, but I'm here and ready to assist you. How can I help you today?",
|
|
679
|
+
"model": "customer-support-assistant-id",
|
|
680
|
+
"modelId": "customer-support-assistant-id",
|
|
681
|
+
"modelIdx": 0,
|
|
682
|
+
"timestamp": 1760362655,
|
|
683
|
+
"sources": []
|
|
684
|
+
}
|
|
685
|
+
},
|
|
686
|
+
"currentId": "29948ec6-6975-4d3a-b019-ceb8b7f7c698"
|
|
687
|
+
},
|
|
688
|
+
"messages": [
|
|
689
|
+
{
|
|
690
|
+
"id": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
691
|
+
"parentId": "f55b5f5e-d3be-4bb3-8afc-cc3d322ef70f",
|
|
692
|
+
"childrenIds": [
|
|
693
|
+
"29948ec6-6975-4d3a-b019-ceb8b7f7c698"
|
|
694
|
+
],
|
|
695
|
+
"role": "user",
|
|
696
|
+
"content": "how are you",
|
|
697
|
+
"timestamp": 1760362655,
|
|
698
|
+
"models": [
|
|
699
|
+
"customer-support-assistant-id"
|
|
700
|
+
]
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
"id": "29948ec6-6975-4d3a-b019-ceb8b7f7c698",
|
|
704
|
+
"parentId": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
705
|
+
"childrenIds": [],
|
|
706
|
+
"role": "assistant",
|
|
707
|
+
"content": "As an AI, I don't have feelings, but I'm here and ready to assist you. How can I help you today?",
|
|
708
|
+
"model": "customer-support-assistant-id",
|
|
709
|
+
"modelId": "customer-support-assistant-id",
|
|
710
|
+
"modelIdx": 0,
|
|
711
|
+
"timestamp": 1760362655,
|
|
712
|
+
"sources": []
|
|
713
|
+
}
|
|
714
|
+
]
|
|
715
|
+
},
|
|
716
|
+
"updated_at": 1760433800173,
|
|
717
|
+
"created_at": 1760433800173,
|
|
718
|
+
"share_id": null,
|
|
719
|
+
"archived": false,
|
|
720
|
+
"pinned": false,
|
|
721
|
+
"meta": {},
|
|
722
|
+
"folder_id": null
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
```javascript
|
|
729
|
+
{
|
|
730
|
+
"assistantId": "customer-support-assistant-id",
|
|
731
|
+
"type": "rating",
|
|
732
|
+
"data": {
|
|
733
|
+
"rating": 1, // 1 for positive, -1 for negative
|
|
734
|
+
"model_id": "customer-support-assistant-id"
|
|
735
|
+
},
|
|
736
|
+
"meta": {
|
|
737
|
+
"model_id": "customer-support-assistant-id",
|
|
738
|
+
"message_id": "message-uuid",
|
|
739
|
+
"message_index": 2,
|
|
740
|
+
"chat_id": "chat-uuid",
|
|
741
|
+
"base_models": {"customer-support-assistant-id": "customer-support-assistant-id"}
|
|
742
|
+
},
|
|
743
|
+
"snapshot": {
|
|
744
|
+
"chat": {
|
|
745
|
+
// Complete chat state for context
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
- **Response Body**:
|
|
752
|
+
|
|
753
|
+
```javascript
|
|
754
|
+
{
|
|
755
|
+
"id": "6e6503ff-8f59-4995-a2f4-6b07f02a4723",
|
|
756
|
+
"user_id": "e12c1cb7-f768-42a5-bb45-59846d2406fa",
|
|
757
|
+
"version": 0,
|
|
758
|
+
"type": "rating",
|
|
759
|
+
"data": {
|
|
760
|
+
"rating": 1,
|
|
761
|
+
"model_id": "customer-support-assistant-id",
|
|
762
|
+
"sibling_model_ids": null,
|
|
763
|
+
"reason": null,
|
|
764
|
+
"comment": null
|
|
765
|
+
},
|
|
766
|
+
"meta": {
|
|
767
|
+
"model_id": "customer-support-assistant-id",
|
|
768
|
+
"message_id": "29948ec6-6975-4d3a-b019-ceb8b7f7c698",
|
|
769
|
+
"message_index": 1,
|
|
770
|
+
"chat_id": "3cd6f38c-effc-4038-948a-4fd345ea19b1",
|
|
771
|
+
"base_models": {
|
|
772
|
+
"customer-support-assistant-id": "customer-support-assistant-id"
|
|
773
|
+
}
|
|
774
|
+
},
|
|
775
|
+
"snapshot": {
|
|
776
|
+
"chat": {
|
|
777
|
+
"id": "3cd6f38c-effc-4038-948a-4fd345ea19b1",
|
|
778
|
+
"user_id": null,
|
|
779
|
+
"title": "New Chat",
|
|
780
|
+
"chat": {
|
|
781
|
+
"id": "",
|
|
782
|
+
"title": "New Chat",
|
|
783
|
+
"models": ["customer-support-assistant-id"],
|
|
784
|
+
"params": {},
|
|
785
|
+
"history": {
|
|
786
|
+
"messages": {
|
|
787
|
+
"2860fdae-4c43-4f59-8217-33dfc92b47d3": {
|
|
788
|
+
"id": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
789
|
+
"parentId": null,
|
|
790
|
+
"childrenIds": ["29948ec6-6975-4d3a-b019-ceb8b7f7c698"],
|
|
791
|
+
"role": "user",
|
|
792
|
+
"content": "how are you",
|
|
793
|
+
"timestamp": 1760362655,
|
|
794
|
+
"models": ["customer-support-assistant-id"]
|
|
795
|
+
},
|
|
796
|
+
"29948ec6-6975-4d3a-b019-ceb8b7f7c698": {
|
|
797
|
+
"id": "29948ec6-6975-4d3a-b019-ceb8b7f7c698",
|
|
798
|
+
"parentId": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
799
|
+
"childrenIds": [],
|
|
800
|
+
"role": "assistant",
|
|
801
|
+
"content": "As an AI, I don't have feelings, but I'm here and ready to assist you. How can I help you today?",
|
|
802
|
+
"model": "customer-support-assistant-id",
|
|
803
|
+
"modelId": "customer-support-assistant-id",
|
|
804
|
+
"modelIdx": 0,
|
|
805
|
+
"timestamp": 1760362655,
|
|
806
|
+
"sources": []
|
|
807
|
+
}
|
|
808
|
+
},
|
|
809
|
+
"currentId": "29948ec6-6975-4d3a-b019-ceb8b7f7c698"
|
|
810
|
+
},
|
|
811
|
+
"messages": [
|
|
812
|
+
{
|
|
813
|
+
"id": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
814
|
+
"parentId": "f55b5f5e-d3be-4bb3-8afc-cc3d322ef70f",
|
|
815
|
+
"childrenIds": ["29948ec6-6975-4d3a-b019-ceb8b7f7c698"],
|
|
816
|
+
"role": "user",
|
|
817
|
+
"content": "how are you",
|
|
818
|
+
"timestamp": 1760362655,
|
|
819
|
+
"models": ["customer-support-assistant-id"]
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
"id": "29948ec6-6975-4d3a-b019-ceb8b7f7c698",
|
|
823
|
+
"parentId": "2860fdae-4c43-4f59-8217-33dfc92b47d3",
|
|
824
|
+
"childrenIds": [],
|
|
825
|
+
"role": "assistant",
|
|
826
|
+
"content": "As an AI, I don't have feelings, but I'm here and ready to assist you. How can I help you today?",
|
|
827
|
+
"model": "customer-support-assistant-id",
|
|
828
|
+
"modelId": "customer-support-assistant-id",
|
|
829
|
+
"modelIdx": 0,
|
|
830
|
+
"timestamp": 1760362655,
|
|
831
|
+
"sources": []
|
|
832
|
+
}
|
|
833
|
+
]
|
|
834
|
+
},
|
|
835
|
+
"updated_at": 1760433800173,
|
|
836
|
+
"created_at": 1760433800173,
|
|
837
|
+
"share_id": null,
|
|
838
|
+
"archived": false,
|
|
839
|
+
"pinned": false,
|
|
840
|
+
"meta": {},
|
|
841
|
+
"folder_id": null
|
|
842
|
+
}
|
|
843
|
+
},
|
|
844
|
+
"created_at": 1760434499,
|
|
845
|
+
"updated_at": 1760434499
|
|
846
|
+
}
|
|
847
|
+
```
|
|
193
848
|
|
|
194
849
|
### Configuration Attributes
|
|
195
850
|
|
|
@@ -197,6 +852,10 @@ The chat bubble can be configured using environment variables, data attributes,
|
|
|
197
852
|
|
|
198
853
|
#### Core API Configuration
|
|
199
854
|
|
|
855
|
+
| Attribute | Environment Variable | Data Attribute | Purpose | Default |
|
|
856
|
+
| ------------- | ------------------------------- | ------------------------------- | ----------------------------------------- | ------------------- |
|
|
857
|
+
| `apiUrl` | `VITE_CHAT_BUBBLE_API_URL` | `data-chat-bubble-api-url` | Base URL for API endpoints | `https://localhost` |
|
|
858
|
+
| `assistantId` | `VITE_CHAT_BUBBLE_ASSISTANT_ID` | `data-chat-bubble-assistant-id` | Assistant identifier to use for responses | `test-model` |
|
|
200
859
|
| Attribute | Environment Variable | Data Attribute | Purpose | Default |
|
|
201
860
|
| ------------- | ------------------------------- | ------------------------------- | ----------------------------------------- | ------------------- |
|
|
202
861
|
| `apiUrl` | `VITE_CHAT_BUBBLE_API_URL` | `data-chat-bubble-api-url` | Base URL for API endpoints | `https://localhost` |
|