@exulu/backend 1.58.0 → 1.59.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/dist/catalog-EOKGOHTY.js +10 -0
- package/dist/{chunk-RVLZ5EL3.js → chunk-U36VJDZ7.js} +644 -66
- package/dist/chunk-YS27XOXI.js +62 -0
- package/dist/{convert-exulu-tools-to-ai-sdk-tools-K4W6OJ3G.js → convert-exulu-tools-to-ai-sdk-tools-ZEECMX43.js} +1 -1
- package/dist/index.cjs +2606 -1236
- package/dist/index.d.cts +13 -14
- package/dist/index.d.ts +13 -14
- package/dist/index.js +1812 -1134
- package/ee/python/.litellm/config.yaml.example +64 -0
- package/ee/python/requirements.txt +15 -0
- package/ee/python/setup.sh +13 -0
- package/ee/workers.ts +15 -29
- package/package.json +3 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/exulu/litellm/catalog.ts
|
|
2
|
+
var CACHE_TTL_MS = 3e4;
|
|
3
|
+
var _cache;
|
|
4
|
+
var __resetLiteLLMCatalogCacheForTesting = () => {
|
|
5
|
+
_cache = void 0;
|
|
6
|
+
};
|
|
7
|
+
var fetchLiteLLMCatalog = async () => {
|
|
8
|
+
if (process.env.EXULU_USE_LITELLM !== "true") return [];
|
|
9
|
+
if (_cache && _cache.expiresAt > Date.now()) {
|
|
10
|
+
return _cache.items;
|
|
11
|
+
}
|
|
12
|
+
const host = process.env.LITELLM_HOST ?? "127.0.0.1";
|
|
13
|
+
const port = process.env.LITELLM_PORT ?? "4000";
|
|
14
|
+
const masterKey = process.env.LITELLM_MASTER_KEY;
|
|
15
|
+
if (!masterKey) return [];
|
|
16
|
+
try {
|
|
17
|
+
const res = await fetch(`http://${host}:${port}/model/info`, {
|
|
18
|
+
method: "GET",
|
|
19
|
+
headers: { Authorization: `Bearer ${masterKey}` }
|
|
20
|
+
});
|
|
21
|
+
if (!res.ok) {
|
|
22
|
+
console.error(
|
|
23
|
+
`[EXULU] litellmCatalog: LiteLLM /model/info returned ${res.status}`
|
|
24
|
+
);
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const json = await res.json();
|
|
28
|
+
const items = (Array.isArray(json?.data) ? json.data : []).map((m) => ({
|
|
29
|
+
// filter out trailing * from model_name
|
|
30
|
+
model_name: m.model_name.replace(/\*$/, ""),
|
|
31
|
+
upstream_model: m.litellm_params?.model ?? null,
|
|
32
|
+
tags: Array.isArray(m.model_info?.tags) ? m.model_info.tags : [],
|
|
33
|
+
brand: m.model_info?.brand ?? null,
|
|
34
|
+
type: m.model_info?.type ?? null,
|
|
35
|
+
region: m.model_info?.region ?? null,
|
|
36
|
+
max_tokens: m.model_info?.max_tokens ?? null,
|
|
37
|
+
max_input_tokens: m.model_info?.max_input_tokens ?? null,
|
|
38
|
+
active: m.model_info?.active ?? true,
|
|
39
|
+
max_output_tokens: m.model_info?.max_output_tokens ?? null,
|
|
40
|
+
supports_vision: !!m.model_info?.supports_vision,
|
|
41
|
+
supports_function_calling: !!m.model_info?.supports_function_calling,
|
|
42
|
+
supports_pdf_input: !!m.model_info?.supports_pdf_input,
|
|
43
|
+
supports_audio_input: !!m.model_info?.supports_audio_input
|
|
44
|
+
}));
|
|
45
|
+
_cache = { expiresAt: Date.now() + CACHE_TTL_MS, items };
|
|
46
|
+
return items.filter((m) => m.type !== "speech_to_text" && m.type !== "text_to_speech");
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.error("[EXULU] litellmCatalog: failed to fetch /model/info:", err);
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var findLiteLLMModel = async (modelName) => {
|
|
53
|
+
if (!modelName) return void 0;
|
|
54
|
+
const items = await fetchLiteLLMCatalog();
|
|
55
|
+
return items.find((m) => m.model_name === modelName);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
__resetLiteLLMCatalogCacheForTesting,
|
|
60
|
+
fetchLiteLLMCatalog,
|
|
61
|
+
findLiteLLMModel
|
|
62
|
+
};
|