mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 11:02:17 +00:00
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:
parent
02a9b4f09f
commit
9b8ea585bd
3 changed files with 22 additions and 61 deletions
|
|
@ -10,6 +10,8 @@ export {
|
|||
getProviderInfo,
|
||||
getProviderModels,
|
||||
loadModels,
|
||||
type ModalityInput,
|
||||
type ModalityOutput,
|
||||
type ModelInfo,
|
||||
type ModelsData,
|
||||
type ProviderInfo,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env tsx
|
||||
|
||||
import { loadModels, getModelInfo, getProviderModels, getProviderInfo, getAllProviders, supportsThinking, supportsTools } from "../src/models.js";
|
||||
|
||||
// Test loading models
|
||||
console.log("Loading models data...");
|
||||
const data = loadModels();
|
||||
const providers = getAllProviders();
|
||||
console.log(`Loaded ${providers.length} providers\n`);
|
||||
|
||||
// Test getting provider info
|
||||
console.log("OpenAI provider info:");
|
||||
const openai = getProviderInfo("openai");
|
||||
if (openai) {
|
||||
console.log(` Name: ${openai.name}`);
|
||||
console.log(` NPM: ${openai.npm}`);
|
||||
console.log(` Models: ${Object.keys(openai.models).length}`);
|
||||
}
|
||||
|
||||
// Test getting a specific model
|
||||
console.log("\nGetting info for gpt-4o:");
|
||||
const gpt4o = getModelInfo("gpt-4o");
|
||||
if (gpt4o) {
|
||||
console.log(` Name: ${gpt4o.name}`);
|
||||
console.log(` Context: ${gpt4o.limit?.context}`);
|
||||
console.log(` Max Output: ${gpt4o.limit?.output}`);
|
||||
console.log(` Reasoning: ${gpt4o.reasoning}`);
|
||||
console.log(` Tool Call: ${gpt4o.tool_call}`);
|
||||
}
|
||||
|
||||
// Test getting provider models
|
||||
console.log("\nOpenAI models:");
|
||||
const openaiModels = getProviderModels("openai");
|
||||
console.log(` Found ${openaiModels.length} OpenAI models`);
|
||||
console.log(` First 5: ${openaiModels.slice(0, 5).map(m => m.id).join(", ")}`);
|
||||
|
||||
// Test checking capabilities
|
||||
console.log("\nModel capabilities:");
|
||||
console.log(` gpt-4o supports thinking: ${supportsThinking("gpt-4o")}`);
|
||||
console.log(` gpt-4o supports tools: ${supportsTools("gpt-4o")}`);
|
||||
console.log(` o1 supports thinking: ${supportsThinking("o1")}`);
|
||||
console.log(` o1 supports tools: ${supportsTools("o1")}`);
|
||||
console.log(` claude-3-5-sonnet-20241022 supports tools: ${supportsTools("claude-3-5-sonnet-20241022")}`);
|
||||
Loading…
Add table
Add a link
Reference in a new issue