jasper-context-compactor 0.3.3 → 0.3.4
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/cli.js +21 -14
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -51,19 +51,22 @@ async function detectModelContextWindow(config) {
|
|
|
51
51
|
const modelId = config?.agents?.defaults?.model?.primary;
|
|
52
52
|
if (!modelId) return null;
|
|
53
53
|
|
|
54
|
-
// Parse provider/model from the model ID (e.g., "
|
|
54
|
+
// Parse provider/model from the model ID (e.g., "ollama/qwen2.5")
|
|
55
55
|
const [providerName, ...modelParts] = modelId.split('/');
|
|
56
|
-
const modelName = modelParts.join('/');
|
|
56
|
+
const modelName = modelParts.join('/'); // e.g., "qwen2.5"
|
|
57
57
|
|
|
58
58
|
// Look up in config's models.providers
|
|
59
59
|
const providers = config?.models?.providers || {};
|
|
60
60
|
const provider = providers[providerName];
|
|
61
61
|
|
|
62
62
|
if (provider?.models) {
|
|
63
|
-
// Find the model
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
// Find the model - compare against just the model name (without provider prefix)
|
|
64
|
+
// e.g., config has id:"qwen2.5", we're looking for "ollama/qwen2.5"
|
|
65
|
+
const modelConfig = provider.models.find(m => {
|
|
66
|
+
if (!m.id) return false;
|
|
67
|
+
// Match: exact ID, or model name matches, or ID matches without provider prefix
|
|
68
|
+
return m.id === modelId || m.id === modelName || modelName.includes(m.id) || m.id.includes(modelName);
|
|
69
|
+
});
|
|
67
70
|
|
|
68
71
|
if (modelConfig?.contextWindow) {
|
|
69
72
|
return {
|
|
@@ -75,17 +78,21 @@ async function detectModelContextWindow(config) {
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
// Fallback: check
|
|
81
|
+
// Fallback: check ALL providers for a matching model ID
|
|
79
82
|
for (const [pName, pConfig] of Object.entries(providers)) {
|
|
80
83
|
if (pConfig?.models) {
|
|
81
84
|
for (const m of pConfig.models) {
|
|
82
|
-
if (m.id
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
if (!m.id) continue;
|
|
86
|
+
// Flexible matching: model ID contains or is contained by what we're looking for
|
|
87
|
+
if (m.id === modelName || modelName.includes(m.id) || m.id.includes(modelName)) {
|
|
88
|
+
if (m.contextWindow) {
|
|
89
|
+
return {
|
|
90
|
+
model: modelId,
|
|
91
|
+
tokens: m.contextWindow,
|
|
92
|
+
source: 'config',
|
|
93
|
+
maxTokens: m.maxTokens
|
|
94
|
+
};
|
|
95
|
+
}
|
|
89
96
|
}
|
|
90
97
|
}
|
|
91
98
|
}
|
package/package.json
CHANGED