Skip to content

Commit afe12c2

Browse files
committed
chore: update
1 parent 7a8d557 commit afe12c2

12 files changed

Lines changed: 78 additions & 71 deletions

File tree

app/api/[provider]/[...path]/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { handle as moonshotHandler } from "../../moonshot";
1111
import { handle as stabilityHandler } from "../../stability";
1212
import { handle as iflytekHandler } from "../../iflytek";
1313
import { handle as xaiHandler } from "../../xai";
14-
import { handle as glmHandler } from "../../glm";
14+
import { handle as chatglmHandler } from "../../glm";
1515
import { handle as proxyHandler } from "../../proxy";
1616

1717
async function handle(
@@ -42,8 +42,8 @@ async function handle(
4242
return iflytekHandler(req, { params });
4343
case ApiPath.XAI:
4444
return xaiHandler(req, { params });
45-
case ApiPath.GLM:
46-
return glmHandler(req, { params });
45+
case ApiPath.ChatGLM:
46+
return chatglmHandler(req, { params });
4747
case ApiPath.OpenAI:
4848
return openaiHandler(req, { params });
4949
default:

app/api/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ export function auth(req: NextRequest, modelProvider: ModelProvider) {
9595
case ModelProvider.XAI:
9696
systemApiKey = serverConfig.xaiApiKey;
9797
break;
98-
case ModelProvider.GLM:
99-
systemApiKey = serverConfig.glmApiKey;
98+
case ModelProvider.ChatGLM:
99+
systemApiKey = serverConfig.chatglmApiKey;
100100
break;
101101
case ModelProvider.GPT:
102102
default:

app/api/glm.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getServerSideConfig } from "@/app/config/server";
22
import {
3-
GLM_BASE_URL,
3+
CHATGLM_BASE_URL,
44
ApiPath,
55
ModelProvider,
66
ServiceProvider,
@@ -42,9 +42,9 @@ async function request(req: NextRequest) {
4242
const controller = new AbortController();
4343

4444
// alibaba use base url or just remove the path
45-
let path = `${req.nextUrl.pathname}`.replaceAll(ApiPath.GLM, "");
45+
let path = `${req.nextUrl.pathname}`.replaceAll(ApiPath.ChatGLM, "");
4646

47-
let baseUrl = serverConfig.glmUrl || GLM_BASE_URL;
47+
let baseUrl = serverConfig.chatglmUrl || CHATGLM_BASE_URL;
4848

4949
if (!baseUrl.startsWith("http")) {
5050
baseUrl = `https://${baseUrl}`;
@@ -92,7 +92,7 @@ async function request(req: NextRequest) {
9292
isModelAvailableInServer(
9393
serverConfig.customModels,
9494
jsonBody?.model as string,
95-
ServiceProvider.GLM as string,
95+
ServiceProvider.ChatGLM as string,
9696
)
9797
) {
9898
return NextResponse.json(

app/client/api.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { HunyuanApi } from "./platforms/tencent";
2121
import { MoonshotApi } from "./platforms/moonshot";
2222
import { SparkApi } from "./platforms/iflytek";
2323
import { XAIApi } from "./platforms/xai";
24-
import { GLMApi } from "./platforms/glm";
24+
import { ChatGLMApi } from "./platforms/glm";
2525

2626
export const ROLES = ["system", "user", "assistant"] as const;
2727
export type MessageRole = (typeof ROLES)[number];
@@ -157,8 +157,8 @@ export class ClientApi {
157157
case ModelProvider.XAI:
158158
this.llm = new XAIApi();
159159
break;
160-
case ModelProvider.GLM:
161-
this.llm = new GLMApi();
160+
case ModelProvider.ChatGLM:
161+
this.llm = new ChatGLMApi();
162162
break;
163163
default:
164164
this.llm = new ChatGPTApi();
@@ -248,7 +248,7 @@ export function getHeaders(ignoreHeaders: boolean = false) {
248248
const isMoonshot = modelConfig.providerName === ServiceProvider.Moonshot;
249249
const isIflytek = modelConfig.providerName === ServiceProvider.Iflytek;
250250
const isXAI = modelConfig.providerName === ServiceProvider.XAI;
251-
const isGLM = modelConfig.providerName === ServiceProvider.GLM;
251+
const isChatGLM = modelConfig.providerName === ServiceProvider.ChatGLM;
252252
const isEnabledAccessControl = accessStore.enabledAccessControl();
253253
const apiKey = isGoogle
254254
? accessStore.googleApiKey
@@ -264,8 +264,8 @@ export function getHeaders(ignoreHeaders: boolean = false) {
264264
? accessStore.moonshotApiKey
265265
: isXAI
266266
? accessStore.xaiApiKey
267-
: isGLM
268-
? accessStore.glmApiKey
267+
: isChatGLM
268+
? accessStore.chatglmApiKey
269269
: isIflytek
270270
? accessStore.iflytekApiKey && accessStore.iflytekApiSecret
271271
? accessStore.iflytekApiKey + ":" + accessStore.iflytekApiSecret
@@ -281,7 +281,7 @@ export function getHeaders(ignoreHeaders: boolean = false) {
281281
isMoonshot,
282282
isIflytek,
283283
isXAI,
284-
isGLM,
284+
isChatGLM,
285285
apiKey,
286286
isEnabledAccessControl,
287287
};
@@ -346,8 +346,8 @@ export function getClientApi(provider: ServiceProvider): ClientApi {
346346
return new ClientApi(ModelProvider.Iflytek);
347347
case ServiceProvider.XAI:
348348
return new ClientApi(ModelProvider.XAI);
349-
case ServiceProvider.GLM:
350-
return new ClientApi(ModelProvider.GLM);
349+
case ServiceProvider.ChatGLM:
350+
return new ClientApi(ModelProvider.ChatGLM);
351351
default:
352352
return new ClientApi(ModelProvider.GPT);
353353
}

app/client/platforms/glm.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
"use client";
2-
import { ApiPath, GLM_BASE_URL, GLM, REQUEST_TIMEOUT_MS } from "@/app/constant";
2+
import {
3+
ApiPath,
4+
CHATGLM_BASE_URL,
5+
ChatGLM,
6+
REQUEST_TIMEOUT_MS,
7+
} from "@/app/constant";
38
import {
49
useAccessStore,
510
useAppConfig,
@@ -20,7 +25,7 @@ import { getMessageTextContent } from "@/app/utils";
2025
import { RequestPayload } from "./openai";
2126
import { fetch } from "@/app/utils/stream";
2227

23-
export class GLMApi implements LLMApi {
28+
export class ChatGLMApi implements LLMApi {
2429
private disableListModels = true;
2530

2631
path(path: string): string {
@@ -29,19 +34,19 @@ export class GLMApi implements LLMApi {
2934
let baseUrl = "";
3035

3136
if (accessStore.useCustomConfig) {
32-
baseUrl = accessStore.glmUrl;
37+
baseUrl = accessStore.chatglmUrl;
3338
}
3439

3540
if (baseUrl.length === 0) {
3641
const isApp = !!getClientConfig()?.isApp;
37-
const apiPath = ApiPath.GLM;
38-
baseUrl = isApp ? GLM_BASE_URL : apiPath;
42+
const apiPath = ApiPath.ChatGLM;
43+
baseUrl = isApp ? CHATGLM_BASE_URL : apiPath;
3944
}
4045

4146
if (baseUrl.endsWith("/")) {
4247
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
4348
}
44-
if (!baseUrl.startsWith("http") && !baseUrl.startsWith(ApiPath.GLM)) {
49+
if (!baseUrl.startsWith("http") && !baseUrl.startsWith(ApiPath.ChatGLM)) {
4550
baseUrl = "https://" + baseUrl;
4651
}
4752

@@ -91,7 +96,7 @@ export class GLMApi implements LLMApi {
9196
options.onController?.(controller);
9297

9398
try {
94-
const chatPath = this.path(GLM.ChatPath);
99+
const chatPath = this.path(ChatGLM.ChatPath);
95100
const chatPayload = {
96101
method: "POST",
97102
body: JSON.stringify(requestPayload),

app/components/settings.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ import {
7272
Stability,
7373
Iflytek,
7474
SAAS_CHAT_URL,
75-
GLM,
75+
ChatGLM,
7676
} from "../constant";
7777
import { Prompt, SearchService, usePromptStore } from "../store/prompt";
7878
import { ErrorBoundary } from "./error";
@@ -1235,38 +1235,40 @@ export function Settings() {
12351235
</>
12361236
);
12371237

1238-
const glmConfigComponent = accessStore.provider === ServiceProvider.GLM && (
1238+
const chatglmConfigComponent = accessStore.provider ===
1239+
ServiceProvider.ChatGLM && (
12391240
<>
12401241
<ListItem
1241-
title={Locale.Settings.Access.GLM.Endpoint.Title}
1242+
title={Locale.Settings.Access.ChatGLM.Endpoint.Title}
12421243
subTitle={
1243-
Locale.Settings.Access.GLM.Endpoint.SubTitle + GLM.ExampleEndpoint
1244+
Locale.Settings.Access.ChatGLM.Endpoint.SubTitle +
1245+
ChatGLM.ExampleEndpoint
12441246
}
12451247
>
12461248
<input
1247-
aria-label={Locale.Settings.Access.GLM.Endpoint.Title}
1249+
aria-label={Locale.Settings.Access.ChatGLM.Endpoint.Title}
12481250
type="text"
1249-
value={accessStore.glmUrl}
1250-
placeholder={GLM.ExampleEndpoint}
1251+
value={accessStore.chatglmUrl}
1252+
placeholder={ChatGLM.ExampleEndpoint}
12511253
onChange={(e) =>
12521254
accessStore.update(
1253-
(access) => (access.glmUrl = e.currentTarget.value),
1255+
(access) => (access.chatglmUrl = e.currentTarget.value),
12541256
)
12551257
}
12561258
></input>
12571259
</ListItem>
12581260
<ListItem
1259-
title={Locale.Settings.Access.GLM.ApiKey.Title}
1260-
subTitle={Locale.Settings.Access.GLM.ApiKey.SubTitle}
1261+
title={Locale.Settings.Access.ChatGLM.ApiKey.Title}
1262+
subTitle={Locale.Settings.Access.ChatGLM.ApiKey.SubTitle}
12611263
>
12621264
<PasswordInput
1263-
aria-label={Locale.Settings.Access.GLM.ApiKey.Title}
1264-
value={accessStore.glmApiKey}
1265+
aria-label={Locale.Settings.Access.ChatGLM.ApiKey.Title}
1266+
value={accessStore.chatglmApiKey}
12651267
type="text"
1266-
placeholder={Locale.Settings.Access.GLM.ApiKey.Placeholder}
1268+
placeholder={Locale.Settings.Access.ChatGLM.ApiKey.Placeholder}
12671269
onChange={(e) => {
12681270
accessStore.update(
1269-
(access) => (access.glmApiKey = e.currentTarget.value),
1271+
(access) => (access.chatglmApiKey = e.currentTarget.value),
12701272
);
12711273
}}
12721274
/>
@@ -1733,7 +1735,7 @@ export function Settings() {
17331735
{stabilityConfigComponent}
17341736
{lflytekConfigComponent}
17351737
{XAIConfigComponent}
1736-
{glmConfigComponent}
1738+
{chatglmConfigComponent}
17371739
</>
17381740
)}
17391741
</>

app/config/server.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ declare global {
7575
XAI_URL?: string;
7676
XAI_API_KEY?: string;
7777

78-
// glm only
79-
GLM_URL?: string;
80-
GLM_API_KEY?: string;
78+
// chatglm only
79+
CHATGLM_URL?: string;
80+
CHATGLM_API_KEY?: string;
8181

8282
// custom template for preprocessing user input
8383
DEFAULT_INPUT_TEMPLATE?: string;
@@ -155,7 +155,7 @@ export const getServerSideConfig = () => {
155155
const isMoonshot = !!process.env.MOONSHOT_API_KEY;
156156
const isIflytek = !!process.env.IFLYTEK_API_KEY;
157157
const isXAI = !!process.env.XAI_API_KEY;
158-
const isGLM = !!process.env.GLM_API_KEY;
158+
const isChatGLM = !!process.env.CHATGLM_API_KEY;
159159
// const apiKeyEnvVar = process.env.OPENAI_API_KEY ?? "";
160160
// const apiKeys = apiKeyEnvVar.split(",").map((v) => v.trim());
161161
// const randomIndex = Math.floor(Math.random() * apiKeys.length);
@@ -222,9 +222,9 @@ export const getServerSideConfig = () => {
222222
xaiUrl: process.env.XAI_URL,
223223
xaiApiKey: getApiKey(process.env.XAI_API_KEY),
224224

225-
isGLM,
226-
glmUrl: process.env.GLM_URL,
227-
glmApiKey: getApiKey(process.env.GLM_API_KEY),
225+
isChatGLM,
226+
chatglmUrl: process.env.CHATGLM_URL,
227+
chatglmApiKey: getApiKey(process.env.CHATGLM_API_KEY),
228228

229229
cloudflareAccountId: process.env.CLOUDFLARE_ACCOUNT_ID,
230230
cloudflareKVNamespaceId: process.env.CLOUDFLARE_KV_NAMESPACE_ID,

app/constant.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const IFLYTEK_BASE_URL = "https://spark-api-open.xf-yun.com";
3030

3131
export const XAI_BASE_URL = "https://api.x.ai";
3232

33-
export const GLM_BASE_URL = "https://open.bigmodel.cn";
33+
export const CHATGLM_BASE_URL = "https://open.bigmodel.cn";
3434

3535
export const CACHE_URL_PREFIX = "/api/cache";
3636
export const UPLOAD_URL = `${CACHE_URL_PREFIX}/upload`;
@@ -64,7 +64,7 @@ export enum ApiPath {
6464
Stability = "/api/stability",
6565
Artifacts = "/api/artifacts",
6666
XAI = "/api/xai",
67-
GLM = "/api/glm",
67+
ChatGLM = "/api/chatglm",
6868
}
6969

7070
export enum SlotID {
@@ -118,7 +118,7 @@ export enum ServiceProvider {
118118
Stability = "Stability",
119119
Iflytek = "Iflytek",
120120
XAI = "XAI",
121-
GLM = "ChatGLM",
121+
ChatGLM = "ChatGLM",
122122
}
123123

124124
// Google API safety settings, see https://ai.google.dev/gemini-api/docs/safety-settings
@@ -142,7 +142,7 @@ export enum ModelProvider {
142142
Moonshot = "Moonshot",
143143
Iflytek = "Iflytek",
144144
XAI = "XAI",
145-
GLM = "ChatGLM",
145+
ChatGLM = "ChatGLM",
146146
}
147147

148148
export const Stability = {
@@ -230,8 +230,8 @@ export const XAI = {
230230
ChatPath: "v1/chat/completions",
231231
};
232232

233-
export const GLM = {
234-
ExampleEndpoint: GLM_BASE_URL,
233+
export const ChatGLM = {
234+
ExampleEndpoint: CHATGLM_BASE_URL,
235235
ChatPath: "/api/paas/v4/chat/completions",
236236
};
237237

@@ -386,7 +386,7 @@ const iflytekModels = [
386386

387387
const xAIModes = ["grok-beta"];
388388

389-
const glmModels = [
389+
const chatglmModels = [
390390
"glm-4-plus",
391391
"glm-4-0520",
392392
"glm-4",
@@ -520,7 +520,7 @@ export const DEFAULT_MODELS = [
520520
sorted: 11,
521521
},
522522
})),
523-
...glmModels.map((name) => ({
523+
...chatglmModels.map((name) => ({
524524
name,
525525
available: true,
526526
sorted: seq++,

app/locales/cn.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,11 @@ const cn = {
473473
SubTitle: "样例:",
474474
},
475475
},
476-
GLM: {
476+
ChatGLM: {
477477
ApiKey: {
478478
Title: "接口密钥",
479-
SubTitle: "使用自定义 GLM API Key",
480-
Placeholder: "GLM API Key",
479+
SubTitle: "使用自定义 ChatGLM API Key",
480+
Placeholder: "ChatGLM API Key",
481481
},
482482
Endpoint: {
483483
Title: "接口地址",

app/locales/en.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,11 @@ const en: LocaleType = {
457457
SubTitle: "Example: ",
458458
},
459459
},
460-
GLM: {
460+
ChatGLM: {
461461
ApiKey: {
462-
Title: "GLM API Key",
463-
SubTitle: "Use a custom GLM API Key",
464-
Placeholder: "GLM API Key",
462+
Title: "ChatGLM API Key",
463+
SubTitle: "Use a custom ChatGLM API Key",
464+
Placeholder: "ChatGLM API Key",
465465
},
466466
Endpoint: {
467467
Title: "Endpoint Address",

0 commit comments

Comments
 (0)