Remove the static catalog for DeepInfra and always rely on model discovery
This commit is contained in:
parent
6236093ccd
commit
395070e5f2
@ -4,10 +4,8 @@ import {
|
||||
} from "openclaw/plugin-sdk/provider-models";
|
||||
import {
|
||||
applyAgentDefaultModelPrimary,
|
||||
applyProviderConfigWithModelCatalog,
|
||||
type OpenClawConfig,
|
||||
} from "openclaw/plugin-sdk/provider-onboard";
|
||||
import { buildDeepInfraStaticProvider } from "./provider-catalog.js";
|
||||
|
||||
export { DEEPINFRA_BASE_URL, DEEPINFRA_DEFAULT_MODEL_REF };
|
||||
|
||||
@ -18,13 +16,16 @@ export function applyDeepInfraProviderConfig(cfg: OpenClawConfig): OpenClawConfi
|
||||
alias: models[DEEPINFRA_DEFAULT_MODEL_REF]?.alias ?? "DeepInfra",
|
||||
};
|
||||
|
||||
return applyProviderConfigWithModelCatalog(cfg, {
|
||||
agentModels: models,
|
||||
providerId: "deepinfra",
|
||||
api: "openai-completions",
|
||||
baseUrl: DEEPINFRA_BASE_URL,
|
||||
catalogModels: buildDeepInfraStaticProvider().models ?? [],
|
||||
});
|
||||
return {
|
||||
...cfg,
|
||||
agents: {
|
||||
...cfg.agents,
|
||||
defaults: {
|
||||
...cfg.agents?.defaults,
|
||||
models,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function applyDeepInfraConfig(cfg: OpenClawConfig): OpenClawConfig {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import {
|
||||
type ModelProviderConfig,
|
||||
discoverDeepInfraModels,
|
||||
buildDeepInfraStaticCatalog,
|
||||
DEEPINFRA_BASE_URL,
|
||||
} from "openclaw/plugin-sdk/provider-models";
|
||||
|
||||
@ -13,11 +12,3 @@ export async function buildDeepInfraProviderWithDiscovery(): Promise<ModelProvid
|
||||
models,
|
||||
};
|
||||
}
|
||||
|
||||
export function buildDeepInfraStaticProvider(): ModelProviderConfig {
|
||||
return {
|
||||
baseUrl: DEEPINFRA_BASE_URL,
|
||||
api: "openai-completions",
|
||||
models: buildDeepInfraStaticCatalog(),
|
||||
};
|
||||
}
|
||||
|
||||
@ -3,8 +3,8 @@ import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { captureEnv } from "../test-utils/env.ts";
|
||||
import { buildStaticCatalog } from "./deepinfra-models.ts";
|
||||
import { resolveImplicitProvidersForTest } from "./models-config.e2e-harness.ts";
|
||||
import { buildDeepInfraStaticProvider } from "./models-config.providers.ts";
|
||||
|
||||
const DEEPINFRA_MODEL_IDS = [
|
||||
"openai/gpt-oss-120b",
|
||||
@ -42,25 +42,23 @@ describe("DeepInfra implicit provider", () => {
|
||||
});
|
||||
|
||||
it("should build deepinfra provider with correct configuration", () => {
|
||||
const provider = buildDeepInfraStaticProvider();
|
||||
expect(provider.baseUrl).toBe("https://api.deepinfra.com/v1/openai/");
|
||||
expect(provider.api).toBe("openai-completions");
|
||||
expect(provider.models).toBeDefined();
|
||||
expect(provider.models.length).toBeGreaterThan(0);
|
||||
const models = buildStaticCatalog();
|
||||
expect(models).toBeDefined();
|
||||
expect(models.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("should include the default deepinfra model", () => {
|
||||
const provider = buildDeepInfraStaticProvider();
|
||||
const modelIds = provider.models.map((m) => m.id);
|
||||
const models = buildStaticCatalog();
|
||||
const modelIds = models.map((m) => m.id);
|
||||
expect(modelIds).toContain("openai/gpt-oss-120b");
|
||||
});
|
||||
|
||||
it("should include the static fallback catalog", () => {
|
||||
const provider = buildDeepInfraStaticProvider();
|
||||
const modelIds = provider.models.map((m) => m.id);
|
||||
const models = buildStaticCatalog();
|
||||
const modelIds = models.map((m) => m.id);
|
||||
for (const modelId of DEEPINFRA_MODEL_IDS) {
|
||||
expect(modelIds).toContain(modelId);
|
||||
}
|
||||
expect(provider.models).toHaveLength(DEEPINFRA_MODEL_IDS.length);
|
||||
expect(models).toHaveLength(DEEPINFRA_MODEL_IDS.length);
|
||||
});
|
||||
});
|
||||
|
||||
@ -4,7 +4,6 @@ export {
|
||||
} from "../../extensions/byteplus/provider-catalog.js";
|
||||
export { buildKimiCodingProvider } from "../../extensions/kimi-coding/provider-catalog.js";
|
||||
export { buildKilocodeProvider } from "../../extensions/kilocode/provider-catalog.js";
|
||||
export { buildDeepInfraStaticProvider } from "../../extensions/deepinfra/provider-catalog.js";
|
||||
export {
|
||||
buildMinimaxPortalProvider,
|
||||
buildMinimaxProvider,
|
||||
|
||||
@ -11,7 +11,6 @@ import { ensureAuthProfileStore, listProfilesForProvider } from "./auth-profiles
|
||||
import { discoverBedrockModels } from "./bedrock-discovery.js";
|
||||
import { normalizeGoogleModelId } from "./model-id-normalization.js";
|
||||
import { resolveOllamaApiBase } from "./models-config.providers.discovery.js";
|
||||
export { buildDeepInfraStaticProvider } from "../../extensions/deepinfra/provider-catalog.js";
|
||||
export { buildKimiCodingProvider } from "../../extensions/kimi-coding/provider-catalog.js";
|
||||
export { buildKilocodeProvider } from "../../extensions/kilocode/provider-catalog.js";
|
||||
export {
|
||||
|
||||
@ -16,12 +16,10 @@ import {
|
||||
DEEPINFRA_DEFAULT_MODEL_ID,
|
||||
DEEPINFRA_DEFAULT_MODEL_REF,
|
||||
DEEPINFRA_DEFAULT_MAX_TOKENS,
|
||||
DEEPINFRA_MODEL_CATALOG,
|
||||
} from "../providers/deepinfra-shared.js";
|
||||
import { captureEnv } from "../test-utils/env.js";
|
||||
|
||||
const emptyCfg: OpenClawConfig = {};
|
||||
const DEEPINFRA_MODEL_IDS = DEEPINFRA_MODEL_CATALOG.map((m) => m.id);
|
||||
|
||||
describe("DeepInfra provider config", () => {
|
||||
describe("constants", () => {
|
||||
@ -56,48 +54,9 @@ describe("DeepInfra provider config", () => {
|
||||
});
|
||||
|
||||
describe("applyDeepInfraProviderConfig", () => {
|
||||
it("registers deepinfra provider with correct baseUrl and api", () => {
|
||||
it("does not persist a provider block (discovery populates models at runtime)", () => {
|
||||
const result = applyDeepInfraProviderConfig(emptyCfg);
|
||||
const provider = result.models?.providers?.deepinfra;
|
||||
expect(provider).toBeDefined();
|
||||
expect(provider?.baseUrl).toBe(DEEPINFRA_BASE_URL);
|
||||
expect(provider?.api).toBe("openai-completions");
|
||||
});
|
||||
|
||||
it("includes the default model in the provider model list", () => {
|
||||
const result = applyDeepInfraProviderConfig(emptyCfg);
|
||||
const provider = result.models?.providers?.deepinfra;
|
||||
const models = provider?.models;
|
||||
expect(Array.isArray(models)).toBe(true);
|
||||
const modelIds = models?.map((m) => m.id) ?? [];
|
||||
expect(modelIds).toContain(DEEPINFRA_DEFAULT_MODEL_ID);
|
||||
});
|
||||
|
||||
it("surfaces the full DeepInfra model catalog", () => {
|
||||
const result = applyDeepInfraProviderConfig(emptyCfg);
|
||||
const provider = result.models?.providers?.deepinfra;
|
||||
const modelIds = provider?.models?.map((m) => m.id) ?? [];
|
||||
for (const modelId of DEEPINFRA_MODEL_IDS) {
|
||||
expect(modelIds).toContain(modelId);
|
||||
}
|
||||
});
|
||||
|
||||
it("appends missing catalog models to existing DeepInfra provider config", () => {
|
||||
const result = applyDeepInfraProviderConfig({
|
||||
models: {
|
||||
providers: {
|
||||
deepinfra: {
|
||||
baseUrl: DEEPINFRA_BASE_URL,
|
||||
api: "openai-completions",
|
||||
models: [{ ...DEEPINFRA_MODEL_CATALOG[0], cost: DEEPINFRA_DEFAULT_COST }],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const modelIds = result.models?.providers?.deepinfra?.models?.map((m) => m.id) ?? [];
|
||||
for (const modelId of DEEPINFRA_MODEL_IDS) {
|
||||
expect(modelIds).toContain(modelId);
|
||||
}
|
||||
expect(result.models?.providers?.deepinfra).toBeUndefined();
|
||||
});
|
||||
|
||||
it("sets DeepInfra alias in agent default models", () => {
|
||||
@ -143,11 +102,9 @@ describe("DeepInfra provider config", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("also registers the provider", () => {
|
||||
it("does not persist a provider block (discovery populates models at runtime)", () => {
|
||||
const result = applyDeepInfraConfig(emptyCfg);
|
||||
const provider = result.models?.providers?.deepinfra;
|
||||
expect(provider).toBeDefined();
|
||||
expect(provider?.baseUrl).toBe(DEEPINFRA_BASE_URL);
|
||||
expect(result.models?.providers?.deepinfra).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -106,10 +106,7 @@ export {
|
||||
VERCEL_AI_GATEWAY_BASE_URL,
|
||||
} from "../agents/vercel-ai-gateway.js";
|
||||
export { DEEPINFRA_BASE_URL, DEEPINFRA_DEFAULT_MODEL_REF } from "../providers/deepinfra-shared.js";
|
||||
export {
|
||||
buildStaticCatalog as buildDeepInfraStaticCatalog,
|
||||
discoverDeepInfraModels,
|
||||
} from "../agents/deepinfra-models.js";
|
||||
export { discoverDeepInfraModels } from "../agents/deepinfra-models.js";
|
||||
|
||||
export function buildKilocodeModelDefinition(): ModelDefinitionConfig {
|
||||
return {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user