@serii84/vertex-partner-provider 1.0.26 → 1.0.27
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/index.js +11 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vertex Partner Provider for OpenCode
|
|
3
|
-
* v1.0.
|
|
3
|
+
* v1.0.27 - Ensure finish_reason is always a string
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const fs = require('fs');
|
|
@@ -56,18 +56,22 @@ function cleanResponse(parsed) {
|
|
|
56
56
|
|| choice.finish_reason.stop_reason
|
|
57
57
|
|| 'stop';
|
|
58
58
|
} else {
|
|
59
|
-
cleanChoice.finish_reason = choice.finish_reason;
|
|
59
|
+
cleanChoice.finish_reason = String(choice.finish_reason);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// Clean up delta - remove null values and non-standard fields
|
|
64
|
-
if (
|
|
64
|
+
// Only include delta if there's actual content (not on finish chunks)
|
|
65
|
+
if (choice.delta && !choice.finish_reason) {
|
|
65
66
|
const cleanDelta = {};
|
|
66
67
|
if (choice.delta.role) cleanDelta.role = choice.delta.role;
|
|
67
68
|
if (choice.delta.content) cleanDelta.content = choice.delta.content;
|
|
68
69
|
else if (choice.delta.reasoning_content) cleanDelta.content = choice.delta.reasoning_content;
|
|
69
70
|
if (choice.delta.tool_calls) cleanDelta.tool_calls = choice.delta.tool_calls;
|
|
70
71
|
cleanChoice.delta = cleanDelta;
|
|
72
|
+
} else if (choice.delta) {
|
|
73
|
+
// On finish chunks, include empty delta for compatibility
|
|
74
|
+
cleanChoice.delta = {};
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
if (choice.message) {
|
|
@@ -94,10 +98,13 @@ function cleanResponse(parsed) {
|
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
function transformStream(response) {
|
|
101
|
+
// Log response headers for debugging
|
|
102
|
+
debugLog('Response headers:', Object.fromEntries(response.headers.entries()));
|
|
103
|
+
|
|
97
104
|
const reader = response.body.getReader();
|
|
98
105
|
const decoder = new TextDecoder();
|
|
99
106
|
const encoder = new TextEncoder();
|
|
100
|
-
|
|
107
|
+
|
|
101
108
|
let buffer = '';
|
|
102
109
|
|
|
103
110
|
const transformedStream = new ReadableStream({
|