gheim 0.1.1 → 0.1.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/cjs/index.cjs +79 -110
- package/dist/cjs/openai/index.cjs +111 -112
- package/dist/esm/index.js +86 -112
- package/dist/esm/openai/index.js +118 -114
- package/dist/types/core/session.d.ts +42 -6
- package/dist/types/core/session.d.ts.map +1 -1
- package/dist/types/detectors/index.d.ts +1 -1
- package/dist/types/detectors/index.d.ts.map +1 -1
- package/dist/types/detectors/local.d.ts +65 -2
- package/dist/types/detectors/local.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/normalizers.d.ts +5 -2
- package/dist/types/normalizers.d.ts.map +1 -1
- package/dist/types/openai/_chat.d.ts.map +1 -1
- package/dist/types/openai/_client.d.ts +15 -2
- package/dist/types/openai/_client.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ export type { Detector, Span } from "./base.ts";
|
|
|
2
2
|
export { DEFAULT_BASE_URL, DEFAULT_MODEL as REMOTE_DEFAULT_MODEL, RemoteDetector, } from "./remote.ts";
|
|
3
3
|
export type { RemoteDetectorOptions } from "./remote.ts";
|
|
4
4
|
export { LocalDetector } from "./local.ts";
|
|
5
|
-
export type { LocalDetectorOptions } from "./local.ts";
|
|
5
|
+
export type { LocalDetectorOptions, LocalDetectorLoadEvent } from "./local.ts";
|
|
6
6
|
import type { Detector } from "./base.ts";
|
|
7
7
|
/** Pick a reasonable default: remote if `GHEIM_API_KEY` is set in env, else local. */
|
|
8
8
|
export declare function defaultDetector(): Detector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/detectors/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,aAAa,IAAI,oBAAoB,EACrC,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/detectors/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,aAAa,IAAI,oBAAoB,EACrC,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAE/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAI1C,sFAAsF;AACtF,wBAAgB,eAAe,IAAI,QAAQ,CAI1C"}
|
|
@@ -18,7 +18,16 @@ export declare const DEFAULT_MODEL = "joelbarmettler/gheim-ch-560m";
|
|
|
18
18
|
export interface LocalDetectorOptions {
|
|
19
19
|
/** HuggingFace model id (must be a token-classification model). */
|
|
20
20
|
model?: string;
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Backend selector. Defaults to `"auto"`, which:
|
|
23
|
+
* - in the browser, probes `navigator.gpu.requestAdapter()` and uses
|
|
24
|
+
* WebGPU if a real adapter is available, otherwise WASM. If WebGPU
|
|
25
|
+
* loading throws (shader compile, OOM, driver bug) it falls back
|
|
26
|
+
* to WASM transparently.
|
|
27
|
+
* - in Node, just uses WASM (no WebGPU bindings).
|
|
28
|
+
* Pass `"webgpu"`, `"wasm"`, `"cpu"`, etc. to force a specific backend
|
|
29
|
+
* (no probe, no fallback — your choice is respected and may throw).
|
|
30
|
+
*/
|
|
22
31
|
device?: string;
|
|
23
32
|
/** Quantization dtype: "fp32" | "fp16" | "q8" | "q4" | "auto" */
|
|
24
33
|
dtype?: string;
|
|
@@ -38,19 +47,72 @@ export interface LocalDetectorOptions {
|
|
|
38
47
|
batchSize?: number;
|
|
39
48
|
/** Optional pre-built pipeline instance (e.g. for tests). */
|
|
40
49
|
pipelineInstance?: unknown;
|
|
50
|
+
/**
|
|
51
|
+
* Optional callback fired during model loading. Receives a normalized
|
|
52
|
+
* event so consumers don't need to reconcile transformers.js's
|
|
53
|
+
* 0-1-vs-0-100 inconsistency or its raw status strings. Useful for
|
|
54
|
+
* driving a download progress bar.
|
|
55
|
+
*/
|
|
56
|
+
onProgress?: (event: LocalDetectorLoadEvent) => void;
|
|
41
57
|
}
|
|
58
|
+
/** Normalized model-load event surfaced to {@link LocalDetectorOptions.onProgress}. */
|
|
59
|
+
export interface LocalDetectorLoadEvent {
|
|
60
|
+
/** Phase of the load. */
|
|
61
|
+
phase: "initiate" | "download" | "progress" | "ready" | "done";
|
|
62
|
+
/** File being processed, when applicable. */
|
|
63
|
+
file?: string;
|
|
64
|
+
/** Bytes downloaded so far (only on `phase: "progress"`). */
|
|
65
|
+
loadedBytes?: number;
|
|
66
|
+
/** Total bytes for `file` (only on `phase: "progress"`). */
|
|
67
|
+
totalBytes?: number;
|
|
68
|
+
/** Fraction in [0, 1] (only on `phase: "progress"`). Normalized so
|
|
69
|
+
* consumers can use the value directly without bounds-clamping. */
|
|
70
|
+
fraction?: number;
|
|
71
|
+
/** Backend currently being attempted (e.g. `"webgpu"`, `"wasm"`).
|
|
72
|
+
* When auto-fallback fires, two phase-streams may be observed: one
|
|
73
|
+
* for the failed `"webgpu"` attempt, then a fresh stream for `"wasm"`. */
|
|
74
|
+
device?: string;
|
|
75
|
+
}
|
|
76
|
+
interface DetectionItem {
|
|
77
|
+
start?: number;
|
|
78
|
+
end?: number;
|
|
79
|
+
word?: string;
|
|
80
|
+
entity?: string;
|
|
81
|
+
entity_group?: string;
|
|
82
|
+
score?: number;
|
|
83
|
+
}
|
|
84
|
+
type PipelineCallable = (text: string | string[], opts?: {
|
|
85
|
+
aggregation_strategy?: string;
|
|
86
|
+
batch_size?: number;
|
|
87
|
+
}) => Promise<DetectionItem[] | DetectionItem[][]>;
|
|
42
88
|
export declare class LocalDetector implements Detector {
|
|
43
89
|
readonly model: string;
|
|
90
|
+
/** Device preference as passed to the constructor (`"auto"`, `"webgpu"`, ...). */
|
|
44
91
|
readonly device: string;
|
|
45
92
|
readonly dtype: string;
|
|
46
93
|
readonly aggregationStrategy: string;
|
|
47
94
|
readonly chunkTokens: number;
|
|
48
95
|
readonly chunkOverlapTokens: number;
|
|
49
96
|
readonly batchSize: number;
|
|
97
|
+
/** Backend that ended up being used after `load()` resolves. `null` until
|
|
98
|
+
* the model is loaded. Different from {@link device} only when
|
|
99
|
+
* `device: "auto"` was requested. */
|
|
100
|
+
actualDevice: string | null;
|
|
50
101
|
private _pipeline;
|
|
51
102
|
private _loadPromise;
|
|
103
|
+
private readonly _onProgress?;
|
|
52
104
|
constructor(opts?: LocalDetectorOptions);
|
|
53
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Load the model. Idempotent; concurrent calls share a single load.
|
|
107
|
+
* With `device: "auto"`, probes `navigator.gpu.requestAdapter()` and
|
|
108
|
+
* walks the candidate-backend list, falling back from WebGPU to WASM
|
|
109
|
+
* if construction throws (and reporting both attempts via `onProgress`).
|
|
110
|
+
*/
|
|
111
|
+
load(): Promise<PipelineCallable>;
|
|
112
|
+
/** Build the ordered list of backends to attempt. */
|
|
113
|
+
private _planDeviceSequence;
|
|
114
|
+
/** Translate a raw transformers.js progress callback into our normalized event. */
|
|
115
|
+
private _emitProgress;
|
|
54
116
|
detect(text: string, opts?: {
|
|
55
117
|
model?: string;
|
|
56
118
|
}): Promise<Span[]>;
|
|
@@ -65,4 +127,5 @@ export declare class LocalDetector implements Detector {
|
|
|
65
127
|
}): Promise<Span[][]>;
|
|
66
128
|
private chunkText;
|
|
67
129
|
}
|
|
130
|
+
export {};
|
|
68
131
|
//# sourceMappingURL=local.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../src/detectors/local.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEhD,eAAO,MAAM,aAAa,iCAAiC,CAAC;AAQ5D,0EAA0E;AAC1E,MAAM,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../src/detectors/local.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEhD,eAAO,MAAM,aAAa,iCAAiC,CAAC;AAQ5D,0EAA0E;AAC1E,MAAM,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;CACtD;AAED,uFAAuF;AACvF,MAAM,WAAW,sBAAsB;IACrC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G,IAAI,CAAQ;IACnC,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,YAAY,CAA0C;IAC9D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAA0C;gBAE3D,IAAI,GAAE,oBAAyB;IAsB3C;;;;;OAKG;IACG,IAAI,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAkCvC,qDAAqD;YACvC,mBAAmB;IAmBjC,mFAAmF;IACnF,OAAO,CAAC,aAAa;IAqBf,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAYtE;;;;;OAKG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;YAyFlE,SAAS;CAkBxB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,13 +8,16 @@
|
|
|
8
8
|
* - StreamDeanonymizer (low-level)
|
|
9
9
|
*/
|
|
10
10
|
export { Session } from "./core/session.ts";
|
|
11
|
+
export type { Normalizer, SessionOptions } from "./core/session.ts";
|
|
11
12
|
export { LABEL_TO_TAG, SENTINEL_RE, isPossibleSentinelPrefix, labelTag, parseSentinel, renderSentinel, } from "./core/sentinels.ts";
|
|
12
13
|
export type { Sentinel } from "./core/sentinels.ts";
|
|
13
14
|
export { StreamDeanonymizer } from "./core/stream.ts";
|
|
14
15
|
export type { Detector, Span } from "./detectors/base.ts";
|
|
15
16
|
export { DEFAULT_BASE_URL, REMOTE_DEFAULT_MODEL, RemoteDetector, LocalDetector, defaultDetector, } from "./detectors/index.ts";
|
|
16
|
-
export type { RemoteDetectorOptions, LocalDetectorOptions } from "./detectors/index.ts";
|
|
17
|
+
export type { RemoteDetectorOptions, LocalDetectorOptions, LocalDetectorLoadEvent, } from "./detectors/index.ts";
|
|
17
18
|
export { anonymizeMessages, anonymizeText, deanonymizeStream, deanonymizeText, } from "./plain.ts";
|
|
18
19
|
export type { ChatMessage } from "./plain.ts";
|
|
19
|
-
export declare const VERSION = "0.1.
|
|
20
|
+
export declare const VERSION = "0.1.2";
|
|
21
|
+
export { mergeAdjacent } from "./core/session.ts";
|
|
22
|
+
export type { MergedSpan } from "./core/session.ts";
|
|
20
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,WAAW,EACX,wBAAwB,EACxB,QAAQ,EACR,aAAa,EACb,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,wBAAwB,EACxB,QAAQ,EACR,aAAa,EACb,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAK9C,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -43,9 +43,12 @@
|
|
|
43
43
|
/**
|
|
44
44
|
* A normalizer takes a raw surface and returns a canonical form, or
|
|
45
45
|
* `null` if the surface is unparseable (caller falls back to the
|
|
46
|
-
* default NFKC+lowercase key).
|
|
46
|
+
* default NFKC+lowercase key). Re-exported from the core for ergonomics
|
|
47
|
+
* — the canonical declaration lives in `core/session.ts` so that the
|
|
48
|
+
* main `gheim` entry doesn't pull in `node:module`.
|
|
47
49
|
*/
|
|
48
|
-
export type Normalizer
|
|
50
|
+
export type { Normalizer } from "./core/session.ts";
|
|
51
|
+
type Normalizer = (s: string) => string | null;
|
|
49
52
|
/** Options for {@link e164}. */
|
|
50
53
|
export interface E164Options {
|
|
51
54
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizers.d.ts","sourceRoot":"","sources":["../../src/normalizers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH
|
|
1
|
+
{"version":3,"file":"normalizers.d.ts","sourceRoot":"","sources":["../../src/normalizers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH;;;;;;GAMG;AACH,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,KAAK,UAAU,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;AAE/C,gCAAgC;AAChC,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAgDD;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,WAAgB,GAAG,UAAU,CAavD;AAED,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CACvE;AAmBD;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,GAAE,cAAmB,GAAG,UAAU,CAQ7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,IAAI,UAAU,CAclD;AAQD,iEAAiE;AACjE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAUvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_chat.d.ts","sourceRoot":"","sources":["../../../src/openai/_chat.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,OAAO,KAAK,WAAW,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAqC,KAAK,UAAU,EAAsB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"_chat.d.ts","sourceRoot":"","sources":["../../../src/openai/_chat.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,OAAO,KAAK,WAAW,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAqC,KAAK,UAAU,EAAsB,MAAM,YAAY,CAAC;AAoIpG,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,EACnC,UAAU,EAAE,QAAQ;IAGjC,MAAM,CACV,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,sCAAsC,GAAG,UAAU,GACrF,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC;IACjD,MAAM,CACV,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,mCAAmC,GAAG,UAAU,GAClF,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;CAoB5E;AAED,qBAAa,SAAS;IACpB,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;gBAC/B,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ;CAGpE"}
|
|
@@ -6,13 +6,26 @@ import { GheimChat } from "./_chat.ts";
|
|
|
6
6
|
import { GheimCompletions } from "./_completions.ts";
|
|
7
7
|
import { GheimResponses } from "./_responses.ts";
|
|
8
8
|
import { GheimEmbeddings, GheimImages, GheimModerations } from "./_anonymize_only.ts";
|
|
9
|
-
|
|
9
|
+
/** Options for constructing a gheim-wrapped OpenAI client.
|
|
10
|
+
*
|
|
11
|
+
* gheim-specific keys (`gheimDetector`, `gheimStrict`, `openaiClient`,
|
|
12
|
+
* `clientOptions`) configure the wrapper itself. Any other key is
|
|
13
|
+
* forwarded to the underlying `new OpenAI(...)` constructor — so
|
|
14
|
+
* `apiKey`, `baseURL`, `organization` etc. work at the top level, like
|
|
15
|
+
* the openai SDK itself. This mirrors gheim-py's behavior, where
|
|
16
|
+
* everything except `gheim_*` kwargs gets forwarded via `**kwargs`.
|
|
17
|
+
*
|
|
18
|
+
* If both top-level passthrough AND `clientOptions` carry the same key,
|
|
19
|
+
* the top-level value wins.
|
|
20
|
+
*/
|
|
21
|
+
export interface GheimOpenAIOptions extends Omit<NonNullable<ConstructorParameters<typeof OpenAIClass>[0]>, never> {
|
|
10
22
|
gheimDetector?: Detector;
|
|
11
23
|
/** Strict mode: raise on access to unwrapped endpoints. Default true. */
|
|
12
24
|
gheimStrict?: boolean;
|
|
13
25
|
/** Pre-built openai client to wrap (useful for tests). */
|
|
14
26
|
openaiClient?: OpenAIClass;
|
|
15
|
-
/**
|
|
27
|
+
/** Explicit shape for the inner `new OpenAI(...)` opts. Any key here is
|
|
28
|
+
* overridden by the same key passed at the top level. */
|
|
16
29
|
clientOptions?: ConstructorParameters<typeof OpenAIClass>[0];
|
|
17
30
|
}
|
|
18
31
|
export declare class OpenAI {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_client.d.ts","sourceRoot":"","sources":["../../../src/openai/_client.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,OAAO,KAAK,WAAW,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,eAAe,EACf,WAAW,EACX,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAG9B,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"_client.d.ts","sourceRoot":"","sources":["../../../src/openai/_client.ts"],"names":[],"mapp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CAAC;IAC9B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAuB;gBAE1C,IAAI,GAAE,kBAAuB;IA+CnC,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC;CAGpC;AAED,eAAO,MAAM,WAAW,eAAS,CAAC;AAClC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gheim",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "PII round-trip for LLM APIs: anonymize before the request, de-anonymize the stream on the way back.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Joel Barmettler <joel.barmettler@gmail.com>",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
],
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "rm -rf dist && bun run build:esm && bun run build:cjs && bun run build:types",
|
|
53
|
-
"build:esm": "bun build ./src/index.ts ./src/openai/index.ts --outdir ./dist/esm --target
|
|
53
|
+
"build:esm": "bun build ./src/index.ts ./src/openai/index.ts --outdir ./dist/esm --target browser --format esm --external openai --external @huggingface/transformers --external libphonenumber-js --external chrono-node --external node:module",
|
|
54
54
|
"build:cjs": "bun build ./src/index.ts ./src/openai/index.ts --outdir ./dist/cjs --target node --format cjs --entry-naming '[dir]/[name].cjs' --external openai --external @huggingface/transformers",
|
|
55
55
|
"build:types": "tsc --emitDeclarationOnly --outDir dist/types",
|
|
56
56
|
"test": "bun test",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@huggingface/transformers": ">=3.0.0 <5.0.0",
|
|
70
70
|
"chrono-node": "^2.7.0",
|
|
71
71
|
"libphonenumber-js": "^1.10.0",
|
|
72
|
-
"openai": ">=4.0.0 <
|
|
72
|
+
"openai": ">=4.0.0 <7.0.0"
|
|
73
73
|
},
|
|
74
74
|
"peerDependenciesMeta": {
|
|
75
75
|
"openai": {
|