mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
fix(chutes): honor serving context limits (#119196)
This commit is contained in:
@@ -238,6 +238,41 @@ describe("chutes-models", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("selects Chutes context limits in provider precedence order", async () => {
|
||||
const mockFetch = vi.fn().mockResolvedValue(
|
||||
jsonResponse({
|
||||
data: [
|
||||
{
|
||||
id: "provider/context-primary",
|
||||
context_length: 131072,
|
||||
max_model_len: 262144,
|
||||
},
|
||||
{ id: "provider/serving-fallback", max_model_len: 131072 },
|
||||
{
|
||||
id: "provider/invalid-primary",
|
||||
context_length: -1,
|
||||
max_model_len: 131072,
|
||||
},
|
||||
{
|
||||
id: "provider/default-control",
|
||||
context_length: 0,
|
||||
max_model_len: 0,
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
await withLiveChutesDiscovery(mockFetch, async () => {
|
||||
const models = await discoverChutesModels("context-limit-precedence");
|
||||
expect(models.map(({ id, contextWindow }) => ({ id, contextWindow }))).toEqual([
|
||||
{ id: "provider/context-primary", contextWindow: 131072 },
|
||||
{ id: "provider/serving-fallback", contextWindow: 131072 },
|
||||
{ id: "provider/invalid-primary", contextWindow: 131072 },
|
||||
{ id: "provider/default-control", contextWindow: 128000 },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back from malformed live token metadata", async () => {
|
||||
const mockFetch = vi.fn().mockResolvedValue(
|
||||
jsonResponse({
|
||||
|
||||
@@ -50,6 +50,7 @@ interface ChutesModelEntry {
|
||||
supported_features?: string[];
|
||||
input_modalities?: string[];
|
||||
context_length?: number;
|
||||
max_model_len?: number;
|
||||
max_output_length?: number;
|
||||
pricing?: {
|
||||
prompt?: number;
|
||||
@@ -93,7 +94,10 @@ function projectChutesModels(rows: readonly unknown[]): ModelDefinitionConfig[]
|
||||
cacheRead: entry.pricing?.input_cache_read || 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: asPositiveSafeInteger(entry.context_length) ?? CHUTES_DEFAULT_CONTEXT_WINDOW,
|
||||
contextWindow:
|
||||
asPositiveSafeInteger(entry.context_length) ??
|
||||
asPositiveSafeInteger(entry.max_model_len) ??
|
||||
CHUTES_DEFAULT_CONTEXT_WINDOW,
|
||||
maxTokens: asPositiveSafeInteger(entry.max_output_length) ?? CHUTES_DEFAULT_MAX_TOKENS,
|
||||
compat: { supportsUsageInStreaming: false },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user