fix(coding-agent): custom models for built-in providers and list-models error surfacing (#3072)
* fix(coding-agent): surface models.json load errors on stderr in --list-models When models.json has validation errors, --list-models silently discarded custom models and overrides without any user-visible feedback. Now prints the error to stderr via chalk.yellow warning before listing available models. * fix(coding-agent): allow custom models for built-in providers in models.json Built-in providers (openrouter, anthropic, etc.) already have api and baseUrl on every model, and auth comes from env vars / auth storage. Relax validation so custom models under built-in providers don't need redundant baseUrl, apiKey, or api fields. Inherit them from the first built-in model for that provider. fixes #2921 --------- Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import type { Api, Model } from "@mariozechner/pi-ai";
|
||||
import { fuzzyFilter } from "@mariozechner/pi-tui";
|
||||
import chalk from "chalk";
|
||||
import type { ModelRegistry } from "../core/model-registry.js";
|
||||
|
||||
/**
|
||||
@@ -25,6 +26,11 @@ function formatTokenCount(count: number): string {
|
||||
* List available models, optionally filtered by search pattern
|
||||
*/
|
||||
export async function listModels(modelRegistry: ModelRegistry, searchPattern?: string): Promise<void> {
|
||||
const loadError = modelRegistry.getError();
|
||||
if (loadError) {
|
||||
console.error(chalk.yellow(`Warning: errors loading models.json:\n${loadError}`));
|
||||
}
|
||||
|
||||
const models = modelRegistry.getAvailable();
|
||||
|
||||
if (models.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user