quickblox 2.17.0-beta.1 → 2.17.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.md +1 -1
- package/package.json +1 -1
- package/quickblox.d.ts +7 -3
- package/quickblox.js +23 -43
- package/quickblox.min.js +1 -1
- package/src/modules/chat/qbChat.js +1 -3
- package/src/modules/qbAI.js +20 -38
- package/src/qbConfig.js +2 -2
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Check out our [API Reference](https://quickblox.github.io/quickblox-javascript-s
|
|
|
16
16
|
## Dependencies for browser
|
|
17
17
|
|
|
18
18
|
```html
|
|
19
|
-
<script src="https://unpkg.com/quickblox@2.
|
|
19
|
+
<script src="https://unpkg.com/quickblox@2.17.0/quickblox.min.js"></script>
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Bower and RequireJS
|
package/package.json
CHANGED
package/quickblox.d.ts
CHANGED
|
@@ -420,7 +420,11 @@ export class AIRole {
|
|
|
420
420
|
|
|
421
421
|
export interface AIChatMessage {
|
|
422
422
|
role: AIRole;
|
|
423
|
-
|
|
423
|
+
message: string;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export interface AIAnswerResponse {
|
|
427
|
+
answer: string;
|
|
424
428
|
}
|
|
425
429
|
|
|
426
430
|
export declare type AIChatHistory = AIChatMessage[] | null | undefined;
|
|
@@ -430,12 +434,12 @@ interface QBAIModule{
|
|
|
430
434
|
answerAssist(smartChatAssistantId: string,
|
|
431
435
|
message: string,
|
|
432
436
|
history :AIChatHistory,
|
|
433
|
-
callback: QBCallback<
|
|
437
|
+
callback: QBCallback<AIAnswerResponse>): void
|
|
434
438
|
//QB.ai.translate
|
|
435
439
|
translate(smartChatAssistantId: string,
|
|
436
440
|
message: string,
|
|
437
441
|
languageCode: string,
|
|
438
|
-
callback: QBCallback<
|
|
442
|
+
callback: QBCallback<AIAnswerResponse>): void
|
|
439
443
|
|
|
440
444
|
}
|
|
441
445
|
|
package/quickblox.js
CHANGED
|
@@ -47342,9 +47342,7 @@ MucProxy.prototype = {
|
|
|
47342
47342
|
Utils.safeCallbackCall(callback, {
|
|
47343
47343
|
code: code || 500,
|
|
47344
47344
|
message: errorMessage || 'Unknown issue'
|
|
47345
|
-
},
|
|
47346
|
-
dialogId: dialogId
|
|
47347
|
-
});
|
|
47345
|
+
}, null);
|
|
47348
47346
|
}
|
|
47349
47347
|
}
|
|
47350
47348
|
}
|
|
@@ -48795,7 +48793,6 @@ function AIProxy(service) {
|
|
|
48795
48793
|
* @namespace QB.ai
|
|
48796
48794
|
**/
|
|
48797
48795
|
AIProxy.prototype = {
|
|
48798
|
-
|
|
48799
48796
|
/**
|
|
48800
48797
|
* Provides answer assistant functionality that helps users effortlessly send various answers considering({@link https://docs.quickblox.com/docs/js-sdk-ai-features#ai-assist-answer read more}).
|
|
48801
48798
|
* @memberof QB.ai
|
|
@@ -48807,8 +48804,8 @@ AIProxy.prototype = {
|
|
|
48807
48804
|
* var history = [
|
|
48808
48805
|
* {role: "user", message: "Hello"},
|
|
48809
48806
|
* {role: "assistant", message: "Hi"}
|
|
48810
|
-
*
|
|
48811
|
-
*
|
|
48807
|
+
* ];
|
|
48808
|
+
* var messageToAssist = 'Where is my order?';
|
|
48812
48809
|
* QB.ai.answerAssist(smartChatAssistantId, messageToAssist, history, callback);
|
|
48813
48810
|
* // or third parameters can be null
|
|
48814
48811
|
* QB.ai.answerAssist(smartChatAssistantId, messageToAssist, null, callback);
|
|
@@ -48821,61 +48818,36 @@ AIProxy.prototype = {
|
|
|
48821
48818
|
* @param {String} [response.answer] - assist answer for message
|
|
48822
48819
|
* @callback answerAssistCallback
|
|
48823
48820
|
* */
|
|
48821
|
+
if (!callback || typeof callback !== 'function') {
|
|
48822
|
+
throw new Error('Callback function is required and must be a function');
|
|
48823
|
+
}
|
|
48824
48824
|
function validateHistory(history) {
|
|
48825
48825
|
var AIRole = {
|
|
48826
48826
|
user: 'user',
|
|
48827
48827
|
assistant: 'assistant'
|
|
48828
48828
|
};
|
|
48829
|
-
// throw new Error('The QB.addressbook.get accept callback function is required.');
|
|
48830
|
-
// isArray, isCallback
|
|
48831
48829
|
if (history !== null && history !== undefined) {
|
|
48832
48830
|
if (!Array.isArray(history)) {
|
|
48833
|
-
|
|
48834
|
-
code: 400,
|
|
48835
|
-
message: 'History must be an array'
|
|
48836
|
-
});
|
|
48837
|
-
return false;
|
|
48831
|
+
throw new Error('History must be an array');
|
|
48838
48832
|
}
|
|
48839
|
-
|
|
48840
48833
|
for (var i = 0; i < history.length; i++) {
|
|
48841
48834
|
var item = history[i];
|
|
48842
48835
|
if (typeof item !== 'object' || item === null || Array.isArray(item)) {
|
|
48843
|
-
|
|
48844
|
-
code: 400,
|
|
48845
|
-
message: 'Each element of history must be an object'
|
|
48846
|
-
});
|
|
48847
|
-
return false;
|
|
48836
|
+
throw new Error('Each element of history must be an object');
|
|
48848
48837
|
}
|
|
48849
|
-
|
|
48850
48838
|
if (!('role' in item) || !('message' in item)) {
|
|
48851
|
-
|
|
48852
|
-
code: 400,
|
|
48853
|
-
message: 'Each element of history must have an role and message fields'
|
|
48854
|
-
});
|
|
48855
|
-
return false;
|
|
48839
|
+
throw new Error('Each element of history must have an role and message fields');
|
|
48856
48840
|
}
|
|
48857
|
-
|
|
48858
48841
|
if (!(item.role === AIRole.user || item.role === AIRole.assistant)) {
|
|
48859
|
-
|
|
48860
|
-
code: 400,
|
|
48861
|
-
message: 'Invalid role in history item'
|
|
48862
|
-
});
|
|
48863
|
-
return false;
|
|
48842
|
+
throw new Error('Invalid role in history item');
|
|
48864
48843
|
}
|
|
48865
|
-
|
|
48866
48844
|
if (typeof item.message !== 'string') {
|
|
48867
|
-
|
|
48868
|
-
code: 400,
|
|
48869
|
-
message: 'Message of history item must be a string'
|
|
48870
|
-
});
|
|
48871
|
-
return false;
|
|
48845
|
+
throw new Error('Message of history item must be a string');
|
|
48872
48846
|
}
|
|
48873
48847
|
}
|
|
48874
48848
|
}
|
|
48875
|
-
|
|
48876
48849
|
return true;
|
|
48877
48850
|
}
|
|
48878
|
-
|
|
48879
48851
|
if (!validateHistory(history)) {
|
|
48880
48852
|
return;
|
|
48881
48853
|
}
|
|
@@ -48903,10 +48875,11 @@ AIProxy.prototype = {
|
|
|
48903
48875
|
* @memberof QB.ai
|
|
48904
48876
|
* @param {String} smartChatAssistantId - Smart Chat Assistant id.
|
|
48905
48877
|
* @param {String} text - Text to translate.
|
|
48906
|
-
* @param {String} languageCode - Translation language code.
|
|
48878
|
+
* @param {String} languageCode - Translation language code. All list see on page: {@link https://docs.quickblox.com/docs/js-sdk-ai-features#ai-translate }
|
|
48907
48879
|
* @param {translateCallback} callback - The callback function.
|
|
48880
|
+
*
|
|
48908
48881
|
* */
|
|
48909
|
-
|
|
48882
|
+
|
|
48910
48883
|
translate: function(smartChatAssistantId, text, languageCode, callback) {
|
|
48911
48884
|
/**
|
|
48912
48885
|
* Callback for QB.ai.translate().
|
|
@@ -48914,7 +48887,14 @@ AIProxy.prototype = {
|
|
|
48914
48887
|
* @param {Object} response - The server response object.
|
|
48915
48888
|
* @param {String} [response.answer] - translated message
|
|
48916
48889
|
* @callback translateCallback
|
|
48890
|
+
* @example
|
|
48891
|
+
* var textToTranslate = 'Hola!';
|
|
48892
|
+
* var languageCode = 'en';
|
|
48893
|
+
* QB.ai.translate(smartChatAssistantId, textToTranslate, languageCode, callback);
|
|
48917
48894
|
* */
|
|
48895
|
+
if (!callback || typeof callback !== 'function') {
|
|
48896
|
+
throw new Error('Callback function is required and must be a function');
|
|
48897
|
+
}
|
|
48918
48898
|
var data = {
|
|
48919
48899
|
smart_chat_assistant_id: smartChatAssistantId,
|
|
48920
48900
|
text: text,
|
|
@@ -53829,8 +53809,8 @@ module.exports = StreamManagement;
|
|
|
53829
53809
|
*/
|
|
53830
53810
|
|
|
53831
53811
|
var config = {
|
|
53832
|
-
version: '2.
|
|
53833
|
-
buildNumber: '
|
|
53812
|
+
version: '2.17.0',
|
|
53813
|
+
buildNumber: '1160',
|
|
53834
53814
|
creds: {
|
|
53835
53815
|
'appId': 0,
|
|
53836
53816
|
'authKey': '',
|