mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-23 15:11:42 +00:00
Preserves explicit `supportsUsageInStreaming` overrides from built-in provider catalogs and user config instead of unconditionally forcing `false` on non-native openai-completions endpoints. Adds `applyNativeStreamingUsageCompat()` to set `supportsUsageInStreaming: true` on ModelStudio (DashScope) and Moonshot models at config build time so their native streaming usage works out of the box. Closes #46142 Co-authored-by: pezy <peizhe.chen@vbot.cn>
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
applyNativeStreamingUsageCompat,
|
|
buildModelStudioProvider,
|
|
} from "./models-config.providers.js";
|
|
|
|
describe("Model Studio implicit provider", () => {
|
|
it("should opt native Model Studio baseUrls into streaming usage", () => {
|
|
const providers = applyNativeStreamingUsageCompat({
|
|
modelstudio: buildModelStudioProvider(),
|
|
});
|
|
expect(providers?.modelstudio).toBeDefined();
|
|
expect(providers?.modelstudio?.baseUrl).toBe("https://coding-intl.dashscope.aliyuncs.com/v1");
|
|
expect(
|
|
providers?.modelstudio?.models?.every(
|
|
(model) => model.compat?.supportsUsageInStreaming === true,
|
|
),
|
|
).toBe(true);
|
|
});
|
|
|
|
it("should keep streaming usage opt-in disabled for custom Model Studio-compatible baseUrls", () => {
|
|
const providers = applyNativeStreamingUsageCompat({
|
|
modelstudio: {
|
|
...buildModelStudioProvider(),
|
|
baseUrl: "https://proxy.example.com/v1",
|
|
},
|
|
});
|
|
expect(providers?.modelstudio).toBeDefined();
|
|
expect(providers?.modelstudio?.baseUrl).toBe("https://proxy.example.com/v1");
|
|
expect(
|
|
providers?.modelstudio?.models?.some(
|
|
(model) => model.compat?.supportsUsageInStreaming === true,
|
|
),
|
|
).toBe(false);
|
|
});
|
|
});
|