@probeo/anymodel 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -4
- package/dist/cli.cjs +139 -22
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +139 -22
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +139 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +139 -22
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/index.d.cts
CHANGED
|
@@ -252,6 +252,16 @@ interface AnyModelConfig {
|
|
|
252
252
|
anthropic?: ProviderConfig;
|
|
253
253
|
openai?: ProviderConfig;
|
|
254
254
|
google?: ProviderConfig;
|
|
255
|
+
mistral?: ProviderConfig;
|
|
256
|
+
groq?: ProviderConfig;
|
|
257
|
+
deepseek?: ProviderConfig;
|
|
258
|
+
xai?: ProviderConfig;
|
|
259
|
+
together?: ProviderConfig;
|
|
260
|
+
fireworks?: ProviderConfig;
|
|
261
|
+
perplexity?: ProviderConfig;
|
|
262
|
+
ollama?: ProviderConfig & {
|
|
263
|
+
baseURL?: string;
|
|
264
|
+
};
|
|
255
265
|
custom?: Record<string, CustomProviderConfig>;
|
|
256
266
|
aliases?: Record<string, string>;
|
|
257
267
|
defaults?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -252,6 +252,16 @@ interface AnyModelConfig {
|
|
|
252
252
|
anthropic?: ProviderConfig;
|
|
253
253
|
openai?: ProviderConfig;
|
|
254
254
|
google?: ProviderConfig;
|
|
255
|
+
mistral?: ProviderConfig;
|
|
256
|
+
groq?: ProviderConfig;
|
|
257
|
+
deepseek?: ProviderConfig;
|
|
258
|
+
xai?: ProviderConfig;
|
|
259
|
+
together?: ProviderConfig;
|
|
260
|
+
fireworks?: ProviderConfig;
|
|
261
|
+
perplexity?: ProviderConfig;
|
|
262
|
+
ollama?: ProviderConfig & {
|
|
263
|
+
baseURL?: string;
|
|
264
|
+
};
|
|
255
265
|
custom?: Record<string, CustomProviderConfig>;
|
|
256
266
|
aliases?: Record<string, string>;
|
|
257
267
|
defaults?: {
|
package/dist/index.js
CHANGED
|
@@ -617,7 +617,19 @@ function createOpenAIAdapter(apiKey, baseURL) {
|
|
|
617
617
|
async listModels() {
|
|
618
618
|
const res = await makeRequest("/models", void 0, "GET");
|
|
619
619
|
const data = await res.json();
|
|
620
|
-
return (data.data || []).filter((m) =>
|
|
620
|
+
return (data.data || []).filter((m) => {
|
|
621
|
+
const id = m.id;
|
|
622
|
+
if (id.includes("embedding")) return false;
|
|
623
|
+
if (id.includes("whisper")) return false;
|
|
624
|
+
if (id.includes("tts")) return false;
|
|
625
|
+
if (id.includes("dall-e")) return false;
|
|
626
|
+
if (id.includes("davinci")) return false;
|
|
627
|
+
if (id.includes("babbage")) return false;
|
|
628
|
+
if (id.includes("moderation")) return false;
|
|
629
|
+
if (id.includes("realtime")) return false;
|
|
630
|
+
if (id.startsWith("ft:")) return false;
|
|
631
|
+
return id.startsWith("gpt-") || id.startsWith("o1") || id.startsWith("o3") || id.startsWith("o4") || id.startsWith("chatgpt-");
|
|
632
|
+
}).map((m) => ({
|
|
621
633
|
id: `openai/${m.id}`,
|
|
622
634
|
name: m.id,
|
|
623
635
|
created: m.created,
|
|
@@ -683,10 +695,16 @@ var SUPPORTED_PARAMS2 = /* @__PURE__ */ new Set([
|
|
|
683
695
|
"tool_choice",
|
|
684
696
|
"response_format"
|
|
685
697
|
]);
|
|
686
|
-
var
|
|
687
|
-
|
|
698
|
+
var FALLBACK_MODELS = [
|
|
699
|
+
// Claude 4.6
|
|
700
|
+
{ id: "anthropic/claude-opus-4-6", name: "Claude Opus 4.6", created: 0, description: "Most capable model", context_length: 2e5, pricing: { prompt: "0.000015", completion: "0.000075" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image"], output_modalities: ["text"], tokenizer: "claude" }, top_provider: { context_length: 2e5, max_completion_tokens: 32768, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS2) },
|
|
688
701
|
{ id: "anthropic/claude-sonnet-4-6", name: "Claude Sonnet 4.6", created: 0, description: "Best balance of speed and capability", context_length: 2e5, pricing: { prompt: "0.000003", completion: "0.000015" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image"], output_modalities: ["text"], tokenizer: "claude" }, top_provider: { context_length: 2e5, max_completion_tokens: 16384, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS2) },
|
|
689
|
-
|
|
702
|
+
// Claude 4.5
|
|
703
|
+
{ id: "anthropic/claude-sonnet-4-5-20251022", name: "Claude Sonnet 4.5", created: 0, description: "Previous generation balanced model", context_length: 2e5, pricing: { prompt: "0.000003", completion: "0.000015" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image"], output_modalities: ["text"], tokenizer: "claude" }, top_provider: { context_length: 2e5, max_completion_tokens: 16384, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS2) },
|
|
704
|
+
{ id: "anthropic/claude-haiku-4-5", name: "Claude Haiku 4.5", created: 0, description: "Fast and compact", context_length: 2e5, pricing: { prompt: "0.000001", completion: "0.000005" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image"], output_modalities: ["text"], tokenizer: "claude" }, top_provider: { context_length: 2e5, max_completion_tokens: 8192, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS2) },
|
|
705
|
+
// Claude 3.5
|
|
706
|
+
{ id: "anthropic/claude-3-5-sonnet-20241022", name: "Claude 3.5 Sonnet", created: 0, description: "Legacy balanced model", context_length: 2e5, pricing: { prompt: "0.000003", completion: "0.000015" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image"], output_modalities: ["text"], tokenizer: "claude" }, top_provider: { context_length: 2e5, max_completion_tokens: 8192, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS2) },
|
|
707
|
+
{ id: "anthropic/claude-3-5-haiku-20241022", name: "Claude 3.5 Haiku", created: 0, description: "Legacy fast model", context_length: 2e5, pricing: { prompt: "0.0000008", completion: "0.000004" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image"], output_modalities: ["text"], tokenizer: "claude" }, top_provider: { context_length: 2e5, max_completion_tokens: 8192, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS2) }
|
|
690
708
|
];
|
|
691
709
|
function createAnthropicAdapter(apiKey) {
|
|
692
710
|
async function makeRequest(path, body, stream = false) {
|
|
@@ -946,7 +964,40 @@ ${body.system}` : jsonInstruction;
|
|
|
946
964
|
};
|
|
947
965
|
},
|
|
948
966
|
async listModels() {
|
|
949
|
-
|
|
967
|
+
try {
|
|
968
|
+
const res = await fetch(`${ANTHROPIC_API_BASE}/models`, {
|
|
969
|
+
method: "GET",
|
|
970
|
+
headers: {
|
|
971
|
+
"x-api-key": apiKey,
|
|
972
|
+
"anthropic-version": ANTHROPIC_VERSION
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
if (!res.ok) return FALLBACK_MODELS;
|
|
976
|
+
const data = await res.json();
|
|
977
|
+
const models = data.data || [];
|
|
978
|
+
return models.filter((m) => m.type === "model").map((m) => ({
|
|
979
|
+
id: `anthropic/${m.id}`,
|
|
980
|
+
name: m.display_name || m.id,
|
|
981
|
+
created: m.created_at ? new Date(m.created_at).getTime() / 1e3 : 0,
|
|
982
|
+
description: m.display_name || "",
|
|
983
|
+
context_length: 2e5,
|
|
984
|
+
pricing: { prompt: "0", completion: "0" },
|
|
985
|
+
architecture: {
|
|
986
|
+
modality: "text+image->text",
|
|
987
|
+
input_modalities: ["text", "image"],
|
|
988
|
+
output_modalities: ["text"],
|
|
989
|
+
tokenizer: "claude"
|
|
990
|
+
},
|
|
991
|
+
top_provider: {
|
|
992
|
+
context_length: 2e5,
|
|
993
|
+
max_completion_tokens: 16384,
|
|
994
|
+
is_moderated: false
|
|
995
|
+
},
|
|
996
|
+
supported_parameters: Array.from(SUPPORTED_PARAMS2)
|
|
997
|
+
}));
|
|
998
|
+
} catch {
|
|
999
|
+
return FALLBACK_MODELS;
|
|
1000
|
+
}
|
|
950
1001
|
},
|
|
951
1002
|
supportsParameter(param) {
|
|
952
1003
|
return SUPPORTED_PARAMS2.has(param);
|
|
@@ -984,9 +1035,16 @@ var SUPPORTED_PARAMS3 = /* @__PURE__ */ new Set([
|
|
|
984
1035
|
"tool_choice",
|
|
985
1036
|
"response_format"
|
|
986
1037
|
]);
|
|
987
|
-
var
|
|
1038
|
+
var FALLBACK_MODELS2 = [
|
|
1039
|
+
// Gemini 2.5
|
|
988
1040
|
{ id: "google/gemini-2.5-pro", name: "Gemini 2.5 Pro", created: 0, description: "Most capable Gemini model", context_length: 1048576, pricing: { prompt: "0.00000125", completion: "0.000005" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image", "video", "audio"], output_modalities: ["text"], tokenizer: "gemini" }, top_provider: { context_length: 1048576, max_completion_tokens: 65536, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS3) },
|
|
989
|
-
{ id: "google/gemini-2.5-flash", name: "Gemini 2.5 Flash", created: 0, description: "Fast and efficient", context_length: 1048576, pricing: { prompt: "0.00000015", completion: "0.0000006" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image", "video", "audio"], output_modalities: ["text"], tokenizer: "gemini" }, top_provider: { context_length: 1048576, max_completion_tokens: 65536, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS3) }
|
|
1041
|
+
{ id: "google/gemini-2.5-flash", name: "Gemini 2.5 Flash", created: 0, description: "Fast and efficient", context_length: 1048576, pricing: { prompt: "0.00000015", completion: "0.0000006" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image", "video", "audio"], output_modalities: ["text"], tokenizer: "gemini" }, top_provider: { context_length: 1048576, max_completion_tokens: 65536, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS3) },
|
|
1042
|
+
// Gemini 2.0
|
|
1043
|
+
{ id: "google/gemini-2.0-flash", name: "Gemini 2.0 Flash", created: 0, description: "Fast multimodal model", context_length: 1048576, pricing: { prompt: "0.0000001", completion: "0.0000004" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image", "video", "audio"], output_modalities: ["text"], tokenizer: "gemini" }, top_provider: { context_length: 1048576, max_completion_tokens: 65536, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS3) },
|
|
1044
|
+
{ id: "google/gemini-2.0-flash-lite", name: "Gemini 2.0 Flash Lite", created: 0, description: "Lightweight and fast", context_length: 1048576, pricing: { prompt: "0.00000005", completion: "0.0000002" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image", "video", "audio"], output_modalities: ["text"], tokenizer: "gemini" }, top_provider: { context_length: 1048576, max_completion_tokens: 65536, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS3) },
|
|
1045
|
+
// Gemini 1.5
|
|
1046
|
+
{ id: "google/gemini-1.5-pro", name: "Gemini 1.5 Pro", created: 0, description: "Previous generation pro model", context_length: 2097152, pricing: { prompt: "0.00000125", completion: "0.000005" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image", "video", "audio"], output_modalities: ["text"], tokenizer: "gemini" }, top_provider: { context_length: 2097152, max_completion_tokens: 8192, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS3) },
|
|
1047
|
+
{ id: "google/gemini-1.5-flash", name: "Gemini 1.5 Flash", created: 0, description: "Previous generation flash model", context_length: 1048576, pricing: { prompt: "0.000000075", completion: "0.0000003" }, architecture: { modality: "text+image->text", input_modalities: ["text", "image", "video", "audio"], output_modalities: ["text"], tokenizer: "gemini" }, top_provider: { context_length: 1048576, max_completion_tokens: 8192, is_moderated: false }, supported_parameters: Array.from(SUPPORTED_PARAMS3) }
|
|
990
1048
|
];
|
|
991
1049
|
function createGoogleAdapter(apiKey) {
|
|
992
1050
|
function getModelEndpoint(model, stream) {
|
|
@@ -1188,7 +1246,37 @@ function createGoogleAdapter(apiKey) {
|
|
|
1188
1246
|
};
|
|
1189
1247
|
},
|
|
1190
1248
|
async listModels() {
|
|
1191
|
-
|
|
1249
|
+
try {
|
|
1250
|
+
const res = await fetch(`${GEMINI_API_BASE}/models?key=${apiKey}`);
|
|
1251
|
+
if (!res.ok) return FALLBACK_MODELS2;
|
|
1252
|
+
const data = await res.json();
|
|
1253
|
+
const models = data.models || [];
|
|
1254
|
+
return models.filter((m) => m.name?.startsWith("models/gemini-") && m.supportedGenerationMethods?.includes("generateContent")).map((m) => {
|
|
1255
|
+
const modelId = m.name.replace("models/", "");
|
|
1256
|
+
return {
|
|
1257
|
+
id: `google/${modelId}`,
|
|
1258
|
+
name: m.displayName || modelId,
|
|
1259
|
+
created: 0,
|
|
1260
|
+
description: m.description || "",
|
|
1261
|
+
context_length: m.inputTokenLimit || 1048576,
|
|
1262
|
+
pricing: { prompt: "0", completion: "0" },
|
|
1263
|
+
architecture: {
|
|
1264
|
+
modality: "text+image->text",
|
|
1265
|
+
input_modalities: ["text", "image", "video", "audio"],
|
|
1266
|
+
output_modalities: ["text"],
|
|
1267
|
+
tokenizer: "gemini"
|
|
1268
|
+
},
|
|
1269
|
+
top_provider: {
|
|
1270
|
+
context_length: m.inputTokenLimit || 1048576,
|
|
1271
|
+
max_completion_tokens: m.outputTokenLimit || 65536,
|
|
1272
|
+
is_moderated: false
|
|
1273
|
+
},
|
|
1274
|
+
supported_parameters: Array.from(SUPPORTED_PARAMS3)
|
|
1275
|
+
};
|
|
1276
|
+
});
|
|
1277
|
+
} catch {
|
|
1278
|
+
return FALLBACK_MODELS2;
|
|
1279
|
+
}
|
|
1192
1280
|
},
|
|
1193
1281
|
supportsParameter(param) {
|
|
1194
1282
|
return SUPPORTED_PARAMS3.has(param);
|
|
@@ -1352,14 +1440,22 @@ function deepMerge(target, source) {
|
|
|
1352
1440
|
}
|
|
1353
1441
|
function envConfig() {
|
|
1354
1442
|
const config = {};
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1443
|
+
const envMap = [
|
|
1444
|
+
["openai", "OPENAI_API_KEY"],
|
|
1445
|
+
["anthropic", "ANTHROPIC_API_KEY"],
|
|
1446
|
+
["google", "GOOGLE_API_KEY"],
|
|
1447
|
+
["mistral", "MISTRAL_API_KEY"],
|
|
1448
|
+
["groq", "GROQ_API_KEY"],
|
|
1449
|
+
["deepseek", "DEEPSEEK_API_KEY"],
|
|
1450
|
+
["xai", "XAI_API_KEY"],
|
|
1451
|
+
["together", "TOGETHER_API_KEY"],
|
|
1452
|
+
["fireworks", "FIREWORKS_API_KEY"],
|
|
1453
|
+
["perplexity", "PERPLEXITY_API_KEY"]
|
|
1454
|
+
];
|
|
1455
|
+
for (const [key, envVar] of envMap) {
|
|
1456
|
+
if (process.env[envVar]) {
|
|
1457
|
+
config[key] = { apiKey: process.env[envVar] };
|
|
1458
|
+
}
|
|
1363
1459
|
}
|
|
1364
1460
|
return config;
|
|
1365
1461
|
}
|
|
@@ -1774,21 +1870,42 @@ var AnyModel = class {
|
|
|
1774
1870
|
};
|
|
1775
1871
|
}
|
|
1776
1872
|
registerProviders() {
|
|
1777
|
-
const
|
|
1778
|
-
const
|
|
1779
|
-
const openaiKey = openai?.apiKey || process.env.OPENAI_API_KEY;
|
|
1780
|
-
const googleKey = google?.apiKey || process.env.GOOGLE_API_KEY;
|
|
1873
|
+
const config = this.config;
|
|
1874
|
+
const openaiKey = config.openai?.apiKey || process.env.OPENAI_API_KEY;
|
|
1781
1875
|
if (openaiKey) {
|
|
1782
1876
|
this.registry.register("openai", createOpenAIAdapter(openaiKey));
|
|
1783
1877
|
}
|
|
1878
|
+
const anthropicKey = config.anthropic?.apiKey || process.env.ANTHROPIC_API_KEY;
|
|
1784
1879
|
if (anthropicKey) {
|
|
1785
1880
|
this.registry.register("anthropic", createAnthropicAdapter(anthropicKey));
|
|
1786
1881
|
}
|
|
1882
|
+
const googleKey = config.google?.apiKey || process.env.GOOGLE_API_KEY;
|
|
1787
1883
|
if (googleKey) {
|
|
1788
1884
|
this.registry.register("google", createGoogleAdapter(googleKey));
|
|
1789
1885
|
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1886
|
+
const builtinProviders = [
|
|
1887
|
+
{ name: "mistral", baseURL: "https://api.mistral.ai/v1", configKey: "mistral", envVar: "MISTRAL_API_KEY" },
|
|
1888
|
+
{ name: "groq", baseURL: "https://api.groq.com/openai/v1", configKey: "groq", envVar: "GROQ_API_KEY" },
|
|
1889
|
+
{ name: "deepseek", baseURL: "https://api.deepseek.com", configKey: "deepseek", envVar: "DEEPSEEK_API_KEY" },
|
|
1890
|
+
{ name: "xai", baseURL: "https://api.x.ai/v1", configKey: "xai", envVar: "XAI_API_KEY" },
|
|
1891
|
+
{ name: "together", baseURL: "https://api.together.xyz/v1", configKey: "together", envVar: "TOGETHER_API_KEY" },
|
|
1892
|
+
{ name: "fireworks", baseURL: "https://api.fireworks.ai/inference/v1", configKey: "fireworks", envVar: "FIREWORKS_API_KEY" },
|
|
1893
|
+
{ name: "perplexity", baseURL: "https://api.perplexity.ai", configKey: "perplexity", envVar: "PERPLEXITY_API_KEY" }
|
|
1894
|
+
];
|
|
1895
|
+
for (const { name, baseURL, configKey, envVar } of builtinProviders) {
|
|
1896
|
+
const providerConfig = config[configKey];
|
|
1897
|
+
const key = providerConfig?.apiKey || process.env[envVar];
|
|
1898
|
+
if (key) {
|
|
1899
|
+
this.registry.register(name, createCustomAdapter(name, { baseURL, apiKey: key }));
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
const ollamaConfig = config.ollama;
|
|
1903
|
+
const ollamaURL = ollamaConfig?.baseURL || process.env.OLLAMA_BASE_URL || "http://localhost:11434/v1";
|
|
1904
|
+
if (ollamaConfig || process.env.OLLAMA_BASE_URL) {
|
|
1905
|
+
this.registry.register("ollama", createCustomAdapter("ollama", { baseURL: ollamaURL }));
|
|
1906
|
+
}
|
|
1907
|
+
if (config.custom) {
|
|
1908
|
+
for (const [name, customConfig] of Object.entries(config.custom)) {
|
|
1792
1909
|
this.registry.register(name, createCustomAdapter(name, customConfig));
|
|
1793
1910
|
}
|
|
1794
1911
|
}
|