@memberjunction/ai-gemini 6.2.0-edge.4 → 6.2.0-edge.5
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/geminiEmbedding.d.ts +11 -0
- package/dist/geminiEmbedding.d.ts.map +1 -1
- package/dist/geminiEmbedding.js +34 -12
- package/dist/geminiEmbedding.js.map +1 -1
- package/dist/geminiImage.d.ts +10 -3
- package/dist/geminiImage.d.ts.map +1 -1
- package/dist/geminiImage.js +84 -14
- package/dist/geminiImage.js.map +1 -1
- package/dist/geminiLiveSetup.d.ts +1 -1
- package/dist/geminiLiveSetup.js +4 -4
- package/dist/geminiLiveSetup.js.map +1 -1
- package/dist/geminiRealtime.d.ts +20 -2
- package/dist/geminiRealtime.d.ts.map +1 -1
- package/dist/geminiRealtime.js +50 -10
- package/dist/geminiRealtime.js.map +1 -1
- package/dist/geminiSampling.d.ts +30 -0
- package/dist/geminiSampling.d.ts.map +1 -0
- package/dist/geminiSampling.js +44 -0
- package/dist/geminiSampling.js.map +1 -0
- package/dist/geminiThinking.d.ts +54 -0
- package/dist/geminiThinking.d.ts.map +1 -0
- package/dist/geminiThinking.js +107 -0
- package/dist/geminiThinking.js.map +1 -0
- package/dist/index.d.ts +58 -45
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +171 -309
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ export declare class GeminiLLM extends BaseLLM {
|
|
|
17
17
|
private _geminiPromise;
|
|
18
18
|
private _streamingState;
|
|
19
19
|
private _cacheDiagContext;
|
|
20
|
-
private _streamingCancellationToken;
|
|
21
20
|
constructor(apiKey: string);
|
|
22
21
|
/**
|
|
23
22
|
* Factory method to create the GoogleGenAI client instance
|
|
@@ -40,31 +39,6 @@ export declare class GeminiLLM extends BaseLLM {
|
|
|
40
39
|
* Note: This is async now because the client may not be initialized yet
|
|
41
40
|
*/
|
|
42
41
|
get GeminiClient(): GoogleGenAI;
|
|
43
|
-
/**
|
|
44
|
-
* Convert MJ effort level (1-100) to Gemini thinkingBudget (0-24576)
|
|
45
|
-
*
|
|
46
|
-
* Mapping strategy:
|
|
47
|
-
* - 1 (minimal): 0 (disabled) on Flash; clamped to ~1024 on Pro
|
|
48
|
-
* - 2-33 (low): 1024-4096 tokens
|
|
49
|
-
* - 34-66 (medium): 4097-12288 tokens
|
|
50
|
-
* - 67-100 (high): 12289-24576 tokens
|
|
51
|
-
* - undefined: No thinkingConfig (Gemini default ~8192)
|
|
52
|
-
*
|
|
53
|
-
* Model-specific behavior:
|
|
54
|
-
* - Gemini 2.5 Flash/Flash-Lite: Can disable thinking with budget=0
|
|
55
|
-
* - Gemini 2.5 Pro: Cannot disable thinking, minimum ~1024
|
|
56
|
-
* - Gemini 3 models: Use thinkingLevel instead (future consideration)
|
|
57
|
-
*
|
|
58
|
-
* @param effortLevel - MJ normalized effort level (1-100) as string or number
|
|
59
|
-
* @param modelName - The Gemini model name to check capabilities
|
|
60
|
-
* @returns thinkingBudget value or undefined for default behavior
|
|
61
|
-
*/
|
|
62
|
-
private getThinkingBudget;
|
|
63
|
-
/**
|
|
64
|
-
* Check if a model supports thinking configuration
|
|
65
|
-
* Thinking is supported on Gemini 2.5+ models
|
|
66
|
-
*/
|
|
67
|
-
private supportsThinking;
|
|
68
42
|
/**
|
|
69
43
|
* Gemini supports streaming
|
|
70
44
|
*/
|
|
@@ -79,11 +53,6 @@ export declare class GeminiLLM extends BaseLLM {
|
|
|
79
53
|
* Implementation of non-streaming chat completion for Gemini
|
|
80
54
|
*/
|
|
81
55
|
protected nonStreamingChatCompletion(params: ChatParams): Promise<ChatResult>;
|
|
82
|
-
/**
|
|
83
|
-
* Attach the caller's cancellation token to a Gemini per-request config. @google/genai reads
|
|
84
|
-
* `GenerateContentConfig.abortSignal` and forwards it to the underlying `fetch` call, so an
|
|
85
|
-
* abort tears down the HTTP socket instead of merely abandoning the promise.
|
|
86
|
-
*/
|
|
87
56
|
/**
|
|
88
57
|
* Maps the neutral {@link ChatParams.tools} onto Gemini's `tools` / `toolConfig` request fields.
|
|
89
58
|
*
|
|
@@ -121,21 +90,65 @@ export declare class GeminiLLM extends BaseLLM {
|
|
|
121
90
|
* @returns The normalized calls, or undefined when the model called nothing
|
|
122
91
|
*/
|
|
123
92
|
private extractToolCalls;
|
|
93
|
+
/**
|
|
94
|
+
* Attach the caller's cancellation token to a Gemini per-request config. @google/genai reads
|
|
95
|
+
* `GenerateContentConfig.abortSignal` and forwards it to the underlying `fetch` call, so an
|
|
96
|
+
* abort tears down the HTTP socket instead of merely abandoning the promise.
|
|
97
|
+
*/
|
|
124
98
|
private applyCancellationToken;
|
|
125
|
-
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Model + field pairs already warned about, so a prompt that sets `temperature` on every call
|
|
101
|
+
* logs once per process instead of once per request.
|
|
102
|
+
*/
|
|
103
|
+
private static readonly _warnedUnsupportedSampling;
|
|
104
|
+
/**
|
|
105
|
+
* Builds the per-request generation options: sampling, stop sequences, seed, response format.
|
|
106
|
+
*
|
|
107
|
+
* Sampling fields depend on the model's version. Models before Gemini 3.6 keep the original
|
|
108
|
+
* shape (`temperature` defaulting to 0.5, `topP`, `topK`) because they still honor it. Every
|
|
109
|
+
* other model gets none of the three: Google ignores them since Gemini 3.6 Flash and upcoming
|
|
110
|
+
* models reject them with a 400, so a caller-supplied value is dropped with a one-time warning.
|
|
111
|
+
*
|
|
112
|
+
* A `ModelSpecific` response format is merged in after this gate, so it can still set these
|
|
113
|
+
* fields explicitly; that is the caller's deliberate override.
|
|
114
|
+
*/
|
|
115
|
+
private buildGenerationOptions;
|
|
116
|
+
private warnUnsupportedSampling;
|
|
117
|
+
/**
|
|
118
|
+
* Thinking settings a model rejected in this process, mapped to what was sent instead (`null`
|
|
119
|
+
* for no setting). Keyed by driver, model and setting, so a rejected `MINIMAL` does not stop
|
|
120
|
+
* `HIGH` being sent, and a rejection through one driver does not affect another.
|
|
121
|
+
*/
|
|
122
|
+
private static readonly _thinkingReplacements;
|
|
123
|
+
/** Thinking warnings already logged, so each is logged once per process. */
|
|
124
|
+
private static readonly _warnedThinking;
|
|
125
|
+
private thinkingReplacementKey;
|
|
126
|
+
/**
|
|
127
|
+
* Puts the `thinkingConfig` for `effortLevel` on the request (see {@link ResolveGeminiThinkingConfig}),
|
|
128
|
+
* or what replaced it after the model rejected it earlier in this process. Nothing is added when
|
|
129
|
+
* no effort is set; an effort that cannot be used is reported once.
|
|
130
|
+
*/
|
|
131
|
+
private applyThinkingConfig;
|
|
132
|
+
/**
|
|
133
|
+
* Sends a request, and when it carried a thinking setting and Google answered 400, sends it once
|
|
134
|
+
* more with the setting's fallback (see {@link GeminiThinkingFallback}: `LOW` for a rejected
|
|
135
|
+
* `MINIMAL`, otherwise none). Which levels a model accepts varies (Gemini 3.8 Flash rejects
|
|
136
|
+
* `MINIMAL`), so an unsupported level must not fail the request. When the retry succeeds, the
|
|
137
|
+
* rejected setting is replaced for this driver and model for the rest of the process; when it also
|
|
138
|
+
* fails, the 400 had another cause, so the original error is thrown and nothing is remembered.
|
|
139
|
+
*/
|
|
140
|
+
private sendWithThinkingFallback;
|
|
141
|
+
private warnThinkingOnce;
|
|
142
|
+
/**
|
|
143
|
+
* Normalizes Gemini usage to the {@link ModelUsage} contract.
|
|
144
|
+
*
|
|
145
|
+
* - `promptTokenCount` includes cached tokens, reported separately as `cachedContentTokenCount`,
|
|
146
|
+
* so the cached count is subtracted (clamped at 0) and recorded as `cacheReadTokens`. Gemini
|
|
147
|
+
* reports no separate cache-write charge.
|
|
148
|
+
* - `candidatesTokenCount` leaves out thinking, which Google counts in `thoughtsTokenCount` and
|
|
149
|
+
* bills as output, so completion tokens are the sum of the two.
|
|
150
|
+
*/
|
|
151
|
+
private static usageFromMetadata;
|
|
139
152
|
/**
|
|
140
153
|
* Reset streaming state for a new request
|
|
141
154
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAY,OAAO,EAAE,IAAI,EAAmJ,MAAM,eAAe,CAAC;AAGtN,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAA0B,kBAAkB,EAAsD,gBAAgB,EAAuF,MAAM,oBAAoB,CAAC;AAyC3T;;;;;;;;;;GAUG;AACH,eAAO,MAAM,6BAA6B,gEAAgE,CAAC;AAE3G,qBACa,SAAU,SAAQ,OAAO;IAClC,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAQ;IAC7C,OAAO,CAAC,cAAc,CAAqC;IAG3D,OAAO,CAAC,eAAe,CAUrB;IAIF,OAAO,CAAC,iBAAiB,CAAuC;gBAEpD,MAAM,EAAE,MAAM;IAM1B;;;;;OAKG;cACa,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC;IAIpD;;;OAGG;YACW,kBAAkB;IAahC;;OAEG;IACa,mBAAmB,IAAI,gBAAgB,GAAG,IAAI;IAe9D;;;OAGG;IACH,IAAW,YAAY,IAAI,WAAW,CAKrC;IAED;;OAEG;IACH,IAAoB,iBAAiB,IAAI,OAAO,CAE/C;IAED;;;OAGG;IACH,IAAoB,aAAa,IAAI,OAAO,CAE3C;IAED,SAAS,CAAC,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE;IAqC9D;;OAEG;cACa,0BAA0B,CAAC,MAAM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