@mmmbuto/zai-codex-bridge 0.1.4 → 0.1.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/package.json +1 -1
- package/src/server.js +26 -17
package/package.json
CHANGED
package/src/server.js
CHANGED
|
@@ -71,25 +71,34 @@ function translateResponsesToChat(request) {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
//
|
|
75
|
-
if (request.input
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
// Handle input: can be string (simple user message) or array (message history)
|
|
75
|
+
if (request.input) {
|
|
76
|
+
if (typeof request.input === 'string') {
|
|
77
|
+
// Simple string input -> user message
|
|
78
|
+
messages.push({
|
|
79
|
+
role: 'user',
|
|
80
|
+
content: request.input
|
|
81
|
+
});
|
|
82
|
+
} else if (Array.isArray(request.input)) {
|
|
83
|
+
// Array of message objects
|
|
84
|
+
for (const item of request.input) {
|
|
85
|
+
const msg = {
|
|
86
|
+
role: item.role,
|
|
87
|
+
content: flattenContent(item.content)
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Handle tool calls if present
|
|
91
|
+
if (item.tool_calls && Array.isArray(item.tool_calls)) {
|
|
92
|
+
msg.tool_calls = item.tool_calls;
|
|
93
|
+
}
|
|
86
94
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
// Handle tool call ID for tool responses
|
|
96
|
+
if (item.tool_call_id) {
|
|
97
|
+
msg.tool_call_id = item.tool_call_id;
|
|
98
|
+
}
|
|
91
99
|
|
|
92
|
-
|
|
100
|
+
messages.push(msg);
|
|
101
|
+
}
|
|
93
102
|
}
|
|
94
103
|
}
|
|
95
104
|
|