@jaypie/llm 1.2.12 → 1.2.14
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/constants.d.ts +1 -1
- package/dist/cjs/index.cjs +32 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/operate/adapters/GeminiAdapter.d.ts +1 -1
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/index.js +32 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operate/adapters/GeminiAdapter.d.ts +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ import { GeminiPart, GeminiRawResponse, GeminiRequest } from "../../providers/ge
|
|
|
12
12
|
* specific to Gemini's generateContent API.
|
|
13
13
|
*/
|
|
14
14
|
export declare class GeminiAdapter extends BaseProviderAdapter {
|
|
15
|
-
readonly name: "
|
|
15
|
+
readonly name: "google";
|
|
16
16
|
readonly defaultModel: "gemini-3-pro-preview";
|
|
17
17
|
buildRequest(request: OperateRequest): GeminiRequest;
|
|
18
18
|
formatTools(toolkit: Toolkit, outputSchema?: JsonObject): ProviderToolDefinition[];
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare const PROVIDER: {
|
|
|
32
32
|
readonly TINY: "gemini-3-flash-preview";
|
|
33
33
|
};
|
|
34
34
|
readonly MODEL_MATCH_WORDS: readonly ["gemini", "google"];
|
|
35
|
-
readonly NAME: "
|
|
35
|
+
readonly NAME: "google";
|
|
36
36
|
readonly ROLE: {
|
|
37
37
|
readonly MODEL: "model";
|
|
38
38
|
readonly USER: "user";
|
package/dist/esm/index.js
CHANGED
|
@@ -79,7 +79,7 @@ const PROVIDER = {
|
|
|
79
79
|
TINY: FIRST_CLASS_PROVIDER.GEMINI.TINY,
|
|
80
80
|
},
|
|
81
81
|
MODEL_MATCH_WORDS: ["gemini", "google"],
|
|
82
|
-
NAME: "
|
|
82
|
+
NAME: "google",
|
|
83
83
|
ROLE: {
|
|
84
84
|
MODEL: "model",
|
|
85
85
|
USER: "user",
|
|
@@ -194,7 +194,7 @@ function determineModelProvider(input) {
|
|
|
194
194
|
provider: PROVIDER.ANTHROPIC.NAME,
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
|
-
if (input === PROVIDER.GEMINI.NAME) {
|
|
197
|
+
if (input === PROVIDER.GEMINI.NAME || input === "gemini") {
|
|
198
198
|
return {
|
|
199
199
|
model: PROVIDER.GEMINI.MODEL.DEFAULT,
|
|
200
200
|
provider: PROVIDER.GEMINI.NAME,
|
|
@@ -2095,7 +2095,17 @@ class GeminiAdapter extends BaseProviderAdapter {
|
|
|
2095
2095
|
return JSON.parse(textContent);
|
|
2096
2096
|
}
|
|
2097
2097
|
catch {
|
|
2098
|
-
//
|
|
2098
|
+
// Strip markdown code fences and retry (Gemini sometimes wraps JSON in fences)
|
|
2099
|
+
const jsonMatch = textContent.match(/```(?:json)?\s*([\s\S]*?)\s*```/) ||
|
|
2100
|
+
textContent.match(/\{[\s\S]*\}/);
|
|
2101
|
+
if (jsonMatch) {
|
|
2102
|
+
try {
|
|
2103
|
+
return JSON.parse(jsonMatch[1] || jsonMatch[0]);
|
|
2104
|
+
}
|
|
2105
|
+
catch {
|
|
2106
|
+
// Fall through to return original string
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2099
2109
|
return textContent;
|
|
2100
2110
|
}
|
|
2101
2111
|
}
|
|
@@ -5141,6 +5151,17 @@ class GeminiProvider {
|
|
|
5141
5151
|
return JSON.parse(text);
|
|
5142
5152
|
}
|
|
5143
5153
|
catch {
|
|
5154
|
+
// Strip markdown code fences and retry (Gemini sometimes wraps JSON in fences)
|
|
5155
|
+
const jsonMatch = text.match(/```(?:json)?\s*([\s\S]*?)\s*```/) ||
|
|
5156
|
+
text.match(/\{[\s\S]*\}/);
|
|
5157
|
+
if (jsonMatch) {
|
|
5158
|
+
try {
|
|
5159
|
+
return JSON.parse(jsonMatch[1] || jsonMatch[0]);
|
|
5160
|
+
}
|
|
5161
|
+
catch {
|
|
5162
|
+
// Fall through to return original text
|
|
5163
|
+
}
|
|
5164
|
+
}
|
|
5144
5165
|
return text || "";
|
|
5145
5166
|
}
|
|
5146
5167
|
}
|
|
@@ -5516,6 +5537,10 @@ class Llm {
|
|
|
5516
5537
|
const { fallback, model } = options;
|
|
5517
5538
|
let finalProvider = providerName;
|
|
5518
5539
|
let finalModel = model;
|
|
5540
|
+
// Legacy: accept "gemini" but warn
|
|
5541
|
+
if (providerName === "gemini") {
|
|
5542
|
+
log$3.warn(`Provider "gemini" is deprecated, use "${PROVIDER.GEMINI.NAME}" instead`);
|
|
5543
|
+
}
|
|
5519
5544
|
if (model) {
|
|
5520
5545
|
const modelDetermined = determineModelProvider(model);
|
|
5521
5546
|
finalModel = modelDetermined.model;
|
|
@@ -5530,6 +5555,10 @@ class Llm {
|
|
|
5530
5555
|
throw new ConfigurationError(`Unable to determine provider from: ${providerName}`);
|
|
5531
5556
|
}
|
|
5532
5557
|
finalProvider = providerDetermined.provider;
|
|
5558
|
+
// When providerName is actually a model name, extract the model (#213)
|
|
5559
|
+
if (!finalModel && providerName !== providerDetermined.provider) {
|
|
5560
|
+
finalModel = providerDetermined.model;
|
|
5561
|
+
}
|
|
5533
5562
|
}
|
|
5534
5563
|
// Handle conflicts: if both providerName and model specify different providers
|
|
5535
5564
|
if (model && providerName !== DEFAULT.PROVIDER.NAME) {
|