@desert-ant-labs/emo 0.6.1 → 0.6.2
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/dist/index.browser.d.ts +3 -1
- package/dist/index.browser.js +3 -4
- package/package.json +1 -1
package/dist/index.browser.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ export { loadModel, type EmoEnv, type FileCache } from "./hub.js";
|
|
|
7
7
|
/** Loading configuration. Mutate before the first call, or pass overrides to {@link load}. */
|
|
8
8
|
export declare const env: EmoEnv;
|
|
9
9
|
/** Loads the model from the Hugging Face Hub (cached in Cache Storage). */
|
|
10
|
-
export declare function load(options?: Partial<EmoEnv>
|
|
10
|
+
export declare function load(options?: Partial<EmoEnv> & {
|
|
11
|
+
usageKey?: string;
|
|
12
|
+
}): Promise<EmoModel>;
|
|
11
13
|
/**
|
|
12
14
|
* Returns emoji suggestions for a phrase, most likely first. The model is loaded
|
|
13
15
|
* (and cached) lazily on first call. Empty input returns `[]`.
|
package/dist/index.browser.js
CHANGED
|
@@ -12,12 +12,11 @@ export const env = {
|
|
|
12
12
|
allowRemote: true,
|
|
13
13
|
useCache: true,
|
|
14
14
|
};
|
|
15
|
-
const USAGE_KEY = "dal_lEL3EuFU2eh8IRTH8RW9pV9czYn0TrCk";
|
|
16
15
|
let usage = null;
|
|
17
|
-
function instrument(model) {
|
|
16
|
+
function instrument(model, usageKey) {
|
|
18
17
|
const suggestions = model.suggestions.bind(model);
|
|
19
18
|
model.suggestions = (text, limit, options) => {
|
|
20
|
-
usage ??= initUsage({ key:
|
|
19
|
+
usage ??= initUsage({ key: usageKey });
|
|
21
20
|
const out = suggestions(text, limit, options);
|
|
22
21
|
usage.recordCall();
|
|
23
22
|
return out;
|
|
@@ -27,7 +26,7 @@ function instrument(model) {
|
|
|
27
26
|
/** Loads the model from the Hugging Face Hub (cached in Cache Storage). */
|
|
28
27
|
export async function load(options = {}) {
|
|
29
28
|
const e = { ...env, ...options };
|
|
30
|
-
return instrument(await loadModel(e, e.useCache ? webCache() : null));
|
|
29
|
+
return instrument(await loadModel(e, e.useCache ? webCache() : null), options.usageKey);
|
|
31
30
|
}
|
|
32
31
|
let modelPromise = null;
|
|
33
32
|
/**
|