@jaypie/llm 1.2.12 → 1.2.13
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 +22 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +22 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -2097,7 +2097,17 @@ class GeminiAdapter extends BaseProviderAdapter {
|
|
|
2097
2097
|
return JSON.parse(textContent);
|
|
2098
2098
|
}
|
|
2099
2099
|
catch {
|
|
2100
|
-
//
|
|
2100
|
+
// Strip markdown code fences and retry (Gemini sometimes wraps JSON in fences)
|
|
2101
|
+
const jsonMatch = textContent.match(/```(?:json)?\s*([\s\S]*?)\s*```/) ||
|
|
2102
|
+
textContent.match(/\{[\s\S]*\}/);
|
|
2103
|
+
if (jsonMatch) {
|
|
2104
|
+
try {
|
|
2105
|
+
return JSON.parse(jsonMatch[1] || jsonMatch[0]);
|
|
2106
|
+
}
|
|
2107
|
+
catch {
|
|
2108
|
+
// Fall through to return original string
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2101
2111
|
return textContent;
|
|
2102
2112
|
}
|
|
2103
2113
|
}
|
|
@@ -5143,6 +5153,17 @@ class GeminiProvider {
|
|
|
5143
5153
|
return JSON.parse(text);
|
|
5144
5154
|
}
|
|
5145
5155
|
catch {
|
|
5156
|
+
// Strip markdown code fences and retry (Gemini sometimes wraps JSON in fences)
|
|
5157
|
+
const jsonMatch = text.match(/```(?:json)?\s*([\s\S]*?)\s*```/) ||
|
|
5158
|
+
text.match(/\{[\s\S]*\}/);
|
|
5159
|
+
if (jsonMatch) {
|
|
5160
|
+
try {
|
|
5161
|
+
return JSON.parse(jsonMatch[1] || jsonMatch[0]);
|
|
5162
|
+
}
|
|
5163
|
+
catch {
|
|
5164
|
+
// Fall through to return original text
|
|
5165
|
+
}
|
|
5166
|
+
}
|
|
5146
5167
|
return text || "";
|
|
5147
5168
|
}
|
|
5148
5169
|
}
|