mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-28 01:42:03 +07:00
fix: decouple moonshot stream wrappers from provider runtime
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { shouldApplyMoonshotPayloadCompat } from "./moonshot-stream-wrappers.js";
|
||||
|
||||
describe("moonshot stream wrappers", () => {
|
||||
it("keeps Moonshot compatibility on the lightweight provider-id path", () => {
|
||||
expect(
|
||||
shouldApplyMoonshotPayloadCompat({
|
||||
provider: "moonshot",
|
||||
modelId: "kimi-k2.5",
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
shouldApplyMoonshotPayloadCompat({
|
||||
provider: "kimi-coding",
|
||||
modelId: "kimi-code",
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
shouldApplyMoonshotPayloadCompat({
|
||||
provider: "ollama",
|
||||
modelId: "kimi-k2.5:cloud",
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
shouldApplyMoonshotPayloadCompat({
|
||||
provider: "openai",
|
||||
modelId: "gpt-5.4",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { StreamFn } from "@mariozechner/pi-agent-core";
|
||||
import { streamSimple } from "@mariozechner/pi-ai";
|
||||
import type { ThinkLevel } from "../../auto-reply/thinking.js";
|
||||
import { usesMoonshotThinkingPayloadCompat } from "../provider-capabilities.js";
|
||||
import { normalizeProviderId } from "../provider-id.js";
|
||||
|
||||
type MoonshotThinkingType = "enabled" | "disabled";
|
||||
|
||||
@@ -60,10 +60,10 @@ export function shouldApplyMoonshotPayloadCompat(params: {
|
||||
provider: string;
|
||||
modelId: string;
|
||||
}): boolean {
|
||||
const normalizedProvider = params.provider.trim().toLowerCase();
|
||||
const normalizedProvider = normalizeProviderId(params.provider);
|
||||
const normalizedModelId = params.modelId.trim().toLowerCase();
|
||||
|
||||
if (usesMoonshotThinkingPayloadCompat(normalizedProvider)) {
|
||||
if (normalizedProvider === "moonshot" || normalizedProvider === "kimi") {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user