@razzium/piece-aimw-api 0.0.16 → 0.0.18
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/package.json +2 -4
- package/src/lib/common/common.ts +3 -13
package/package.json
CHANGED
package/src/lib/common/common.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { encoding_for_model } from 'tiktoken';
|
|
2
|
-
|
|
3
1
|
export const baseUrl = 'https://rekto.dashboard.aimw.ai/api';
|
|
4
2
|
|
|
5
3
|
export const Languages = [
|
|
@@ -84,17 +82,9 @@ export const streamToBuffer = (stream: any) => {
|
|
|
84
82
|
});
|
|
85
83
|
};
|
|
86
84
|
|
|
87
|
-
export const calculateTokensFromString = (string: string,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const tokens = encoder.encode(string);
|
|
91
|
-
encoder.free();
|
|
92
|
-
|
|
93
|
-
return tokens.length;
|
|
94
|
-
} catch (e) {
|
|
95
|
-
// Model not supported by tiktoken, every 4 chars is a token
|
|
96
|
-
return Math.round(string.length / 4);
|
|
97
|
-
}
|
|
85
|
+
export const calculateTokensFromString = (string: string, _model: string) => {
|
|
86
|
+
// Estimation simple: ~4 caractères par token
|
|
87
|
+
return Math.round(string.length / 4);
|
|
98
88
|
};
|
|
99
89
|
|
|
100
90
|
export const calculateMessagesTokenSize = async (
|