mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-15 02:50:10 +01:00
patch text.substring bug from compressor
This commit is contained in:
parent
3198718975
commit
2185753068
@ -19,8 +19,13 @@ class TokenManager {
|
|||||||
// https://github.com/openai/tiktoken/blob/9e79899bc248d5313c7dd73562b5e211d728723d/tiktoken/core.py#L91C20-L91C38
|
// https://github.com/openai/tiktoken/blob/9e79899bc248d5313c7dd73562b5e211d728723d/tiktoken/core.py#L91C20-L91C38
|
||||||
// Returns number[]
|
// Returns number[]
|
||||||
tokensFromString(input = "") {
|
tokensFromString(input = "") {
|
||||||
const tokens = this.encoder.encode(input, undefined, []);
|
try {
|
||||||
|
const tokens = this.encoder.encode(String(input), undefined, []);
|
||||||
return tokens;
|
return tokens;
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bytesFromTokens(tokens = []) {
|
bytesFromTokens(tokens = []) {
|
||||||
|
Loading…
Reference in New Issue
Block a user