You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param {Record<string|number, string|{ text: string, hide?: boolean }>} errors - The error codes to set, typically an object containing error code definitions.
740
+
* @param {Record<string|number, string|ErrorCode>} errors - The error codes to set, typically an object containing error code definitions.
722
741
* @returns {void}
723
742
*/
724
743
_setErrorCodes(errors){
@@ -729,7 +748,7 @@ class TinyAiInstance extends EventEmitter {
729
748
* Get error details based on the provided error code.
730
749
*
731
750
* @param {string|number} code - The error code to look up.
732
-
* @returns {Object|null} An object containing the error message, or null if no error is found.
751
+
* @returns {ErrorCode|null} An object containing the error message, or null if no error is found.
733
752
*/
734
753
getErrorCode(code){
735
754
if(this._errorCode){
@@ -756,11 +775,11 @@ class TinyAiInstance extends EventEmitter {
756
775
/**
757
776
* Generates content for the AI session.
758
777
*
759
-
* @param {Object} data - The data for content generation.
778
+
* @param {Record<string, any>} data - The data for content generation.
760
779
* @param {string} model - The model to be used for content generation. If not provided, the default model is used.
761
-
* @param {Object} controller - The controller managing the content generation process.
780
+
* @param {AbortController} controller - The controller managing the content generation process.
762
781
* @param {Function} [streamCallback] - The callback function for streaming content (optional).
763
-
* @returns {Object} The generated content returned by the API.
782
+
* @returns {Record<string, any>} The generated content returned by the API.
764
783
* @throws {Error} If no content generator API script is defined.
765
784
*/
766
785
genContent(data,model,controller,streamCallback){
@@ -814,7 +833,7 @@ class TinyAiInstance extends EventEmitter {
814
833
* Get the data associated with a specific session history ID.
815
834
*
816
835
* @param {string} [id] - The session ID. If omitted, the currently selected session history ID will be used.
817
-
* @returns {Record<string, any>|null} The data associated with the session ID, or `null` if no data exists for that ID.
836
+
* @returns {SessionData|null} The data associated with the session ID, or `null` if no data exists for that ID.
818
837
*/
819
838
getData(id){
820
839
constselectedId=this.getId(id);
@@ -858,7 +877,7 @@ class TinyAiInstance extends EventEmitter {
858
877
*
859
878
* @param {number} msgIndex - The index of the message in the session history.
860
879
* @param {string} [id] - The session ID. If omitted, the currently selected session history ID will be used.
861
-
* @returns {Object|null} The token data associated with the message at the specified index, or `null` if the data is not found.
880
+
* @returns {TokenCount|null} The token data associated with the message at the specified index, or `null` if the data is not found.
862
881
*/
863
882
getMsgTokensByIndex(msgIndex,id){
864
883
consthistory=this.getData(id);
@@ -877,7 +896,7 @@ class TinyAiInstance extends EventEmitter {
877
896
*
878
897
* @param {string} msgId - The unique ID of the message in the session history.
879
898
* @param {string} [id] - The session ID. If omitted, the currently selected session history ID will be used.
880
-
* @returns {Object|null} The token data associated with the message with the given ID, or `null` if the message is not found.
899
+
* @returns {TokenCount|null} The token data associated with the message with the given ID, or `null` if the message is not found.
881
900
*/
882
901
getMsgTokensById(msgId,id){
883
902
consthistory=this.getData(id);
@@ -939,7 +958,7 @@ class TinyAiInstance extends EventEmitter {
939
958
*
940
959
* @param {number} index - The index of the data entry to retrieve.
941
960
* @param {string} [id] - The session ID. If omitted, the currently selected session history ID will be used.
942
-
* @returns {Object|null} The data entry at the specified index, or `null` if the index is out of bounds or no data exists for the given session ID.
961
+
* @returns {AIContentData|null} The data entry at the specified index, or `null` if the index is out of bounds or no data exists for the given session ID.
943
962
*/
944
963
getMsgByIndex(index,id){
945
964
consthistory=this.getData(id);
@@ -952,7 +971,7 @@ class TinyAiInstance extends EventEmitter {
952
971
*
953
972
* @param {string} msgId - The ID of the message to retrieve.
954
973
* @param {string} [id] - The session ID. If omitted, the currently selected session history ID will be used.
955
-
* @returns {Object|null} The message data associated with the given ID, or `null` if the message ID is invalid or does not exist.
974
+
* @returns {AIContentData|null} The message data associated with the given ID, or `null` if the message ID is invalid or does not exist.
956
975
*/
957
976
getMsgById(msgId,id){
958
977
consthistory=this.getData(id);
@@ -1014,8 +1033,8 @@ class TinyAiInstance extends EventEmitter {
1014
1033
* Replaces an entry at the specified index in the session history with new data.
1015
1034
*
1016
1035
* @param {number} index - The index of the entry to replace.
1017
-
* @param {Object} [data] - The new data to replace the existing entry (optional).
1018
-
* @param {number} [tokens] - The token count associated with the new entry (optional).
1036
+
* @param {AIContentData} [data] - The new data to replace the existing entry (optional).
1037
+
* @param {TokenCount} [tokens] - The token count associated with the new entry (optional).
1019
1038
* @param {string} [id] - The session ID (optional). If omitted, the currently selected session history ID will be used.
1020
1039
* @returns {boolean} `true` if the entry was successfully replaced, `false` if the index is invalid or the entry does not exist.
1021
1040
*/
@@ -1052,7 +1071,7 @@ class TinyAiInstance extends EventEmitter {
1052
1071
* Retrieve the data of the last entry in the session history.
1053
1072
*
1054
1073
* @param {string} [id] - The session ID. If omitted, the currently selected session history ID will be used.
1055
-
* @returns {Object|null} The data of the last entry in the session history, or `null` if the history is empty or invalid.
1074
+
* @returns {AIContentData|null} The data of the last entry in the session history, or `null` if the history is empty or invalid.
1056
1075
*/
1057
1076
getLastIndexData(id){
1058
1077
consthistory=this.getData(id);
@@ -1077,7 +1096,7 @@ class TinyAiInstance extends EventEmitter {
1077
1096
* Retrieve the first entry in the session history.
1078
1097
*
1079
1098
* @param {string} [id] - The session ID. If omitted, the currently selected session history ID will be used.
1080
-
* @returns {Object|null} The first entry of the session history, or `null` if no entry exists.
1099
+
* @returns {AIContentData|null} The first entry of the session history, or `null` if no entry exists.
1081
1100
*/
1082
1101
getFirstIndexData(id){
1083
1102
consthistory=this.getData(id);
@@ -1092,8 +1111,8 @@ class TinyAiInstance extends EventEmitter {
1092
1111
* **Note**: The `tokenData` parameter is optional and can be used to track token-related data associated with the new entry.
1093
1112
* This may include token counts, but this script does not manage token counting automatically. Developers must implement token management separately if necessary.
1094
1113
*
1095
-
* @param {Object} data - The data to be added to the session history.
1096
-
* @param {Object} [tokenData={count: null}] - Optional token-related data to be associated with the new entry. Defaults to `{count: null}`.
1114
+
* @param {AIContentData} data - The data to be added to the session history.
1115
+
* @param {TokenCount} [tokenData={count: null}] - Optional token-related data to be associated with the new entry. Defaults to `{count: null}`.
1097
1116
* @param {string} [id] - The session history ID. If omitted, the currently selected session ID will be used.
1098
1117
* @returns {number} The new ID of the added data entry.
1099
1118
* @throws {Error} If the provided session ID is invalid or the session ID does not exist in history.
@@ -1265,7 +1284,7 @@ class TinyAiInstance extends EventEmitter {
1265
1284
* Retrieves file data from the selected session history.
1266
1285
*
1267
1286
* @param {string} [id] - The session ID. If omitted, the currently selected session history ID will be used.
1268
-
* @returns {Object|null} The file data, including MIME type and encoded content, or null if no file data is found.
1287
+
* @returns {{data: string, mime: string}|null} The file data, including MIME type and encoded content, or null if no file data is found.
1269
1288
* @throws {Error} If no valid session history ID is found.
1270
1289
*/
1271
1290
getFileData(id){
@@ -1367,7 +1386,7 @@ class TinyAiInstance extends EventEmitter {
1367
1386
*
1368
1387
* @param {string} id - The session ID for the new data session.
1369
1388
* @param {boolean} [selected=false] - A flag to indicate whether this session should be selected as the active session.
1370
-
* @returns {Object} The newly created session data, which includes an empty data array, an empty IDs array, and null values for system instruction and model.
1389
+
* @returns {SessionData} The newly created session data, which includes an empty data array, an empty IDs array, and null values for system instruction and model.
0 commit comments