mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:40:44 +00:00
fix: include configured provider rows in all models list
This commit is contained in:
@@ -474,7 +474,9 @@ describe("models list/status", () => {
|
||||
models: {
|
||||
providers: {
|
||||
"custom-proxy": {
|
||||
api: "openai-responses",
|
||||
baseUrl: "https://custom.example/v1",
|
||||
apiKey: "$CUSTOM_PROXY_API_KEY",
|
||||
models: [
|
||||
{
|
||||
id: "custom-model",
|
||||
@@ -491,6 +493,7 @@ describe("models list/status", () => {
|
||||
models: {
|
||||
providers: {
|
||||
"custom-proxy": {
|
||||
api: "openai-responses",
|
||||
baseUrl: "https://custom.example/v1",
|
||||
apiKey: "sk-resolved-runtime-value", // pragma: allowlist secret
|
||||
models: [
|
||||
@@ -512,7 +515,7 @@ describe("models list/status", () => {
|
||||
getRuntimeConfig.mockReturnValue(resolvedConfig);
|
||||
const runtime = makeRuntime();
|
||||
|
||||
await modelsListCommand({ all: true, provider: "custom-proxy", json: true }, runtime);
|
||||
await modelsListCommand({ all: true, json: true }, runtime);
|
||||
|
||||
expect(ensureOpenClawModelsJson).not.toHaveBeenCalled();
|
||||
const payload = parseJsonLog(runtime);
|
||||
|
||||
@@ -104,13 +104,11 @@ export async function modelsListCommand(
|
||||
context: rowContext,
|
||||
});
|
||||
|
||||
if (providerFilter) {
|
||||
appendConfiguredProviderRows({
|
||||
rows,
|
||||
context: rowContext,
|
||||
seenKeys,
|
||||
});
|
||||
}
|
||||
appendConfiguredProviderRows({
|
||||
rows,
|
||||
context: rowContext,
|
||||
seenKeys,
|
||||
});
|
||||
|
||||
if (modelRegistry) {
|
||||
await appendCatalogSupplementRows({
|
||||
|
||||
@@ -104,6 +104,16 @@ function toConfiguredProviderListModel(params: {
|
||||
};
|
||||
}
|
||||
|
||||
function shouldListConfiguredProviderModel(params: {
|
||||
providerConfig: Partial<ModelProviderConfig>;
|
||||
model: Partial<ModelDefinitionConfig>;
|
||||
}): boolean {
|
||||
return (
|
||||
params.providerConfig.apiKey !== undefined &&
|
||||
(params.providerConfig.api !== undefined || params.model.api !== undefined)
|
||||
);
|
||||
}
|
||||
|
||||
export async function loadListModelRegistry(
|
||||
cfg: OpenClawConfig,
|
||||
opts?: { providerFilter?: string },
|
||||
@@ -159,6 +169,9 @@ export function appendConfiguredProviderRows(params: {
|
||||
params.context.cfg.models?.providers ?? {},
|
||||
)) {
|
||||
for (const configuredModel of providerConfig.models ?? []) {
|
||||
if (!shouldListConfiguredProviderModel({ providerConfig, model: configuredModel })) {
|
||||
continue;
|
||||
}
|
||||
const key = modelKey(provider, configuredModel.id);
|
||||
if (params.seenKeys.has(key)) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user