@razzium/piece-aimw-api 0.0.17 → 0.0.19
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
CHANGED
package/src/lib/common/common.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// tiktoken est importé dynamiquement dans calculateTokensFromString pour éviter crash à l'import
|
|
2
|
-
|
|
3
1
|
export const baseUrl = 'https://rekto.dashboard.aimw.ai/api';
|
|
4
2
|
|
|
5
3
|
export const Languages = [
|
|
@@ -84,20 +82,9 @@ export const streamToBuffer = (stream: any) => {
|
|
|
84
82
|
});
|
|
85
83
|
};
|
|
86
84
|
|
|
87
|
-
export const calculateTokensFromString = (string: string,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
91
|
-
const tiktoken = require('tiktoken');
|
|
92
|
-
const encoder = tiktoken.encoding_for_model(model as any);
|
|
93
|
-
const tokens = encoder.encode(string);
|
|
94
|
-
encoder.free();
|
|
95
|
-
|
|
96
|
-
return tokens.length;
|
|
97
|
-
} catch (e) {
|
|
98
|
-
// Tiktoken non disponible ou model non supporté - fallback: ~4 chars par token
|
|
99
|
-
return Math.round(string.length / 4);
|
|
100
|
-
}
|
|
85
|
+
export const calculateTokensFromString = (string: string, _model: string) => {
|
|
86
|
+
// Estimation simple: ~4 caractères par token
|
|
87
|
+
return Math.round(string.length / 4);
|
|
101
88
|
};
|
|
102
89
|
|
|
103
90
|
export const calculateMessagesTokenSize = async (
|