Always validate AI model capabilities and configurations before attempting to use them. This includes checking: 1. Feature support (e.g., images, embeddings)
Always validate AI model capabilities and configurations before attempting to use them. This includes checking:
Example:
// Before using model features, validate capabilities
const provider = await client.providerRef.deref();
const modelCapabilities = {
supportsImages: provider?.apiHandler?.getModel()?.info?.supportsImages ?? false,
supportedDimensions: [768, 1536, 3072],
isModelAvailable: Boolean(routerModels[provider]?.[modelId])
};
// Use capabilities to make decisions
const imagesToInclude = modelCapabilities.supportsImages ? allImages : [];
if (!modelCapabilities.isModelAvailable) {
throw new Error(`Model ${modelId} is not available`);
}
This prevents runtime errors, improves reliability, and ensures optimal resource usage. It’s particularly important in AI applications where different models may have varying capabilities and requirements.
Enter the URL of a public GitHub repository