Skip to content

Commit

Permalink
feat: swap name and displayName for bytedance in custom models
Browse files Browse the repository at this point in the history
  • Loading branch information
Dogtiti committed Jul 6, 2024
1 parent 2ec8b7a commit 1caa61f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions app/config/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 8 additions & 1 deletion app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand Down
12 changes: 10 additions & 2 deletions app/utils/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand 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;
}
Expand Down

0 comments on commit 1caa61f

Please sign in to comment.