dsh-custom-api 1.0.2 → 1.0.3
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/lib/index.js +29 -7
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -82,8 +82,9 @@ const GEMINI_LEVELS = Object.freeze({
|
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
function geminiEfforts(id) {
|
|
85
|
-
const norm =
|
|
86
|
-
const
|
|
85
|
+
const norm = normalizeModelId(id);
|
|
86
|
+
const tail = String(id).toLowerCase().split('/').pop() || '';
|
|
87
|
+
const documented = GEMINI_LEVELS[tail] || GEMINI_LEVELS[norm] || ['low', 'medium', 'high'];
|
|
87
88
|
const efforts = { off: null };
|
|
88
89
|
for (const level of documented) efforts[level] = level;
|
|
89
90
|
if (!efforts.medium) efforts.medium = efforts.high || 'medium';
|
|
@@ -146,6 +147,16 @@ function buildModelsDevIndex(data) {
|
|
|
146
147
|
isLoaded = true;
|
|
147
148
|
}
|
|
148
149
|
|
|
150
|
+
// Synchronously load cache on module import if exists
|
|
151
|
+
try {
|
|
152
|
+
if (fs.existsSync(CACHE_PATH)) {
|
|
153
|
+
const content = fs.readFileSync(CACHE_PATH, 'utf8');
|
|
154
|
+
buildModelsDevIndex(JSON.parse(content));
|
|
155
|
+
}
|
|
156
|
+
} catch {
|
|
157
|
+
// Ignore sync read error, will be retried in initModelsDevDatabase
|
|
158
|
+
}
|
|
159
|
+
|
|
149
160
|
async function initModelsDevDatabase(logger) {
|
|
150
161
|
try {
|
|
151
162
|
if (fs.existsSync(CACHE_PATH)) {
|
|
@@ -329,11 +340,22 @@ function determineReasoningEfforts(id, model, dev, forceThinking) {
|
|
|
329
340
|
let isThinking = forceThinking;
|
|
330
341
|
if (!isThinking) {
|
|
331
342
|
if (typeof model?.supports_thinking === 'boolean') isThinking = model.supports_thinking;
|
|
343
|
+
else if (model?.reasoningEfforts && typeof model.reasoningEfforts === 'object') isThinking = true;
|
|
332
344
|
else if (dev?.reasoning === true) isThinking = true;
|
|
333
|
-
else if (THINKING_MODEL_ID.test(String(id))) isThinking = true;
|
|
334
345
|
else {
|
|
335
|
-
const
|
|
336
|
-
isThinking =
|
|
346
|
+
const s = String(id).toLowerCase();
|
|
347
|
+
isThinking = (
|
|
348
|
+
s.includes('r1') || s.includes('o1') || s.includes('o3') || s.includes('o4') ||
|
|
349
|
+
s.includes('reason') || s.includes('think') || s.includes('thought') ||
|
|
350
|
+
s.includes('qwq') || s.includes('qvq') ||
|
|
351
|
+
s.includes('gemini-2.5') || s.includes('gemini-3') || s.includes('gemini-4') ||
|
|
352
|
+
(s.includes('claude') && (s.includes('3-7') || s.includes('3.7') || s.includes('sonnet') || s.includes('opus') || s.includes('4') || s.includes('5'))) ||
|
|
353
|
+
s.includes('gpt-5') || s.includes('gpt-6') ||
|
|
354
|
+
s.includes('grok-4') || s.includes('grok-3') ||
|
|
355
|
+
s.includes('glm-5') || s.includes('deepseek-v4') ||
|
|
356
|
+
s.includes('qwen-3') || s.includes('qwen3') ||
|
|
357
|
+
THINKING_DESCRIPTION.test(typeof model?.description === 'string' ? model.description : '')
|
|
358
|
+
);
|
|
337
359
|
}
|
|
338
360
|
}
|
|
339
361
|
|
|
@@ -389,7 +411,7 @@ function isImageGenerationEndpoint(id, dev) {
|
|
|
389
411
|
/**
|
|
390
412
|
* Giải quyết và gán năng lực hoàn chỉnh cho một model
|
|
391
413
|
*/
|
|
392
|
-
function resolveCapabilities(rawModel, opts = {}) {
|
|
414
|
+
export function resolveCapabilities(rawModel, opts = {}) {
|
|
393
415
|
const id = typeof rawModel === 'string' ? rawModel : rawModel.id;
|
|
394
416
|
const dev = lookupModelsDev(id);
|
|
395
417
|
const apiMeta = extractFromApiMetadata(rawModel);
|
|
@@ -976,7 +998,7 @@ export function apply(ctx) {
|
|
|
976
998
|
maxTokens: Math.min(m.maxTokens || cap.modelEntry.maxTokens, m.contextWindow || cap.modelEntry.contextWindow),
|
|
977
999
|
};
|
|
978
1000
|
|
|
979
|
-
if (cap.hasThinking
|
|
1001
|
+
if (cap.hasThinking) {
|
|
980
1002
|
merged.reasoningEfforts = cap.modelEntry.reasoningEfforts;
|
|
981
1003
|
if (p.api === 'openai-completions') {
|
|
982
1004
|
const s = (m.id || '').toLowerCase();
|
package/package.json
CHANGED