mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-10-25 17:22:27 +08:00
Drop the copied OmpProviderForm and the YAML editor; Oh My Pi now uses PiProviderForm with an omp mode (no provider-level name, no thinkingLevelMap, plus a discovery type selector). Presets are derived from the Pi catalog. Pi-family helpers (isPiFamilyApp, parametrized current-state queries and usage-script command) replace the scattered pi/omp branches, and omp error keys reuse the Pi error translator. Co-authored-by: allenxu09 <s23372.xu@stu.scie.com.cn>
52 lines
2.0 KiB
TypeScript
52 lines
2.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { ompProviderPresets } from "@/config/ompProviderPresets";
|
|
import { piProviderPresets } from "@/config/piProviderPresets";
|
|
|
|
describe("Oh My Pi provider preset translation", () => {
|
|
it("translates Pi's DeepSeek switch and reasoning replay to native controls", () => {
|
|
let translated = 0;
|
|
for (const source of piProviderPresets) {
|
|
const target = ompProviderPresets.find(
|
|
(preset) => preset.providerKey === source.providerKey,
|
|
)!;
|
|
type Compat = Record<string, unknown> | undefined;
|
|
const entries: [Compat, Compat][] = [
|
|
[source.settingsConfig.compat, target.settingsConfig.compat],
|
|
...source.settingsConfig.models.map(
|
|
(model, index): [Compat, Compat] => [
|
|
model.compat,
|
|
target.settingsConfig.models[index].compat as Compat,
|
|
],
|
|
),
|
|
];
|
|
for (const [piCompat, ompCompat] of entries) {
|
|
if (piCompat?.thinkingFormat === "deepseek") {
|
|
translated += 1;
|
|
expect(ompCompat?.thinkingFormat).toBe("zai");
|
|
}
|
|
if (piCompat?.requiresReasoningContentOnAssistantMessages === true) {
|
|
expect(ompCompat).toMatchObject({
|
|
reasoningContentField: "reasoning_content",
|
|
requiresReasoningContentForToolCalls: true,
|
|
requiresReasoningContentForAllAssistantTurns: true,
|
|
allowsSyntheticReasoningContentForToolCalls: false,
|
|
});
|
|
expect(ompCompat).not.toHaveProperty(
|
|
"requiresReasoningContentOnAssistantMessages",
|
|
);
|
|
}
|
|
}
|
|
}
|
|
expect(translated).toBeGreaterThan(0);
|
|
});
|
|
|
|
it("drops the fields omp's models.yml schema does not define", () => {
|
|
for (const preset of ompProviderPresets) {
|
|
expect(preset.settingsConfig).not.toHaveProperty("name");
|
|
for (const model of preset.settingsConfig.models) {
|
|
expect(model).not.toHaveProperty("thinkingLevelMap");
|
|
}
|
|
}
|
|
});
|
|
});
|