mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2025-05-02 17:07:13 +00:00
patch text.substring bug from compressor (#1918)
This commit is contained in:
parent
a43fa8a292
commit
18171bc7f4
1 changed files with 7 additions and 2 deletions
|
@ -19,8 +19,13 @@ class TokenManager {
|
|||
// https://github.com/openai/tiktoken/blob/9e79899bc248d5313c7dd73562b5e211d728723d/tiktoken/core.py#L91C20-L91C38
|
||||
// Returns number[]
|
||||
tokensFromString(input = "") {
|
||||
const tokens = this.encoder.encode(input, undefined, []);
|
||||
return tokens;
|
||||
try {
|
||||
const tokens = this.encoder.encode(String(input), undefined, []);
|
||||
return tokens;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
bytesFromTokens(tokens = []) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue