ikie-cli 0.1.44 → 0.1.45
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/index.js +19 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -164,22 +164,28 @@ async function main() {
|
|
|
164
164
|
config.requestsPerMinute = Math.floor(rpm);
|
|
165
165
|
}
|
|
166
166
|
// If user hasn't explicitly chosen a model, fetch the server's default.
|
|
167
|
+
// Retry once: the server can be slow on a cold start / right after a deploy,
|
|
168
|
+
// and a single timeout would otherwise silently strand us on the stale
|
|
169
|
+
// config default instead of the current server default.
|
|
167
170
|
if (!argv.model && !hasExplicitModel()) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
171
|
+
const modelsUrl = (config.baseURL ?? IKIE_API_BASE).includes('/api/v1')
|
|
172
|
+
? (config.baseURL ?? IKIE_API_BASE).replace('/api/v1', '/api/models')
|
|
173
|
+
: `${IKIE_HOST}/api/models`;
|
|
174
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
175
|
+
try {
|
|
176
|
+
const res = await fetch(modelsUrl, { signal: AbortSignal.timeout(8000) });
|
|
177
|
+
if (res.ok) {
|
|
178
|
+
const data = await res.json();
|
|
179
|
+
const serverDefault = data.models?.find(m => m.is_default);
|
|
180
|
+
if (serverDefault) {
|
|
181
|
+
config.model = serverDefault.name;
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
178
184
|
}
|
|
179
185
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
186
|
+
catch {
|
|
187
|
+
// Retry once, then silently fall back to DEFAULT_MODEL.
|
|
188
|
+
}
|
|
183
189
|
}
|
|
184
190
|
}
|
|
185
191
|
const oneShot = argv._.length > 0 ? argv._.join(' ') : undefined;
|