fix(ai): Improve ModelInfo types based on actual data structure

- Remove catch-all [key: string]: any from ModelInfo
- Make all required fields non-optional (attachment, reasoning, etc.)
- Add proper union types for modalities (text, image, audio, video, pdf)
- Mark only cost and knowledge fields as optional
- Export ModalityInput and ModalityOutput types
This commit is contained in:
Mario Zechner 2025-08-25 20:18:34 +02:00
parent 02a9b4f09f
commit 9b8ea585bd
3 changed files with 22 additions and 61 deletions

View file

@ -10,6 +10,8 @@ export {
getProviderInfo,
getProviderModels,
loadModels,
type ModalityInput,
type ModalityOutput,
type ModelInfo,
type ModelsData,
type ProviderInfo,

View file

@ -2,32 +2,34 @@ import { readFileSync } from "fs";
import { dirname, join } from "path";
import { fileURLToPath } from "url";
export type ModalityInput = "text" | "image" | "audio" | "video" | "pdf";
export type ModalityOutput = "text" | "image" | "audio";
export interface ModelInfo {
id: string;
name: string;
attachment?: boolean;
reasoning?: boolean;
temperature?: boolean;
tool_call?: boolean;
knowledge?: string;
release_date?: string;
last_updated?: string;
modalities?: {
input?: string[];
output?: string[];
attachment: boolean;
reasoning: boolean;
temperature: boolean;
tool_call: boolean;
release_date: string;
last_updated: string;
modalities: {
input: ModalityInput[];
output: ModalityOutput[];
};
open_weights?: boolean;
open_weights: boolean;
limit: {
context: number;
output: number;
};
knowledge?: string; // Optional - knowledge cutoff date
cost?: {
input?: number;
output?: number;
input: number;
output: number;
cache_read?: number;
cache_write?: number;
};
limit?: {
context?: number;
output?: number;
};
[key: string]: any;
}
export interface ProviderInfo {