fix: update pi-ai patch and tests
This commit is contained in:
@@ -1,12 +1,42 @@
|
||||
diff --git a/dist/providers/google-shared.js b/dist/providers/google-shared.js
|
||||
index ff9cbcfebfac6b4370d85dc838f5cacf2a60ed64..42096c82aec925b412258348a36ba4a7025b283b 100644
|
||||
--- a/dist/providers/google-shared.js
|
||||
+++ b/dist/providers/google-shared.js
|
||||
@@ -140,6 +140,72 @@ export function convertMessages(model, context) {
|
||||
}
|
||||
@@ -52,19 +52,25 @@
|
||||
}
|
||||
else if (block.type === "thinking") {
|
||||
// Thinking blocks require signatures for Claude via Antigravity.
|
||||
- // If signature is missing (e.g. from GPT-OSS), convert to regular text with delimiters.
|
||||
- if (block.thinkingSignature) {
|
||||
+ // Only send thought signatures for Claude models - Gemini doesn't support them
|
||||
+ // and will mimic <thinking> tags if we include them as text.
|
||||
+ if (block.thinkingSignature && model.id.includes("claude")) {
|
||||
parts.push({
|
||||
thought: true,
|
||||
text: sanitizeSurrogates(block.thinking),
|
||||
thoughtSignature: block.thinkingSignature,
|
||||
});
|
||||
}
|
||||
- else {
|
||||
- parts.push({
|
||||
- text: `<thinking>\n${sanitizeSurrogates(block.thinking)}\n</thinking>`,
|
||||
- });
|
||||
+ else if (!model.id.includes("gemini")) {
|
||||
+ // For non-Gemini, non-Claude models, include as text with delimiters
|
||||
+ // Skip entirely for Gemini to avoid it mimicking the pattern
|
||||
+ if (block.thinking && block.thinking.trim()) {
|
||||
+ parts.push({
|
||||
+ text: `<thinking>\n${sanitizeSurrogates(block.thinking)}\n</thinking>`,
|
||||
+ });
|
||||
+ }
|
||||
}
|
||||
+ // For Gemini models without Claude signature: skip thinking blocks entirely
|
||||
}
|
||||
else if (block.type === "toolCall") {
|
||||
const part = {
|
||||
@@ -147,6 +153,77 @@
|
||||
return contents;
|
||||
}
|
||||
+/**
|
||||
/**
|
||||
+ * Sanitize JSON Schema for Google Cloud Code Assist API.
|
||||
+ * Removes unsupported keywords like patternProperties, const, anyOf, etc.
|
||||
+ * and converts to a format compatible with Google's function declarations.
|
||||
@@ -70,12 +100,18 @@ index ff9cbcfebfac6b4370d85dc838f5cacf2a60ed64..42096c82aec925b412258348a36ba4a7
|
||||
+ sanitized[key] = value;
|
||||
+ }
|
||||
+ }
|
||||
+ // Ensure type: "object" is present when properties or required exist
|
||||
+ // Google API requires type to be set when these fields are present
|
||||
+ if (('properties' in sanitized || 'required' in sanitized) && !('type' in sanitized)) {
|
||||
+ sanitized.type = 'object';
|
||||
+ }
|
||||
+ return sanitized;
|
||||
+}
|
||||
/**
|
||||
+/**
|
||||
* Convert tools to Gemini function declarations format.
|
||||
*/
|
||||
@@ -151,7 +216,7 @@ export function convertTools(tools) {
|
||||
export function convertTools(tools) {
|
||||
@@ -157,7 +234,7 @@
|
||||
functionDeclarations: tools.map((tool) => ({
|
||||
name: tool.name,
|
||||
description: tool.description,
|
||||
@@ -84,15 +120,3 @@ index ff9cbcfebfac6b4370d85dc838f5cacf2a60ed64..42096c82aec925b412258348a36ba4a7
|
||||
})),
|
||||
},
|
||||
];
|
||||
diff --git a/dist/providers/openai-responses.js b/dist/providers/openai-responses.js
|
||||
index 20fb0a22aaa28f7ff7c2f44a8b628fa1d9d7d936..31bae0aface1319487ce62d35f1f3b6ed334863e 100644
|
||||
--- a/dist/providers/openai-responses.js
|
||||
+++ b/dist/providers/openai-responses.js
|
||||
@@ -486,7 +486,6 @@ function convertTools(tools) {
|
||||
name: tool.name,
|
||||
description: tool.description,
|
||||
parameters: tool.parameters, // TypeBox already generates JSON Schema
|
||||
- strict: null,
|
||||
}));
|
||||
}
|
||||
function mapStopReason(status) {
|
||||
|
||||
Reference in New Issue
Block a user