File size: 4,007 Bytes
676fc08 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
import { shuffle } from "radash";
export function multiApiKeyPolling(apiKeys = "") {
return shuffle(apiKeys.split(","))[0];
}
export function isThinkingModel(model: string) {
return (
model.includes("thinking") ||
model.startsWith("gemini-2.5-pro") ||
model.startsWith("gemini-2.5-flash")
);
}
export function isNetworkingModel(model: string) {
return (
(model.startsWith("gemini-2.0-flash") &&
!model.includes("lite") &&
!model.includes("thinking") &&
!model.includes("image")) ||
model.startsWith("gemini-2.5-pro") ||
model.startsWith("gemini-2.5-flash")
);
}
export function isOpenRouterFreeModel(model: string) {
return model.endsWith(":free");
}
export function filterThinkingModelList(modelList: string[]) {
const thinkingModelList: string[] = [];
const nonThinkingModelList: string[] = [];
modelList.forEach((model) => {
if (isThinkingModel(model)) {
thinkingModelList.push(model);
} else {
nonThinkingModelList.push(model);
}
});
return [thinkingModelList, nonThinkingModelList];
}
export function filterNetworkingModelList(modelList: string[]) {
const networkingModelList: string[] = [];
const nonNetworkingModelList: string[] = [];
modelList.filter((model) => {
if (isNetworkingModel(model)) {
networkingModelList.push(model);
} else {
nonNetworkingModelList.push(model);
}
});
return [networkingModelList, nonNetworkingModelList];
}
export function filterOpenRouterModelList(modelList: string[]) {
const freeModelList: string[] = [];
const paidModelList: string[] = [];
modelList.filter((model) => {
if (isOpenRouterFreeModel(model)) {
freeModelList.push(model);
} else {
paidModelList.push(model);
}
});
return [freeModelList, paidModelList];
}
export function filterDeepSeekModelList(modelList: string[]) {
const thinkingModelList: string[] = [];
const nonThinkingModelList: string[] = [];
modelList.filter((model) => {
if (model.includes("reasoner")) {
thinkingModelList.push(model);
} else {
nonThinkingModelList.push(model);
}
});
return [thinkingModelList, nonThinkingModelList];
}
export function filterOpenAIModelList(modelList: string[]) {
const networkingModelList: string[] = [];
const nonNetworkingModelList: string[] = [];
modelList.filter((model) => {
if (
model.startsWith("gpt-4o") ||
model.startsWith("gpt-4.1") ||
!model.includes("nano")
) {
networkingModelList.push(model);
} else {
nonNetworkingModelList.push(model);
}
});
return [networkingModelList, nonNetworkingModelList];
}
export function filterPollinationsModelList(modelList: string[]) {
const recommendModelList: string[] = [];
const normalModelList: string[] = [];
modelList.filter((model) => {
if (
model.startsWith("openai") ||
model.startsWith("deepseek") ||
model.startsWith("searchgpt")
) {
recommendModelList.push(model);
} else {
normalModelList.push(model);
}
});
return [recommendModelList, normalModelList];
}
export function filterMistralModelList(modelList: string[]) {
const recommendModelList: string[] = [];
const normalModelList: string[] = [];
modelList.filter((model) => {
if (model.includes("large-latest") || model.includes("medium-latest")) {
recommendModelList.push(model);
} else {
normalModelList.push(model);
}
});
return [recommendModelList, normalModelList];
}
export function getCustomModelList(customModelList: string[]) {
const availableModelList: string[] = [];
const disabledModelList: string[] = [];
customModelList.forEach((model) => {
if (model.startsWith("+")) {
availableModelList.push(model.substring(1));
} else if (model.startsWith("-")) {
disabledModelList.push(model.substring(1));
} else {
availableModelList.push(model);
}
});
return { availableModelList, disabledModelList };
}
|