feat: swap name and displayName for bytedance in custom models

This commit is contained in:
Dogtiti 2024-07-06 22:59:20 +08:00
parent 2ec8b7a804
commit 1caa61f4c0
4 changed files with 23 additions and 6 deletions

View File

@ -225,6 +225,8 @@ export function getClientApi(provider: ServiceProvider): ClientApi {
return new ClientApi(ModelProvider.GeminiPro);
case ServiceProvider.Anthropic:
return new ClientApi(ModelProvider.Claude);
case ServiceProvider.ByteDance:
return new ClientApi(ModelProvider.Doubao);
default:
return new ClientApi(ModelProvider.GPT);
}

View File

@ -32,13 +32,13 @@ declare global {
GOOGLE_API_KEY?: string;
GOOGLE_URL?: string;
// google tag manager
GTM_ID?: string;
// bytedance only
BYTEDANCE_URL?: string;
BYTEDANCE_API_KEY?: string;
// google tag manager
GTM_ID?: string;
// custom template for preprocessing user input
DEFAULT_INPUT_TEMPLATE?: string;
}

View File

@ -183,7 +183,14 @@ const anthropicModels = [
"claude-3-5-sonnet-20240620",
];
const bytedanceModels = ["ep-20240520082937-424bw=Doubao-lite-4k"];
const bytedanceModels = [
"Doubao-lite-4k",
"Doubao-lite-32k",
"Doubao-lite-128k",
"Doubao-pro-4k",
"Doubao-pro-32k",
"Doubao-pro-128k",
];
export const DEFAULT_MODELS = [
...openaiModels.map((name) => ({

View File

@ -39,7 +39,7 @@ export function collectModelTable(
const available = !m.startsWith("-");
const nameConfig =
m.startsWith("+") || m.startsWith("-") ? m.slice(1) : m;
const [name, displayName] = nameConfig.split("=");
let [name, displayName] = nameConfig.split("=");
// enable or disable all models
if (name === "all") {
@ -50,9 +50,17 @@ export function collectModelTable(
// 1. find model by name(), and set available value
let count = 0;
for (const fullName in modelTable) {
if (fullName.split("@").shift() == name) {
const [modelName, providerName] = fullName.split("@");
if (modelName === name) {
count += 1;
modelTable[fullName]["available"] = available;
// swap name and displayName for bytedance
if (providerName === "bytedance") {
const tempName = name;
name = displayName;
displayName = tempName;
modelTable[fullName]["name"] = name;
}
if (displayName) {
modelTable[fullName]["displayName"] = displayName;
}