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
This method allows you to store file data (either as raw text or base64-encoded) along with an optional MIME type and token count in a selected session history. It also calculates a hash for the file data and emits an event with the new file data.
383
277
384
278
---
@@ -426,22 +320,6 @@ This would remove the file data from the session with ID `'session123'`.
426
320
427
321
#### Implementation
428
322
429
-
```js
430
-
removeFileData(id) {
431
-
constselectedId=this.getId(id);
432
-
if (this.history[selectedId]) {
433
-
deletethis.history[selectedId].file;
434
-
deletethis.history[selectedId].hash.file;
435
-
deletethis.history[selectedId].tokens.file;
436
-
this.emit('setFileData', null, null, selectedId);
437
-
return;
438
-
}
439
-
thrownewError('Invalid history id data!');
440
-
}
441
-
```
442
-
443
-
---
444
-
445
323
This method allows you to remove any stored file data from a specific session's history, including the file content, its hash, and associated token data. It also emits an event to indicate that the file data has been removed.
446
324
447
325
---
@@ -505,23 +383,6 @@ This would retrieve and display the MIME type and base64-encoded content of the
This method provides access to the file data stored in the selected session's history, including the MIME type and the base64-encoded content of the file. If no valid file data exists, it returns `null`.
526
387
527
388
---
@@ -586,27 +447,6 @@ This would set the system instruction `'Ensure system stability'` for the sessio
This method allows you to set a system instruction for a given session, optionally associating token data with it. The session is identified by its history ID, and it throws an error if the provided session ID or data is invalid.
611
451
612
452
---
@@ -659,21 +499,6 @@ This would attempt to retrieve the system instruction for the session with ID `'
This method allows you to retrieve the system instruction for a specified session. If no instruction is found or the session ID is invalid, it will return `null`.
678
503
679
504
---
@@ -726,17 +551,6 @@ This would attempt to retrieve the token count for the `prompt` category in the
726
551
727
552
#### Implementation
728
553
729
-
```js
730
-
getTokens(where, id) {
731
-
constselectedId=this.getId(id);
732
-
if (this.history[selectedId] &&typeofthis.history[selectedId].tokens[where] ==='number')
733
-
returnthis.history[selectedId].tokens[where];
734
-
returnnull;
735
-
}
736
-
```
737
-
738
-
---
739
-
740
554
This method allows you to retrieve the token count for a specific category (such as `prompt`, `file`, or `systemInstruction`) for the selected session. If the token count is not available or the session ID is invalid, it returns `null`.
741
555
742
556
---
@@ -789,17 +603,6 @@ This would attempt to retrieve the hash value for the `prompt` item in the sessi
789
603
790
604
#### Implementation
791
605
792
-
```js
793
-
getHash(where, id) {
794
-
constselectedId=this.getId(id);
795
-
if (this.history[selectedId] &&typeofthis.history[selectedId].hash[where] ==='string')
796
-
returnthis.history[selectedId].hash[where];
797
-
returnnull;
798
-
}
799
-
```
800
-
801
-
---
802
-
803
606
This method allows you to retrieve the hash value for a specific item (such as `prompt`, `file`, or `systemInstruction`) in the selected session. If the hash is not available or the session ID is invalid, it returns `null`.
804
607
805
608
---
@@ -856,24 +659,6 @@ This would start a new data session with the ID `'session123'`, select it as the
This method is responsible for initializing a new session with a specific session ID and optional selection flag. It ensures that each session has default, empty structures ready to hold data and other session-specific information. The event `startDataId` is emitted when the session is created.
878
663
879
664
---
@@ -926,18 +711,4 @@ In this example, the session with ID `'session123'` will be stopped and removed
926
711
927
712
#### Implementation
928
713
929
-
```js
930
-
stopDataId(id) {
931
-
if (this.history[id]) {
932
-
deletethis.history[id];
933
-
if (this.getId() === id) this.selectDataId(null);
934
-
this.emit('stopDataId', id);
935
-
returntrue;
936
-
}
937
-
returnfalse;
938
-
}
939
-
```
940
-
941
-
---
942
-
943
714
This method is used to stop and remove a data session by its ID, ensuring that the session history is properly updated. If the stopped session is the active one, it clears the active session as well.
0 commit comments