mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
fix(ai): allow prompt cache keys for compatible proxies (#9442)
This commit is contained in:
parent
a3a1005053
commit
0f4d5e960a
12 changed files with 252 additions and 7 deletions
|
|
@ -549,6 +549,27 @@ describe("ModelRegistry", () => {
|
|||
expect(compat?.supportsEagerToolInputStreaming).toBe(false);
|
||||
});
|
||||
|
||||
test("custom models inherit and override prompt cache key mode independently of long retention", async () => {
|
||||
const provider: ModelsJsonProvider = {
|
||||
baseUrl: "https://proxy.example.com/v1",
|
||||
api: "openai-completions",
|
||||
compat: { promptCacheKeyMode: "enabled", supportsLongCacheRetention: false },
|
||||
models: [{ id: "inherited" }, { id: "disabled", compat: { promptCacheKeyMode: "disabled" } }],
|
||||
};
|
||||
writeRawModelsJson({ demo: provider });
|
||||
|
||||
const registry = await createModelRegistry(authStorage, modelsJsonPath);
|
||||
expect(registry.getError()).toBeUndefined();
|
||||
expect(registry.find("demo", "inherited")?.compat).toMatchObject({
|
||||
promptCacheKeyMode: "enabled",
|
||||
supportsLongCacheRetention: false,
|
||||
});
|
||||
expect(registry.find("demo", "disabled")?.compat).toMatchObject({
|
||||
promptCacheKeyMode: "disabled",
|
||||
supportsLongCacheRetention: false,
|
||||
});
|
||||
});
|
||||
|
||||
test("compat schema accepts long cache retention flag", async () => {
|
||||
writeRawModelsJson({
|
||||
demo: {
|
||||
|
|
@ -922,6 +943,22 @@ describe("ModelRegistry", () => {
|
|||
expect((opus?.compat as OpenAICompletionsCompat | undefined)?.supportsFinishReason).toBe(true);
|
||||
});
|
||||
|
||||
test("built-in models inherit prompt cache key support unless overridden", async () => {
|
||||
const provider: ModelsJsonProvider = {
|
||||
baseUrl: "https://proxy.example.com/v1",
|
||||
compat: { promptCacheKeyMode: "enabled" },
|
||||
modelOverrides: {
|
||||
"gpt-4o-mini": { compat: { promptCacheKeyMode: "disabled" } },
|
||||
},
|
||||
};
|
||||
writeRawModelsJson({ openai: provider });
|
||||
|
||||
const registry = await createModelRegistry(authStorage, modelsJsonPath);
|
||||
expect(registry.getError()).toBeUndefined();
|
||||
expect(registry.find("openai", "gpt-4o")?.compat).toMatchObject({ promptCacheKeyMode: "enabled" });
|
||||
expect(registry.find("openai", "gpt-4o-mini")?.compat).toMatchObject({ promptCacheKeyMode: "disabled" });
|
||||
});
|
||||
|
||||
test("model override deep merges compat settings", async () => {
|
||||
writeRawModelsJson({
|
||||
openrouter: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue