@uipath/apollo-react 4.59.3 → 4.61.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/canvas/icons/LayersArrowUpRightIcon.cjs +67 -0
- package/dist/canvas/icons/LayersArrowUpRightIcon.d.ts +5 -0
- package/dist/canvas/icons/LayersArrowUpRightIcon.d.ts.map +1 -0
- package/dist/canvas/icons/LayersArrowUpRightIcon.js +33 -0
- package/dist/canvas/icons/index.cjs +7 -3
- package/dist/canvas/icons/index.d.ts +1 -0
- package/dist/canvas/icons/index.d.ts.map +1 -1
- package/dist/canvas/icons/index.js +2 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/canvas/utils/icon-registry.cjs +4 -0
- package/dist/canvas/utils/icon-registry.d.ts.map +1 -1
- package/dist/canvas/utils/icon-registry.js +5 -1
- package/dist/material/components/ap-model-picker/ModelPicker.cjs +543 -0
- package/dist/material/components/ap-model-picker/ModelPicker.d.ts +56 -0
- package/dist/material/components/ap-model-picker/ModelPicker.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/ModelPicker.js +494 -0
- package/dist/material/components/ap-model-picker/ModelTagChip.cjs +140 -0
- package/dist/material/components/ap-model-picker/ModelTagChip.d.ts +11 -0
- package/dist/material/components/ap-model-picker/ModelTagChip.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/ModelTagChip.js +90 -0
- package/dist/material/components/ap-model-picker/badges.cjs +53 -0
- package/dist/material/components/ap-model-picker/badges.d.ts +9 -0
- package/dist/material/components/ap-model-picker/badges.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/badges.js +19 -0
- package/dist/material/components/ap-model-picker/i18n.cjs +187 -0
- package/dist/material/components/ap-model-picker/i18n.d.ts +53 -0
- package/dist/material/components/ap-model-picker/i18n.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/i18n.js +117 -0
- package/dist/material/components/ap-model-picker/index.cjs +112 -0
- package/dist/material/components/ap-model-picker/index.d.ts +31 -0
- package/dist/material/components/ap-model-picker/index.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/index.js +15 -0
- package/dist/material/components/ap-model-picker/locales/de.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/de.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/de.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/de.js +2 -0
- package/dist/material/components/ap-model-picker/locales/en.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/en.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/en.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/en.js +2 -0
- package/dist/material/components/ap-model-picker/locales/es-MX.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/es-MX.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/es-MX.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/es-MX.js +2 -0
- package/dist/material/components/ap-model-picker/locales/es.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/es.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/es.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/es.js +2 -0
- package/dist/material/components/ap-model-picker/locales/fr.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/fr.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/fr.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/fr.js +2 -0
- package/dist/material/components/ap-model-picker/locales/ja.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/ja.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/ja.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/ja.js +2 -0
- package/dist/material/components/ap-model-picker/locales/ko.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/ko.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/ko.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/ko.js +2 -0
- package/dist/material/components/ap-model-picker/locales/pt-BR.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/pt-BR.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/pt-BR.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/pt-BR.js +2 -0
- package/dist/material/components/ap-model-picker/locales/pt.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/pt.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/pt.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/pt.js +2 -0
- package/dist/material/components/ap-model-picker/locales/ru.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/ru.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/ru.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/ru.js +2 -0
- package/dist/material/components/ap-model-picker/locales/tr.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/tr.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/tr.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/tr.js +2 -0
- package/dist/material/components/ap-model-picker/locales/zh-CN.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/zh-CN.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/zh-CN.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/zh-CN.js +2 -0
- package/dist/material/components/ap-model-picker/locales/zh-TW.cjs +36 -0
- package/dist/material/components/ap-model-picker/locales/zh-TW.d.ts +3 -0
- package/dist/material/components/ap-model-picker/locales/zh-TW.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/locales/zh-TW.js +2 -0
- package/dist/material/components/ap-model-picker/primitives/FolderSwitcher.cjs +236 -0
- package/dist/material/components/ap-model-picker/primitives/FolderSwitcher.d.ts +15 -0
- package/dist/material/components/ap-model-picker/primitives/FolderSwitcher.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/primitives/FolderSwitcher.js +181 -0
- package/dist/material/components/ap-model-picker/primitives/GroupHeader.cjs +139 -0
- package/dist/material/components/ap-model-picker/primitives/GroupHeader.d.ts +16 -0
- package/dist/material/components/ap-model-picker/primitives/GroupHeader.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/primitives/GroupHeader.js +92 -0
- package/dist/material/components/ap-model-picker/primitives/ModelOptionRow.cjs +258 -0
- package/dist/material/components/ap-model-picker/primitives/ModelOptionRow.d.ts +29 -0
- package/dist/material/components/ap-model-picker/primitives/ModelOptionRow.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/primitives/ModelOptionRow.js +199 -0
- package/dist/material/components/ap-model-picker/primitives/OptionList.cjs +287 -0
- package/dist/material/components/ap-model-picker/primitives/OptionList.d.ts +31 -0
- package/dist/material/components/ap-model-picker/primitives/OptionList.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/primitives/OptionList.js +235 -0
- package/dist/material/components/ap-model-picker/primitives/PickerPopup.cjs +110 -0
- package/dist/material/components/ap-model-picker/primitives/PickerPopup.d.ts +16 -0
- package/dist/material/components/ap-model-picker/primitives/PickerPopup.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/primitives/PickerPopup.js +63 -0
- package/dist/material/components/ap-model-picker/primitives/PickerSearchInput.cjs +143 -0
- package/dist/material/components/ap-model-picker/primitives/PickerSearchInput.d.ts +18 -0
- package/dist/material/components/ap-model-picker/primitives/PickerSearchInput.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/primitives/PickerSearchInput.js +97 -0
- package/dist/material/components/ap-model-picker/primitives/PickerTrigger.cjs +195 -0
- package/dist/material/components/ap-model-picker/primitives/PickerTrigger.d.ts +25 -0
- package/dist/material/components/ap-model-picker/primitives/PickerTrigger.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/primitives/PickerTrigger.js +148 -0
- package/dist/material/components/ap-model-picker/types.cjs +18 -0
- package/dist/material/components/ap-model-picker/types.d.ts +77 -0
- package/dist/material/components/ap-model-picker/types.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/types.js +0 -0
- package/dist/material/components/ap-model-picker/useDiscoveryModels.cjs +113 -0
- package/dist/material/components/ap-model-picker/useDiscoveryModels.d.ts +9 -0
- package/dist/material/components/ap-model-picker/useDiscoveryModels.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/useDiscoveryModels.js +79 -0
- package/dist/material/components/ap-model-picker/useModelPickerState.cjs +175 -0
- package/dist/material/components/ap-model-picker/useModelPickerState.d.ts +40 -0
- package/dist/material/components/ap-model-picker/useModelPickerState.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/useModelPickerState.js +141 -0
- package/dist/material/components/ap-model-picker/usePlatformAccess.cjs +184 -0
- package/dist/material/components/ap-model-picker/usePlatformAccess.d.ts +32 -0
- package/dist/material/components/ap-model-picker/usePlatformAccess.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/usePlatformAccess.js +141 -0
- package/dist/material/components/ap-model-picker/utils.cjs +309 -0
- package/dist/material/components/ap-model-picker/utils.d.ts +23 -0
- package/dist/material/components/ap-model-picker/utils.d.ts.map +1 -0
- package/dist/material/components/ap-model-picker/utils.js +263 -0
- package/dist/material/components/index.cjs +31 -24
- package/dist/material/components/index.d.ts +1 -0
- package/dist/material/components/index.d.ts.map +1 -1
- package/dist/material/components/index.js +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
groupModels: ()=>groupModels,
|
|
28
|
+
getSubstitutionTarget: ()=>getSubstitutionTarget,
|
|
29
|
+
filterModels: ()=>filterModels,
|
|
30
|
+
deriveModelTags: ()=>deriveModelTags,
|
|
31
|
+
defaultCostTier: ()=>defaultCostTier
|
|
32
|
+
});
|
|
33
|
+
const external_badges_cjs_namespaceObject = require("./badges.cjs");
|
|
34
|
+
const external_i18n_cjs_namespaceObject = require("./i18n.cjs");
|
|
35
|
+
const RECOMMENDED_SUBSCRIPTION = 'UiPathOwned';
|
|
36
|
+
const isByoModel = (m)=>'BYOMAdded' === m.modelSubscriptionType || 'BYOMReplacedAlternative' === m.modelSubscriptionType || 'BYOMReplacedLikeForLike' === m.modelSubscriptionType || !!m.byomDetails || !!m.byoConnectionLabel;
|
|
37
|
+
function deriveModelTags(model, context = {}) {
|
|
38
|
+
const tags = [];
|
|
39
|
+
const localize = (desc)=>{
|
|
40
|
+
if (context.i18n) return (0, external_i18n_cjs_namespaceObject.tr)(context.i18n, desc);
|
|
41
|
+
return desc.message ?? desc.id;
|
|
42
|
+
};
|
|
43
|
+
const isByo = isByoModel(model);
|
|
44
|
+
const isRecommended = void 0 !== context.recommendedModelIds ? context.recommendedModelIds.includes(model.modelId) : model.isRecommended ?? (model.modelSubscriptionType === RECOMMENDED_SUBSCRIPTION && !model.isPreview && !model.deprecationDetails?.usageEndDate);
|
|
45
|
+
if (isRecommended) tags.push({
|
|
46
|
+
kind: 'recommended',
|
|
47
|
+
label: localize(external_i18n_cjs_namespaceObject.TAG_LABELS.recommended),
|
|
48
|
+
tooltip: localize(external_i18n_cjs_namespaceObject.TAG_LABELS.recommendedTooltip)
|
|
49
|
+
});
|
|
50
|
+
const isPreview = void 0 !== context.previewModelIds ? context.previewModelIds.includes(model.modelId) : !!model.isPreview;
|
|
51
|
+
if (!isByo && isPreview) tags.push({
|
|
52
|
+
kind: 'preview',
|
|
53
|
+
label: localize(external_i18n_cjs_namespaceObject.TAG_LABELS.preview)
|
|
54
|
+
});
|
|
55
|
+
const substitutionTarget = getSubstitutionTarget(model);
|
|
56
|
+
if (substitutionTarget) tags.push({
|
|
57
|
+
kind: 'substituted',
|
|
58
|
+
label: context.i18n ? context.i18n._({
|
|
59
|
+
id: 'modelPicker.tag.substituted.label',
|
|
60
|
+
message: 'Routes to {target}',
|
|
61
|
+
values: {
|
|
62
|
+
target: substitutionTarget
|
|
63
|
+
}
|
|
64
|
+
}) : `Routes to ${substitutionTarget}`,
|
|
65
|
+
tooltip: context.i18n ? context.i18n._({
|
|
66
|
+
id: 'modelPicker.tag.substituted.tooltip',
|
|
67
|
+
message: 'This model is retired. Your traffic is currently being routed to {target}. Update your configuration to make this explicit.',
|
|
68
|
+
values: {
|
|
69
|
+
target: substitutionTarget
|
|
70
|
+
}
|
|
71
|
+
}) : `This model is retired. Your traffic is currently being routed to ${substitutionTarget}. Update your configuration to make this explicit.`
|
|
72
|
+
});
|
|
73
|
+
else if (model.deprecationDetails?.usageEndDate) {
|
|
74
|
+
const date = formatDate(model.deprecationDetails.usageEndDate);
|
|
75
|
+
tags.push({
|
|
76
|
+
kind: 'deprecating',
|
|
77
|
+
label: context.i18n ? context.i18n._({
|
|
78
|
+
id: 'modelPicker.tag.deprecating.label',
|
|
79
|
+
message: 'Deprecating {date}',
|
|
80
|
+
values: {
|
|
81
|
+
date
|
|
82
|
+
}
|
|
83
|
+
}) : `Deprecating ${date}`,
|
|
84
|
+
tooltip: model.deprecationDetails.replacedBy ? context.i18n ? context.i18n._({
|
|
85
|
+
id: 'modelPicker.tag.deprecating.tooltip',
|
|
86
|
+
message: 'Will be replaced by {replacement}',
|
|
87
|
+
values: {
|
|
88
|
+
replacement: model.deprecationDetails.replacedBy
|
|
89
|
+
}
|
|
90
|
+
}) : `Will be replaced by ${model.deprecationDetails.replacedBy}` : void 0
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (isByo) tags.push({
|
|
94
|
+
kind: 'custom',
|
|
95
|
+
label: localize(external_i18n_cjs_namespaceObject.TAG_LABELS.custom)
|
|
96
|
+
});
|
|
97
|
+
if (!isByo) {
|
|
98
|
+
const geo = model.routingDetails?.geography;
|
|
99
|
+
if (geo && context.homeRegion && 'GLOBAL' !== geo && geo !== context.homeRegion) tags.push({
|
|
100
|
+
kind: 'out-of-region',
|
|
101
|
+
label: context.i18n ? context.i18n._({
|
|
102
|
+
id: 'modelPicker.tag.outOfRegion.label',
|
|
103
|
+
message: 'Out of region ({geography})',
|
|
104
|
+
values: {
|
|
105
|
+
geography: geo
|
|
106
|
+
}
|
|
107
|
+
}) : `Out of region (${geo})`,
|
|
108
|
+
tooltip: context.i18n ? context.i18n._({
|
|
109
|
+
id: 'modelPicker.tag.outOfRegion.tooltip',
|
|
110
|
+
message: 'Routes traffic outside {homeRegion}',
|
|
111
|
+
values: {
|
|
112
|
+
homeRegion: context.homeRegion
|
|
113
|
+
}
|
|
114
|
+
}) : `Routes traffic outside ${context.homeRegion}`
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (context.badgesFor) for (const kind of context.badgesFor(model) ?? []){
|
|
118
|
+
const def = external_badges_cjs_namespaceObject.MODEL_BADGES[kind];
|
|
119
|
+
if (def) tags.push({
|
|
120
|
+
kind,
|
|
121
|
+
label: localize(def.label),
|
|
122
|
+
tooltip: def.tooltip ? localize(def.tooltip) : void 0,
|
|
123
|
+
variant: def.variant
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
if (context.customTagsFor) {
|
|
127
|
+
const extra = context.customTagsFor(model);
|
|
128
|
+
if (extra?.length) tags.push(...extra);
|
|
129
|
+
}
|
|
130
|
+
return tags;
|
|
131
|
+
}
|
|
132
|
+
const DEFAULT_BASIC_THRESHOLD = 1.0;
|
|
133
|
+
const DEFAULT_PREMIUM_THRESHOLD = 5.0;
|
|
134
|
+
function defaultCostTier(model) {
|
|
135
|
+
const inputCost = model.modelDetails?.costDetails?.inputTokenCost;
|
|
136
|
+
if (null == inputCost) return null;
|
|
137
|
+
if (inputCost < DEFAULT_BASIC_THRESHOLD) return 'basic';
|
|
138
|
+
if (inputCost < DEFAULT_PREMIUM_THRESHOLD) return 'standard';
|
|
139
|
+
return 'premium';
|
|
140
|
+
}
|
|
141
|
+
function getSubstitutionTarget(model) {
|
|
142
|
+
const effective = model.effectiveModel;
|
|
143
|
+
if (effective && effective !== model.modelName && effective !== model.modelId) return model.deprecationDetails?.replacedBy ?? effective;
|
|
144
|
+
const routed = model.routingDetails?.model;
|
|
145
|
+
if (routed && routed !== model.modelName && routed !== model.modelId) return model.deprecationDetails?.replacedBy ?? routed;
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
const VENDOR_LABELS = {
|
|
149
|
+
AnthropicClaude: 'Anthropic',
|
|
150
|
+
OpenAi: 'OpenAI',
|
|
151
|
+
AzureOpenAi: 'Azure OpenAI',
|
|
152
|
+
VertexAi: 'Google Vertex',
|
|
153
|
+
AwsBedrock: 'AWS Bedrock'
|
|
154
|
+
};
|
|
155
|
+
function vendorLabel(vendor) {
|
|
156
|
+
return VENDOR_LABELS[vendor] ?? vendor;
|
|
157
|
+
}
|
|
158
|
+
function formatDate(iso) {
|
|
159
|
+
const date = new Date(iso);
|
|
160
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
161
|
+
return date.toLocaleDateString(void 0, {
|
|
162
|
+
month: 'short',
|
|
163
|
+
year: 'numeric'
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function buildSubscriptionMatchers(ctx) {
|
|
167
|
+
const isRecommended = (m)=>void 0 !== ctx.recommendedModelIds ? ctx.recommendedModelIds.includes(m.modelId) : m.isRecommended ?? (m.modelSubscriptionType === RECOMMENDED_SUBSCRIPTION && !m.isPreview && !m.deprecationDetails?.usageEndDate);
|
|
168
|
+
const isPreview = (m)=>void 0 !== ctx.previewModelIds ? ctx.previewModelIds.includes(m.modelId) : !!m.isPreview;
|
|
169
|
+
const localize = (desc)=>{
|
|
170
|
+
if (ctx.i18n) return (0, external_i18n_cjs_namespaceObject.tr)(ctx.i18n, desc);
|
|
171
|
+
return desc.message ?? desc.id;
|
|
172
|
+
};
|
|
173
|
+
return [
|
|
174
|
+
{
|
|
175
|
+
key: 'byo',
|
|
176
|
+
label: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.byo),
|
|
177
|
+
hint: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.byoHint),
|
|
178
|
+
match: (m)=>isByoModel(m)
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
key: 'recommended',
|
|
182
|
+
label: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.recommended),
|
|
183
|
+
hint: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.recommendedHint),
|
|
184
|
+
match: (m)=>isRecommended(m) && !m.deprecationDetails?.usageEndDate
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
key: 'preview',
|
|
188
|
+
label: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.preview),
|
|
189
|
+
hint: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.previewHint),
|
|
190
|
+
match: (m)=>isPreview(m) && !isByoModel(m) && !m.deprecationDetails?.usageEndDate
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
key: 'more',
|
|
194
|
+
label: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.more),
|
|
195
|
+
hint: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.moreHint),
|
|
196
|
+
match: (m)=>!isByoModel(m) && !m.deprecationDetails?.usageEndDate
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
key: 'deprecating',
|
|
200
|
+
label: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.deprecating),
|
|
201
|
+
hint: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.deprecatingHint),
|
|
202
|
+
match: (m)=>!!m.deprecationDetails?.usageEndDate
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
key: 'shared',
|
|
206
|
+
label: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.other),
|
|
207
|
+
match: ()=>true
|
|
208
|
+
}
|
|
209
|
+
];
|
|
210
|
+
}
|
|
211
|
+
function groupModels(models, strategy = "subscription", context = {}) {
|
|
212
|
+
const localize = (desc)=>{
|
|
213
|
+
if (context.i18n) return (0, external_i18n_cjs_namespaceObject.tr)(context.i18n, desc);
|
|
214
|
+
return desc.message ?? desc.id;
|
|
215
|
+
};
|
|
216
|
+
if ('flat' === strategy) return [
|
|
217
|
+
{
|
|
218
|
+
key: 'all',
|
|
219
|
+
label: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.allModels),
|
|
220
|
+
models
|
|
221
|
+
}
|
|
222
|
+
];
|
|
223
|
+
if ('vendor' === strategy) {
|
|
224
|
+
const byVendor = new Map();
|
|
225
|
+
const byo = [];
|
|
226
|
+
for (const m of models){
|
|
227
|
+
if (isByoModel(m)) {
|
|
228
|
+
byo.push(m);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
const k = m.vendor || 'Other';
|
|
232
|
+
if (!byVendor.has(k)) byVendor.set(k, []);
|
|
233
|
+
byVendor.get(k).push(m);
|
|
234
|
+
}
|
|
235
|
+
const groups = [];
|
|
236
|
+
if (byo.length) groups.push({
|
|
237
|
+
key: 'byo',
|
|
238
|
+
label: localize(external_i18n_cjs_namespaceObject.GROUP_LABELS.byo),
|
|
239
|
+
models: byo
|
|
240
|
+
});
|
|
241
|
+
const matchers = buildSubscriptionMatchers(context);
|
|
242
|
+
const ranks = new Map();
|
|
243
|
+
const lifecycleRank = (m)=>{
|
|
244
|
+
let r = ranks.get(m);
|
|
245
|
+
if (void 0 === r) {
|
|
246
|
+
const i = matchers.findIndex((g)=>g.match(m));
|
|
247
|
+
r = -1 === i ? matchers.length : i;
|
|
248
|
+
ranks.set(m, r);
|
|
249
|
+
}
|
|
250
|
+
return r;
|
|
251
|
+
};
|
|
252
|
+
for (const [key, list] of byVendor.entries())groups.push({
|
|
253
|
+
key,
|
|
254
|
+
label: vendorLabel(key),
|
|
255
|
+
models: list.sort((a, b)=>lifecycleRank(a) - lifecycleRank(b))
|
|
256
|
+
});
|
|
257
|
+
return groups;
|
|
258
|
+
}
|
|
259
|
+
const matchers = buildSubscriptionMatchers(context);
|
|
260
|
+
const buckets = {};
|
|
261
|
+
for (const m of models){
|
|
262
|
+
const bucket = matchers.find((g)=>g.match(m));
|
|
263
|
+
if (!bucket) continue;
|
|
264
|
+
const list = buckets[bucket.key] ?? (buckets[bucket.key] = []);
|
|
265
|
+
list.push(m);
|
|
266
|
+
}
|
|
267
|
+
const out = [];
|
|
268
|
+
for (const g of matchers){
|
|
269
|
+
const list = buckets[g.key];
|
|
270
|
+
if (list?.length) out.push({
|
|
271
|
+
key: g.key,
|
|
272
|
+
label: g.label,
|
|
273
|
+
hint: g.hint,
|
|
274
|
+
models: list
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return out;
|
|
278
|
+
}
|
|
279
|
+
function filterModels(models, query) {
|
|
280
|
+
const q = query.trim().toLowerCase();
|
|
281
|
+
if (!q) return models;
|
|
282
|
+
return models.filter((m)=>{
|
|
283
|
+
const haystack = [
|
|
284
|
+
m.modelName,
|
|
285
|
+
m.displayName,
|
|
286
|
+
m.modelId,
|
|
287
|
+
m.vendor,
|
|
288
|
+
m.modelFamily,
|
|
289
|
+
m.effectiveModel,
|
|
290
|
+
m.byoConnectionLabel
|
|
291
|
+
].filter(Boolean).join(' ').toLowerCase();
|
|
292
|
+
return haystack.includes(q);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
exports.defaultCostTier = __webpack_exports__.defaultCostTier;
|
|
296
|
+
exports.deriveModelTags = __webpack_exports__.deriveModelTags;
|
|
297
|
+
exports.filterModels = __webpack_exports__.filterModels;
|
|
298
|
+
exports.getSubstitutionTarget = __webpack_exports__.getSubstitutionTarget;
|
|
299
|
+
exports.groupModels = __webpack_exports__.groupModels;
|
|
300
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
301
|
+
"defaultCostTier",
|
|
302
|
+
"deriveModelTags",
|
|
303
|
+
"filterModels",
|
|
304
|
+
"getSubstitutionTarget",
|
|
305
|
+
"groupModels"
|
|
306
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
307
|
+
Object.defineProperty(exports, '__esModule', {
|
|
308
|
+
value: true
|
|
309
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ModelBadgeKind } from './badges';
|
|
2
|
+
import type { PickerTranslator } from './i18n';
|
|
3
|
+
import type { CostTier, DiscoveryModel, ModelGroup, ModelTag } from './types';
|
|
4
|
+
export interface DeriveModelTagsContext {
|
|
5
|
+
i18n?: PickerTranslator;
|
|
6
|
+
homeRegion?: string;
|
|
7
|
+
recommendedModelIds?: readonly string[];
|
|
8
|
+
previewModelIds?: readonly string[];
|
|
9
|
+
badgesFor?: (model: DiscoveryModel) => readonly ModelBadgeKind[];
|
|
10
|
+
customTagsFor?: (model: DiscoveryModel) => readonly ModelTag[];
|
|
11
|
+
}
|
|
12
|
+
export declare function deriveModelTags(model: DiscoveryModel, context?: DeriveModelTagsContext): ModelTag[];
|
|
13
|
+
export declare function defaultCostTier(model: DiscoveryModel): CostTier | null;
|
|
14
|
+
export declare function getSubstitutionTarget(model: DiscoveryModel): string | null;
|
|
15
|
+
export type GroupStrategy = 'subscription' | 'vendor' | 'flat';
|
|
16
|
+
export interface GroupModelsContext {
|
|
17
|
+
recommendedModelIds?: readonly string[];
|
|
18
|
+
previewModelIds?: readonly string[];
|
|
19
|
+
i18n?: PickerTranslator;
|
|
20
|
+
}
|
|
21
|
+
export declare function groupModels(models: DiscoveryModel[], strategy?: GroupStrategy, context?: GroupModelsContext): ModelGroup[];
|
|
22
|
+
export declare function filterModels(models: DiscoveryModel[], query: string): DiscoveryModel[];
|
|
23
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/material/components/ap-model-picker/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG/C,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAS9E,MAAM,WAAW,sBAAsB;IAOrC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IAExB,UAAU,CAAC,EAAE,MAAM,CAAC;IASpB,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAKxC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAUpC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,cAAc,EAAE,CAAC;IAQjE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,QAAQ,EAAE,CAAC;CAChE;AAiBD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,EACrB,OAAO,GAAE,sBAA2B,GACnC,QAAQ,EAAE,CA6JZ;AAmBD,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,QAAQ,GAAG,IAAI,CAMtE;AAoBD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAa1E;AA8BD,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,QAAQ,GAAG,MAAM,CAAC;AAQ/D,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAMpC,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACzB;AAwED,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,EAAE,EACxB,QAAQ,GAAE,aAA8B,EACxC,OAAO,GAAE,kBAAuB,GAC/B,UAAU,EAAE,CA6Ed;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,CAkBtF"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { MODEL_BADGES } from "./badges.js";
|
|
2
|
+
import { GROUP_LABELS, TAG_LABELS, tr } from "./i18n.js";
|
|
3
|
+
const RECOMMENDED_SUBSCRIPTION = 'UiPathOwned';
|
|
4
|
+
const isByoModel = (m)=>'BYOMAdded' === m.modelSubscriptionType || 'BYOMReplacedAlternative' === m.modelSubscriptionType || 'BYOMReplacedLikeForLike' === m.modelSubscriptionType || !!m.byomDetails || !!m.byoConnectionLabel;
|
|
5
|
+
function deriveModelTags(model, context = {}) {
|
|
6
|
+
const tags = [];
|
|
7
|
+
const localize = (desc)=>{
|
|
8
|
+
if (context.i18n) return tr(context.i18n, desc);
|
|
9
|
+
return desc.message ?? desc.id;
|
|
10
|
+
};
|
|
11
|
+
const isByo = isByoModel(model);
|
|
12
|
+
const isRecommended = void 0 !== context.recommendedModelIds ? context.recommendedModelIds.includes(model.modelId) : model.isRecommended ?? (model.modelSubscriptionType === RECOMMENDED_SUBSCRIPTION && !model.isPreview && !model.deprecationDetails?.usageEndDate);
|
|
13
|
+
if (isRecommended) tags.push({
|
|
14
|
+
kind: 'recommended',
|
|
15
|
+
label: localize(TAG_LABELS.recommended),
|
|
16
|
+
tooltip: localize(TAG_LABELS.recommendedTooltip)
|
|
17
|
+
});
|
|
18
|
+
const isPreview = void 0 !== context.previewModelIds ? context.previewModelIds.includes(model.modelId) : !!model.isPreview;
|
|
19
|
+
if (!isByo && isPreview) tags.push({
|
|
20
|
+
kind: 'preview',
|
|
21
|
+
label: localize(TAG_LABELS.preview)
|
|
22
|
+
});
|
|
23
|
+
const substitutionTarget = getSubstitutionTarget(model);
|
|
24
|
+
if (substitutionTarget) tags.push({
|
|
25
|
+
kind: 'substituted',
|
|
26
|
+
label: context.i18n ? context.i18n._({
|
|
27
|
+
id: 'modelPicker.tag.substituted.label',
|
|
28
|
+
message: 'Routes to {target}',
|
|
29
|
+
values: {
|
|
30
|
+
target: substitutionTarget
|
|
31
|
+
}
|
|
32
|
+
}) : `Routes to ${substitutionTarget}`,
|
|
33
|
+
tooltip: context.i18n ? context.i18n._({
|
|
34
|
+
id: 'modelPicker.tag.substituted.tooltip',
|
|
35
|
+
message: 'This model is retired. Your traffic is currently being routed to {target}. Update your configuration to make this explicit.',
|
|
36
|
+
values: {
|
|
37
|
+
target: substitutionTarget
|
|
38
|
+
}
|
|
39
|
+
}) : `This model is retired. Your traffic is currently being routed to ${substitutionTarget}. Update your configuration to make this explicit.`
|
|
40
|
+
});
|
|
41
|
+
else if (model.deprecationDetails?.usageEndDate) {
|
|
42
|
+
const date = formatDate(model.deprecationDetails.usageEndDate);
|
|
43
|
+
tags.push({
|
|
44
|
+
kind: 'deprecating',
|
|
45
|
+
label: context.i18n ? context.i18n._({
|
|
46
|
+
id: 'modelPicker.tag.deprecating.label',
|
|
47
|
+
message: 'Deprecating {date}',
|
|
48
|
+
values: {
|
|
49
|
+
date
|
|
50
|
+
}
|
|
51
|
+
}) : `Deprecating ${date}`,
|
|
52
|
+
tooltip: model.deprecationDetails.replacedBy ? context.i18n ? context.i18n._({
|
|
53
|
+
id: 'modelPicker.tag.deprecating.tooltip',
|
|
54
|
+
message: 'Will be replaced by {replacement}',
|
|
55
|
+
values: {
|
|
56
|
+
replacement: model.deprecationDetails.replacedBy
|
|
57
|
+
}
|
|
58
|
+
}) : `Will be replaced by ${model.deprecationDetails.replacedBy}` : void 0
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (isByo) tags.push({
|
|
62
|
+
kind: 'custom',
|
|
63
|
+
label: localize(TAG_LABELS.custom)
|
|
64
|
+
});
|
|
65
|
+
if (!isByo) {
|
|
66
|
+
const geo = model.routingDetails?.geography;
|
|
67
|
+
if (geo && context.homeRegion && 'GLOBAL' !== geo && geo !== context.homeRegion) tags.push({
|
|
68
|
+
kind: 'out-of-region',
|
|
69
|
+
label: context.i18n ? context.i18n._({
|
|
70
|
+
id: 'modelPicker.tag.outOfRegion.label',
|
|
71
|
+
message: 'Out of region ({geography})',
|
|
72
|
+
values: {
|
|
73
|
+
geography: geo
|
|
74
|
+
}
|
|
75
|
+
}) : `Out of region (${geo})`,
|
|
76
|
+
tooltip: context.i18n ? context.i18n._({
|
|
77
|
+
id: 'modelPicker.tag.outOfRegion.tooltip',
|
|
78
|
+
message: 'Routes traffic outside {homeRegion}',
|
|
79
|
+
values: {
|
|
80
|
+
homeRegion: context.homeRegion
|
|
81
|
+
}
|
|
82
|
+
}) : `Routes traffic outside ${context.homeRegion}`
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (context.badgesFor) for (const kind of context.badgesFor(model) ?? []){
|
|
86
|
+
const def = MODEL_BADGES[kind];
|
|
87
|
+
if (def) tags.push({
|
|
88
|
+
kind,
|
|
89
|
+
label: localize(def.label),
|
|
90
|
+
tooltip: def.tooltip ? localize(def.tooltip) : void 0,
|
|
91
|
+
variant: def.variant
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (context.customTagsFor) {
|
|
95
|
+
const extra = context.customTagsFor(model);
|
|
96
|
+
if (extra?.length) tags.push(...extra);
|
|
97
|
+
}
|
|
98
|
+
return tags;
|
|
99
|
+
}
|
|
100
|
+
const DEFAULT_BASIC_THRESHOLD = 1.0;
|
|
101
|
+
const DEFAULT_PREMIUM_THRESHOLD = 5.0;
|
|
102
|
+
function defaultCostTier(model) {
|
|
103
|
+
const inputCost = model.modelDetails?.costDetails?.inputTokenCost;
|
|
104
|
+
if (null == inputCost) return null;
|
|
105
|
+
if (inputCost < DEFAULT_BASIC_THRESHOLD) return 'basic';
|
|
106
|
+
if (inputCost < DEFAULT_PREMIUM_THRESHOLD) return 'standard';
|
|
107
|
+
return 'premium';
|
|
108
|
+
}
|
|
109
|
+
function getSubstitutionTarget(model) {
|
|
110
|
+
const effective = model.effectiveModel;
|
|
111
|
+
if (effective && effective !== model.modelName && effective !== model.modelId) return model.deprecationDetails?.replacedBy ?? effective;
|
|
112
|
+
const routed = model.routingDetails?.model;
|
|
113
|
+
if (routed && routed !== model.modelName && routed !== model.modelId) return model.deprecationDetails?.replacedBy ?? routed;
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
const VENDOR_LABELS = {
|
|
117
|
+
AnthropicClaude: 'Anthropic',
|
|
118
|
+
OpenAi: 'OpenAI',
|
|
119
|
+
AzureOpenAi: 'Azure OpenAI',
|
|
120
|
+
VertexAi: 'Google Vertex',
|
|
121
|
+
AwsBedrock: 'AWS Bedrock'
|
|
122
|
+
};
|
|
123
|
+
function vendorLabel(vendor) {
|
|
124
|
+
return VENDOR_LABELS[vendor] ?? vendor;
|
|
125
|
+
}
|
|
126
|
+
function formatDate(iso) {
|
|
127
|
+
const date = new Date(iso);
|
|
128
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
129
|
+
return date.toLocaleDateString(void 0, {
|
|
130
|
+
month: 'short',
|
|
131
|
+
year: 'numeric'
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function buildSubscriptionMatchers(ctx) {
|
|
135
|
+
const isRecommended = (m)=>void 0 !== ctx.recommendedModelIds ? ctx.recommendedModelIds.includes(m.modelId) : m.isRecommended ?? (m.modelSubscriptionType === RECOMMENDED_SUBSCRIPTION && !m.isPreview && !m.deprecationDetails?.usageEndDate);
|
|
136
|
+
const isPreview = (m)=>void 0 !== ctx.previewModelIds ? ctx.previewModelIds.includes(m.modelId) : !!m.isPreview;
|
|
137
|
+
const localize = (desc)=>{
|
|
138
|
+
if (ctx.i18n) return tr(ctx.i18n, desc);
|
|
139
|
+
return desc.message ?? desc.id;
|
|
140
|
+
};
|
|
141
|
+
return [
|
|
142
|
+
{
|
|
143
|
+
key: 'byo',
|
|
144
|
+
label: localize(GROUP_LABELS.byo),
|
|
145
|
+
hint: localize(GROUP_LABELS.byoHint),
|
|
146
|
+
match: (m)=>isByoModel(m)
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
key: 'recommended',
|
|
150
|
+
label: localize(GROUP_LABELS.recommended),
|
|
151
|
+
hint: localize(GROUP_LABELS.recommendedHint),
|
|
152
|
+
match: (m)=>isRecommended(m) && !m.deprecationDetails?.usageEndDate
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
key: 'preview',
|
|
156
|
+
label: localize(GROUP_LABELS.preview),
|
|
157
|
+
hint: localize(GROUP_LABELS.previewHint),
|
|
158
|
+
match: (m)=>isPreview(m) && !isByoModel(m) && !m.deprecationDetails?.usageEndDate
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
key: 'more',
|
|
162
|
+
label: localize(GROUP_LABELS.more),
|
|
163
|
+
hint: localize(GROUP_LABELS.moreHint),
|
|
164
|
+
match: (m)=>!isByoModel(m) && !m.deprecationDetails?.usageEndDate
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
key: 'deprecating',
|
|
168
|
+
label: localize(GROUP_LABELS.deprecating),
|
|
169
|
+
hint: localize(GROUP_LABELS.deprecatingHint),
|
|
170
|
+
match: (m)=>!!m.deprecationDetails?.usageEndDate
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
key: 'shared',
|
|
174
|
+
label: localize(GROUP_LABELS.other),
|
|
175
|
+
match: ()=>true
|
|
176
|
+
}
|
|
177
|
+
];
|
|
178
|
+
}
|
|
179
|
+
function groupModels(models, strategy = "subscription", context = {}) {
|
|
180
|
+
const localize = (desc)=>{
|
|
181
|
+
if (context.i18n) return tr(context.i18n, desc);
|
|
182
|
+
return desc.message ?? desc.id;
|
|
183
|
+
};
|
|
184
|
+
if ('flat' === strategy) return [
|
|
185
|
+
{
|
|
186
|
+
key: 'all',
|
|
187
|
+
label: localize(GROUP_LABELS.allModels),
|
|
188
|
+
models
|
|
189
|
+
}
|
|
190
|
+
];
|
|
191
|
+
if ('vendor' === strategy) {
|
|
192
|
+
const byVendor = new Map();
|
|
193
|
+
const byo = [];
|
|
194
|
+
for (const m of models){
|
|
195
|
+
if (isByoModel(m)) {
|
|
196
|
+
byo.push(m);
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
const k = m.vendor || 'Other';
|
|
200
|
+
if (!byVendor.has(k)) byVendor.set(k, []);
|
|
201
|
+
byVendor.get(k).push(m);
|
|
202
|
+
}
|
|
203
|
+
const groups = [];
|
|
204
|
+
if (byo.length) groups.push({
|
|
205
|
+
key: 'byo',
|
|
206
|
+
label: localize(GROUP_LABELS.byo),
|
|
207
|
+
models: byo
|
|
208
|
+
});
|
|
209
|
+
const matchers = buildSubscriptionMatchers(context);
|
|
210
|
+
const ranks = new Map();
|
|
211
|
+
const lifecycleRank = (m)=>{
|
|
212
|
+
let r = ranks.get(m);
|
|
213
|
+
if (void 0 === r) {
|
|
214
|
+
const i = matchers.findIndex((g)=>g.match(m));
|
|
215
|
+
r = -1 === i ? matchers.length : i;
|
|
216
|
+
ranks.set(m, r);
|
|
217
|
+
}
|
|
218
|
+
return r;
|
|
219
|
+
};
|
|
220
|
+
for (const [key, list] of byVendor.entries())groups.push({
|
|
221
|
+
key,
|
|
222
|
+
label: vendorLabel(key),
|
|
223
|
+
models: list.sort((a, b)=>lifecycleRank(a) - lifecycleRank(b))
|
|
224
|
+
});
|
|
225
|
+
return groups;
|
|
226
|
+
}
|
|
227
|
+
const matchers = buildSubscriptionMatchers(context);
|
|
228
|
+
const buckets = {};
|
|
229
|
+
for (const m of models){
|
|
230
|
+
const bucket = matchers.find((g)=>g.match(m));
|
|
231
|
+
if (!bucket) continue;
|
|
232
|
+
const list = buckets[bucket.key] ?? (buckets[bucket.key] = []);
|
|
233
|
+
list.push(m);
|
|
234
|
+
}
|
|
235
|
+
const out = [];
|
|
236
|
+
for (const g of matchers){
|
|
237
|
+
const list = buckets[g.key];
|
|
238
|
+
if (list?.length) out.push({
|
|
239
|
+
key: g.key,
|
|
240
|
+
label: g.label,
|
|
241
|
+
hint: g.hint,
|
|
242
|
+
models: list
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
return out;
|
|
246
|
+
}
|
|
247
|
+
function filterModels(models, query) {
|
|
248
|
+
const q = query.trim().toLowerCase();
|
|
249
|
+
if (!q) return models;
|
|
250
|
+
return models.filter((m)=>{
|
|
251
|
+
const haystack = [
|
|
252
|
+
m.modelName,
|
|
253
|
+
m.displayName,
|
|
254
|
+
m.modelId,
|
|
255
|
+
m.vendor,
|
|
256
|
+
m.modelFamily,
|
|
257
|
+
m.effectiveModel,
|
|
258
|
+
m.byoConnectionLabel
|
|
259
|
+
].filter(Boolean).join(' ').toLowerCase();
|
|
260
|
+
return haystack.includes(q);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
export { defaultCostTier, deriveModelTags, filterModels, getSubstitutionTarget, groupModels };
|