@desert-ant-labs/emo 0.6.0 → 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/README.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # @desert-ant-labs/emo
2
2
 
3
+ **On-device emoji suggestion for Node and the browser. TypeScript-native, offline, multilingual, no inference runtime.**
4
+
3
5
  On-device emoji suggestions from text. Suggests the best-matching emoji for short
4
6
  tasks, calendar entries, notes, or message drafts across **23 languages**, fully
5
- in-process, no inference runtime.
7
+ in-process, no inference runtime. Emo does emoji prediction (text-to-emoji), useful
8
+ for a keyboard, an autocomplete, or any text field. It runs in TypeScript and
9
+ JavaScript, in Node and in the browser. Emo suggests emoji from text; it is not an
10
+ emoji picker.
6
11
 
7
12
  ```ts
8
13
  import { suggestions } from "@desert-ant-labs/emo";
@@ -112,6 +117,14 @@ emoji for each task on-device. Run it with `node server.js` from that folder and
112
117
 
113
118
  Published at [`desert-ant-labs/emo`](https://huggingface.co/desert-ant-labs/emo) on Hugging Face.
114
119
 
120
+ ## Other platforms
121
+
122
+ Same model, native on each platform:
123
+
124
+ - [`emo-swift`](https://github.com/Desert-Ant-Labs/emo-swift): Swift for iOS and macOS
125
+ - [`emo-kotlin`](https://github.com/Desert-Ant-Labs/emo-kotlin): Kotlin for Android and the JVM
126
+ - Model weights and card: [`desert-ant-labs/emo`](https://huggingface.co/desert-ant-labs/emo)
127
+
115
128
  ## License
116
129
 
117
130
  [Desert Ant Labs Source-Available License](https://license.desertant.ai/1.0). Free for
@@ -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>): Promise<EmoModel>;
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 `[]`.
@@ -1,3 +1,4 @@
1
+ import { initUsage } from "@desert-ant-labs/desert-ant-web";
1
2
  import { webCache } from "./cache-web.js";
2
3
  import { DEFAULT_HOST, DEFAULT_REPO, DEFAULT_REVISION, loadModel } from "./hub.js";
3
4
  export { createEmo, EmoModel } from "./model.js";
@@ -11,10 +12,21 @@ export const env = {
11
12
  allowRemote: true,
12
13
  useCache: true,
13
14
  };
15
+ let usage = null;
16
+ function instrument(model, usageKey) {
17
+ const suggestions = model.suggestions.bind(model);
18
+ model.suggestions = (text, limit, options) => {
19
+ usage ??= initUsage({ key: usageKey });
20
+ const out = suggestions(text, limit, options);
21
+ usage.recordCall();
22
+ return out;
23
+ };
24
+ return model;
25
+ }
14
26
  /** Loads the model from the Hugging Face Hub (cached in Cache Storage). */
15
27
  export async function load(options = {}) {
16
28
  const e = { ...env, ...options };
17
- return loadModel(e, e.useCache ? webCache() : null);
29
+ return instrument(await loadModel(e, e.useCache ? webCache() : null), options.usageKey);
18
30
  }
19
31
  let modelPromise = null;
20
32
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@desert-ant-labs/emo",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "On-device emoji suggestions from text.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.node.js",
@@ -51,9 +51,15 @@
51
51
  },
52
52
  "keywords": [
53
53
  "emoji",
54
+ "emoji-suggestion",
55
+ "emoji-prediction",
56
+ "text-to-emoji",
57
+ "emoji-autocomplete",
54
58
  "on-device",
59
+ "offline",
55
60
  "multilingual",
56
- "text-classification"
61
+ "typescript",
62
+ "keyboard"
57
63
  ],
58
64
  "license": "SEE LICENSE IN LICENSE.md",
59
65
  "repository": {
@@ -68,6 +74,9 @@
68
74
  "publishConfig": {
69
75
  "access": "public"
70
76
  },
77
+ "dependencies": {
78
+ "@desert-ant-labs/desert-ant-web": "^0.1.0"
79
+ },
71
80
  "devDependencies": {
72
81
  "@arethetypeswrong/cli": "^0.18",
73
82
  "@types/node": "^22",