chore: update
This commit is contained in:
parent
7a8d557ea3
commit
afe12c212e
|
@ -11,7 +11,7 @@ import { handle as moonshotHandler } from "../../moonshot";
|
||||||
import { handle as stabilityHandler } from "../../stability";
|
import { handle as stabilityHandler } from "../../stability";
|
||||||
import { handle as iflytekHandler } from "../../iflytek";
|
import { handle as iflytekHandler } from "../../iflytek";
|
||||||
import { handle as xaiHandler } from "../../xai";
|
import { handle as xaiHandler } from "../../xai";
|
||||||
import { handle as glmHandler } from "../../glm";
|
import { handle as chatglmHandler } from "../../glm";
|
||||||
import { handle as proxyHandler } from "../../proxy";
|
import { handle as proxyHandler } from "../../proxy";
|
||||||
|
|
||||||
async function handle(
|
async function handle(
|
||||||
|
@ -42,8 +42,8 @@ async function handle(
|
||||||
return iflytekHandler(req, { params });
|
return iflytekHandler(req, { params });
|
||||||
case ApiPath.XAI:
|
case ApiPath.XAI:
|
||||||
return xaiHandler(req, { params });
|
return xaiHandler(req, { params });
|
||||||
case ApiPath.GLM:
|
case ApiPath.ChatGLM:
|
||||||
return glmHandler(req, { params });
|
return chatglmHandler(req, { params });
|
||||||
case ApiPath.OpenAI:
|
case ApiPath.OpenAI:
|
||||||
return openaiHandler(req, { params });
|
return openaiHandler(req, { params });
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -95,8 +95,8 @@ export function auth(req: NextRequest, modelProvider: ModelProvider) {
|
||||||
case ModelProvider.XAI:
|
case ModelProvider.XAI:
|
||||||
systemApiKey = serverConfig.xaiApiKey;
|
systemApiKey = serverConfig.xaiApiKey;
|
||||||
break;
|
break;
|
||||||
case ModelProvider.GLM:
|
case ModelProvider.ChatGLM:
|
||||||
systemApiKey = serverConfig.glmApiKey;
|
systemApiKey = serverConfig.chatglmApiKey;
|
||||||
break;
|
break;
|
||||||
case ModelProvider.GPT:
|
case ModelProvider.GPT:
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { getServerSideConfig } from "@/app/config/server";
|
import { getServerSideConfig } from "@/app/config/server";
|
||||||
import {
|
import {
|
||||||
GLM_BASE_URL,
|
CHATGLM_BASE_URL,
|
||||||
ApiPath,
|
ApiPath,
|
||||||
ModelProvider,
|
ModelProvider,
|
||||||
ServiceProvider,
|
ServiceProvider,
|
||||||
|
@ -42,9 +42,9 @@ async function request(req: NextRequest) {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
|
|
||||||
// alibaba use base url or just remove the path
|
// alibaba use base url or just remove the path
|
||||||
let path = `${req.nextUrl.pathname}`.replaceAll(ApiPath.GLM, "");
|
let path = `${req.nextUrl.pathname}`.replaceAll(ApiPath.ChatGLM, "");
|
||||||
|
|
||||||
let baseUrl = serverConfig.glmUrl || GLM_BASE_URL;
|
let baseUrl = serverConfig.chatglmUrl || CHATGLM_BASE_URL;
|
||||||
|
|
||||||
if (!baseUrl.startsWith("http")) {
|
if (!baseUrl.startsWith("http")) {
|
||||||
baseUrl = `https://${baseUrl}`;
|
baseUrl = `https://${baseUrl}`;
|
||||||
|
@ -92,7 +92,7 @@ async function request(req: NextRequest) {
|
||||||
isModelAvailableInServer(
|
isModelAvailableInServer(
|
||||||
serverConfig.customModels,
|
serverConfig.customModels,
|
||||||
jsonBody?.model as string,
|
jsonBody?.model as string,
|
||||||
ServiceProvider.GLM as string,
|
ServiceProvider.ChatGLM as string,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { HunyuanApi } from "./platforms/tencent";
|
||||||
import { MoonshotApi } from "./platforms/moonshot";
|
import { MoonshotApi } from "./platforms/moonshot";
|
||||||
import { SparkApi } from "./platforms/iflytek";
|
import { SparkApi } from "./platforms/iflytek";
|
||||||
import { XAIApi } from "./platforms/xai";
|
import { XAIApi } from "./platforms/xai";
|
||||||
import { GLMApi } from "./platforms/glm";
|
import { ChatGLMApi } from "./platforms/glm";
|
||||||
|
|
||||||
export const ROLES = ["system", "user", "assistant"] as const;
|
export const ROLES = ["system", "user", "assistant"] as const;
|
||||||
export type MessageRole = (typeof ROLES)[number];
|
export type MessageRole = (typeof ROLES)[number];
|
||||||
|
@ -157,8 +157,8 @@ export class ClientApi {
|
||||||
case ModelProvider.XAI:
|
case ModelProvider.XAI:
|
||||||
this.llm = new XAIApi();
|
this.llm = new XAIApi();
|
||||||
break;
|
break;
|
||||||
case ModelProvider.GLM:
|
case ModelProvider.ChatGLM:
|
||||||
this.llm = new GLMApi();
|
this.llm = new ChatGLMApi();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.llm = new ChatGPTApi();
|
this.llm = new ChatGPTApi();
|
||||||
|
@ -248,7 +248,7 @@ export function getHeaders(ignoreHeaders: boolean = false) {
|
||||||
const isMoonshot = modelConfig.providerName === ServiceProvider.Moonshot;
|
const isMoonshot = modelConfig.providerName === ServiceProvider.Moonshot;
|
||||||
const isIflytek = modelConfig.providerName === ServiceProvider.Iflytek;
|
const isIflytek = modelConfig.providerName === ServiceProvider.Iflytek;
|
||||||
const isXAI = modelConfig.providerName === ServiceProvider.XAI;
|
const isXAI = modelConfig.providerName === ServiceProvider.XAI;
|
||||||
const isGLM = modelConfig.providerName === ServiceProvider.GLM;
|
const isChatGLM = modelConfig.providerName === ServiceProvider.ChatGLM;
|
||||||
const isEnabledAccessControl = accessStore.enabledAccessControl();
|
const isEnabledAccessControl = accessStore.enabledAccessControl();
|
||||||
const apiKey = isGoogle
|
const apiKey = isGoogle
|
||||||
? accessStore.googleApiKey
|
? accessStore.googleApiKey
|
||||||
|
@ -264,8 +264,8 @@ export function getHeaders(ignoreHeaders: boolean = false) {
|
||||||
? accessStore.moonshotApiKey
|
? accessStore.moonshotApiKey
|
||||||
: isXAI
|
: isXAI
|
||||||
? accessStore.xaiApiKey
|
? accessStore.xaiApiKey
|
||||||
: isGLM
|
: isChatGLM
|
||||||
? accessStore.glmApiKey
|
? accessStore.chatglmApiKey
|
||||||
: isIflytek
|
: isIflytek
|
||||||
? accessStore.iflytekApiKey && accessStore.iflytekApiSecret
|
? accessStore.iflytekApiKey && accessStore.iflytekApiSecret
|
||||||
? accessStore.iflytekApiKey + ":" + accessStore.iflytekApiSecret
|
? accessStore.iflytekApiKey + ":" + accessStore.iflytekApiSecret
|
||||||
|
@ -281,7 +281,7 @@ export function getHeaders(ignoreHeaders: boolean = false) {
|
||||||
isMoonshot,
|
isMoonshot,
|
||||||
isIflytek,
|
isIflytek,
|
||||||
isXAI,
|
isXAI,
|
||||||
isGLM,
|
isChatGLM,
|
||||||
apiKey,
|
apiKey,
|
||||||
isEnabledAccessControl,
|
isEnabledAccessControl,
|
||||||
};
|
};
|
||||||
|
@ -346,8 +346,8 @@ export function getClientApi(provider: ServiceProvider): ClientApi {
|
||||||
return new ClientApi(ModelProvider.Iflytek);
|
return new ClientApi(ModelProvider.Iflytek);
|
||||||
case ServiceProvider.XAI:
|
case ServiceProvider.XAI:
|
||||||
return new ClientApi(ModelProvider.XAI);
|
return new ClientApi(ModelProvider.XAI);
|
||||||
case ServiceProvider.GLM:
|
case ServiceProvider.ChatGLM:
|
||||||
return new ClientApi(ModelProvider.GLM);
|
return new ClientApi(ModelProvider.ChatGLM);
|
||||||
default:
|
default:
|
||||||
return new ClientApi(ModelProvider.GPT);
|
return new ClientApi(ModelProvider.GPT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
"use client";
|
"use client";
|
||||||
import { ApiPath, GLM_BASE_URL, GLM, REQUEST_TIMEOUT_MS } from "@/app/constant";
|
import {
|
||||||
|
ApiPath,
|
||||||
|
CHATGLM_BASE_URL,
|
||||||
|
ChatGLM,
|
||||||
|
REQUEST_TIMEOUT_MS,
|
||||||
|
} from "@/app/constant";
|
||||||
import {
|
import {
|
||||||
useAccessStore,
|
useAccessStore,
|
||||||
useAppConfig,
|
useAppConfig,
|
||||||
|
@ -20,7 +25,7 @@ import { getMessageTextContent } from "@/app/utils";
|
||||||
import { RequestPayload } from "./openai";
|
import { RequestPayload } from "./openai";
|
||||||
import { fetch } from "@/app/utils/stream";
|
import { fetch } from "@/app/utils/stream";
|
||||||
|
|
||||||
export class GLMApi implements LLMApi {
|
export class ChatGLMApi implements LLMApi {
|
||||||
private disableListModels = true;
|
private disableListModels = true;
|
||||||
|
|
||||||
path(path: string): string {
|
path(path: string): string {
|
||||||
|
@ -29,19 +34,19 @@ export class GLMApi implements LLMApi {
|
||||||
let baseUrl = "";
|
let baseUrl = "";
|
||||||
|
|
||||||
if (accessStore.useCustomConfig) {
|
if (accessStore.useCustomConfig) {
|
||||||
baseUrl = accessStore.glmUrl;
|
baseUrl = accessStore.chatglmUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseUrl.length === 0) {
|
if (baseUrl.length === 0) {
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
const apiPath = ApiPath.GLM;
|
const apiPath = ApiPath.ChatGLM;
|
||||||
baseUrl = isApp ? GLM_BASE_URL : apiPath;
|
baseUrl = isApp ? CHATGLM_BASE_URL : apiPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseUrl.endsWith("/")) {
|
if (baseUrl.endsWith("/")) {
|
||||||
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
|
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
|
||||||
}
|
}
|
||||||
if (!baseUrl.startsWith("http") && !baseUrl.startsWith(ApiPath.GLM)) {
|
if (!baseUrl.startsWith("http") && !baseUrl.startsWith(ApiPath.ChatGLM)) {
|
||||||
baseUrl = "https://" + baseUrl;
|
baseUrl = "https://" + baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +96,7 @@ export class GLMApi implements LLMApi {
|
||||||
options.onController?.(controller);
|
options.onController?.(controller);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const chatPath = this.path(GLM.ChatPath);
|
const chatPath = this.path(ChatGLM.ChatPath);
|
||||||
const chatPayload = {
|
const chatPayload = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(requestPayload),
|
body: JSON.stringify(requestPayload),
|
||||||
|
|
|
@ -72,7 +72,7 @@ import {
|
||||||
Stability,
|
Stability,
|
||||||
Iflytek,
|
Iflytek,
|
||||||
SAAS_CHAT_URL,
|
SAAS_CHAT_URL,
|
||||||
GLM,
|
ChatGLM,
|
||||||
} from "../constant";
|
} from "../constant";
|
||||||
import { Prompt, SearchService, usePromptStore } from "../store/prompt";
|
import { Prompt, SearchService, usePromptStore } from "../store/prompt";
|
||||||
import { ErrorBoundary } from "./error";
|
import { ErrorBoundary } from "./error";
|
||||||
|
@ -1235,38 +1235,40 @@ export function Settings() {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
const glmConfigComponent = accessStore.provider === ServiceProvider.GLM && (
|
const chatglmConfigComponent = accessStore.provider ===
|
||||||
|
ServiceProvider.ChatGLM && (
|
||||||
<>
|
<>
|
||||||
<ListItem
|
<ListItem
|
||||||
title={Locale.Settings.Access.GLM.Endpoint.Title}
|
title={Locale.Settings.Access.ChatGLM.Endpoint.Title}
|
||||||
subTitle={
|
subTitle={
|
||||||
Locale.Settings.Access.GLM.Endpoint.SubTitle + GLM.ExampleEndpoint
|
Locale.Settings.Access.ChatGLM.Endpoint.SubTitle +
|
||||||
|
ChatGLM.ExampleEndpoint
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
aria-label={Locale.Settings.Access.GLM.Endpoint.Title}
|
aria-label={Locale.Settings.Access.ChatGLM.Endpoint.Title}
|
||||||
type="text"
|
type="text"
|
||||||
value={accessStore.glmUrl}
|
value={accessStore.chatglmUrl}
|
||||||
placeholder={GLM.ExampleEndpoint}
|
placeholder={ChatGLM.ExampleEndpoint}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
accessStore.update(
|
accessStore.update(
|
||||||
(access) => (access.glmUrl = e.currentTarget.value),
|
(access) => (access.chatglmUrl = e.currentTarget.value),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
></input>
|
></input>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<ListItem
|
<ListItem
|
||||||
title={Locale.Settings.Access.GLM.ApiKey.Title}
|
title={Locale.Settings.Access.ChatGLM.ApiKey.Title}
|
||||||
subTitle={Locale.Settings.Access.GLM.ApiKey.SubTitle}
|
subTitle={Locale.Settings.Access.ChatGLM.ApiKey.SubTitle}
|
||||||
>
|
>
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
aria-label={Locale.Settings.Access.GLM.ApiKey.Title}
|
aria-label={Locale.Settings.Access.ChatGLM.ApiKey.Title}
|
||||||
value={accessStore.glmApiKey}
|
value={accessStore.chatglmApiKey}
|
||||||
type="text"
|
type="text"
|
||||||
placeholder={Locale.Settings.Access.GLM.ApiKey.Placeholder}
|
placeholder={Locale.Settings.Access.ChatGLM.ApiKey.Placeholder}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
accessStore.update(
|
accessStore.update(
|
||||||
(access) => (access.glmApiKey = e.currentTarget.value),
|
(access) => (access.chatglmApiKey = e.currentTarget.value),
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -1733,7 +1735,7 @@ export function Settings() {
|
||||||
{stabilityConfigComponent}
|
{stabilityConfigComponent}
|
||||||
{lflytekConfigComponent}
|
{lflytekConfigComponent}
|
||||||
{XAIConfigComponent}
|
{XAIConfigComponent}
|
||||||
{glmConfigComponent}
|
{chatglmConfigComponent}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -75,9 +75,9 @@ declare global {
|
||||||
XAI_URL?: string;
|
XAI_URL?: string;
|
||||||
XAI_API_KEY?: string;
|
XAI_API_KEY?: string;
|
||||||
|
|
||||||
// glm only
|
// chatglm only
|
||||||
GLM_URL?: string;
|
CHATGLM_URL?: string;
|
||||||
GLM_API_KEY?: string;
|
CHATGLM_API_KEY?: string;
|
||||||
|
|
||||||
// custom template for preprocessing user input
|
// custom template for preprocessing user input
|
||||||
DEFAULT_INPUT_TEMPLATE?: string;
|
DEFAULT_INPUT_TEMPLATE?: string;
|
||||||
|
@ -155,7 +155,7 @@ export const getServerSideConfig = () => {
|
||||||
const isMoonshot = !!process.env.MOONSHOT_API_KEY;
|
const isMoonshot = !!process.env.MOONSHOT_API_KEY;
|
||||||
const isIflytek = !!process.env.IFLYTEK_API_KEY;
|
const isIflytek = !!process.env.IFLYTEK_API_KEY;
|
||||||
const isXAI = !!process.env.XAI_API_KEY;
|
const isXAI = !!process.env.XAI_API_KEY;
|
||||||
const isGLM = !!process.env.GLM_API_KEY;
|
const isChatGLM = !!process.env.CHATGLM_API_KEY;
|
||||||
// const apiKeyEnvVar = process.env.OPENAI_API_KEY ?? "";
|
// const apiKeyEnvVar = process.env.OPENAI_API_KEY ?? "";
|
||||||
// const apiKeys = apiKeyEnvVar.split(",").map((v) => v.trim());
|
// const apiKeys = apiKeyEnvVar.split(",").map((v) => v.trim());
|
||||||
// const randomIndex = Math.floor(Math.random() * apiKeys.length);
|
// const randomIndex = Math.floor(Math.random() * apiKeys.length);
|
||||||
|
@ -222,9 +222,9 @@ export const getServerSideConfig = () => {
|
||||||
xaiUrl: process.env.XAI_URL,
|
xaiUrl: process.env.XAI_URL,
|
||||||
xaiApiKey: getApiKey(process.env.XAI_API_KEY),
|
xaiApiKey: getApiKey(process.env.XAI_API_KEY),
|
||||||
|
|
||||||
isGLM,
|
isChatGLM,
|
||||||
glmUrl: process.env.GLM_URL,
|
chatglmUrl: process.env.CHATGLM_URL,
|
||||||
glmApiKey: getApiKey(process.env.GLM_API_KEY),
|
chatglmApiKey: getApiKey(process.env.CHATGLM_API_KEY),
|
||||||
|
|
||||||
cloudflareAccountId: process.env.CLOUDFLARE_ACCOUNT_ID,
|
cloudflareAccountId: process.env.CLOUDFLARE_ACCOUNT_ID,
|
||||||
cloudflareKVNamespaceId: process.env.CLOUDFLARE_KV_NAMESPACE_ID,
|
cloudflareKVNamespaceId: process.env.CLOUDFLARE_KV_NAMESPACE_ID,
|
||||||
|
|
|
@ -30,7 +30,7 @@ export const IFLYTEK_BASE_URL = "https://spark-api-open.xf-yun.com";
|
||||||
|
|
||||||
export const XAI_BASE_URL = "https://api.x.ai";
|
export const XAI_BASE_URL = "https://api.x.ai";
|
||||||
|
|
||||||
export const GLM_BASE_URL = "https://open.bigmodel.cn";
|
export const CHATGLM_BASE_URL = "https://open.bigmodel.cn";
|
||||||
|
|
||||||
export const CACHE_URL_PREFIX = "/api/cache";
|
export const CACHE_URL_PREFIX = "/api/cache";
|
||||||
export const UPLOAD_URL = `${CACHE_URL_PREFIX}/upload`;
|
export const UPLOAD_URL = `${CACHE_URL_PREFIX}/upload`;
|
||||||
|
@ -64,7 +64,7 @@ export enum ApiPath {
|
||||||
Stability = "/api/stability",
|
Stability = "/api/stability",
|
||||||
Artifacts = "/api/artifacts",
|
Artifacts = "/api/artifacts",
|
||||||
XAI = "/api/xai",
|
XAI = "/api/xai",
|
||||||
GLM = "/api/glm",
|
ChatGLM = "/api/chatglm",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SlotID {
|
export enum SlotID {
|
||||||
|
@ -118,7 +118,7 @@ export enum ServiceProvider {
|
||||||
Stability = "Stability",
|
Stability = "Stability",
|
||||||
Iflytek = "Iflytek",
|
Iflytek = "Iflytek",
|
||||||
XAI = "XAI",
|
XAI = "XAI",
|
||||||
GLM = "ChatGLM",
|
ChatGLM = "ChatGLM",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Google API safety settings, see https://ai.google.dev/gemini-api/docs/safety-settings
|
// Google API safety settings, see https://ai.google.dev/gemini-api/docs/safety-settings
|
||||||
|
@ -142,7 +142,7 @@ export enum ModelProvider {
|
||||||
Moonshot = "Moonshot",
|
Moonshot = "Moonshot",
|
||||||
Iflytek = "Iflytek",
|
Iflytek = "Iflytek",
|
||||||
XAI = "XAI",
|
XAI = "XAI",
|
||||||
GLM = "ChatGLM",
|
ChatGLM = "ChatGLM",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Stability = {
|
export const Stability = {
|
||||||
|
@ -230,8 +230,8 @@ export const XAI = {
|
||||||
ChatPath: "v1/chat/completions",
|
ChatPath: "v1/chat/completions",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GLM = {
|
export const ChatGLM = {
|
||||||
ExampleEndpoint: GLM_BASE_URL,
|
ExampleEndpoint: CHATGLM_BASE_URL,
|
||||||
ChatPath: "/api/paas/v4/chat/completions",
|
ChatPath: "/api/paas/v4/chat/completions",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ const iflytekModels = [
|
||||||
|
|
||||||
const xAIModes = ["grok-beta"];
|
const xAIModes = ["grok-beta"];
|
||||||
|
|
||||||
const glmModels = [
|
const chatglmModels = [
|
||||||
"glm-4-plus",
|
"glm-4-plus",
|
||||||
"glm-4-0520",
|
"glm-4-0520",
|
||||||
"glm-4",
|
"glm-4",
|
||||||
|
@ -520,7 +520,7 @@ export const DEFAULT_MODELS = [
|
||||||
sorted: 11,
|
sorted: 11,
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
...glmModels.map((name) => ({
|
...chatglmModels.map((name) => ({
|
||||||
name,
|
name,
|
||||||
available: true,
|
available: true,
|
||||||
sorted: seq++,
|
sorted: seq++,
|
||||||
|
|
|
@ -473,11 +473,11 @@ const cn = {
|
||||||
SubTitle: "样例:",
|
SubTitle: "样例:",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
GLM: {
|
ChatGLM: {
|
||||||
ApiKey: {
|
ApiKey: {
|
||||||
Title: "接口密钥",
|
Title: "接口密钥",
|
||||||
SubTitle: "使用自定义 GLM API Key",
|
SubTitle: "使用自定义 ChatGLM API Key",
|
||||||
Placeholder: "GLM API Key",
|
Placeholder: "ChatGLM API Key",
|
||||||
},
|
},
|
||||||
Endpoint: {
|
Endpoint: {
|
||||||
Title: "接口地址",
|
Title: "接口地址",
|
||||||
|
|
|
@ -457,11 +457,11 @@ const en: LocaleType = {
|
||||||
SubTitle: "Example: ",
|
SubTitle: "Example: ",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
GLM: {
|
ChatGLM: {
|
||||||
ApiKey: {
|
ApiKey: {
|
||||||
Title: "GLM API Key",
|
Title: "ChatGLM API Key",
|
||||||
SubTitle: "Use a custom GLM API Key",
|
SubTitle: "Use a custom ChatGLM API Key",
|
||||||
Placeholder: "GLM API Key",
|
Placeholder: "ChatGLM API Key",
|
||||||
},
|
},
|
||||||
Endpoint: {
|
Endpoint: {
|
||||||
Title: "Endpoint Address",
|
Title: "Endpoint Address",
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
STABILITY_BASE_URL,
|
STABILITY_BASE_URL,
|
||||||
IFLYTEK_BASE_URL,
|
IFLYTEK_BASE_URL,
|
||||||
XAI_BASE_URL,
|
XAI_BASE_URL,
|
||||||
GLM_BASE_URL,
|
CHATGLM_BASE_URL,
|
||||||
} from "../constant";
|
} from "../constant";
|
||||||
import { getHeaders } from "../client/api";
|
import { getHeaders } from "../client/api";
|
||||||
import { getClientConfig } from "../config/client";
|
import { getClientConfig } from "../config/client";
|
||||||
|
@ -48,7 +48,7 @@ const DEFAULT_IFLYTEK_URL = isApp ? IFLYTEK_BASE_URL : ApiPath.Iflytek;
|
||||||
|
|
||||||
const DEFAULT_XAI_URL = isApp ? XAI_BASE_URL : ApiPath.XAI;
|
const DEFAULT_XAI_URL = isApp ? XAI_BASE_URL : ApiPath.XAI;
|
||||||
|
|
||||||
const DEFAULT_GLM_URL = isApp ? GLM_BASE_URL : ApiPath.GLM;
|
const DEFAULT_CHATGLM_URL = isApp ? CHATGLM_BASE_URL : ApiPath.ChatGLM;
|
||||||
|
|
||||||
const DEFAULT_ACCESS_STATE = {
|
const DEFAULT_ACCESS_STATE = {
|
||||||
accessCode: "",
|
accessCode: "",
|
||||||
|
@ -111,9 +111,9 @@ const DEFAULT_ACCESS_STATE = {
|
||||||
xaiUrl: DEFAULT_XAI_URL,
|
xaiUrl: DEFAULT_XAI_URL,
|
||||||
xaiApiKey: "",
|
xaiApiKey: "",
|
||||||
|
|
||||||
// glm
|
// chatglm
|
||||||
glmUrl: DEFAULT_GLM_URL,
|
chatglmUrl: DEFAULT_CHATGLM_URL,
|
||||||
glmApiKey: "",
|
chatglmApiKey: "",
|
||||||
|
|
||||||
// server config
|
// server config
|
||||||
needCode: true,
|
needCode: true,
|
||||||
|
@ -187,8 +187,8 @@ export const useAccessStore = createPersistStore(
|
||||||
return ensure(get(), ["xaiApiKey"]);
|
return ensure(get(), ["xaiApiKey"]);
|
||||||
},
|
},
|
||||||
|
|
||||||
isValidGLM() {
|
isValidChatGLM() {
|
||||||
return ensure(get(), ["glmApiKey"]);
|
return ensure(get(), ["chatglmApiKey"]);
|
||||||
},
|
},
|
||||||
|
|
||||||
isAuthorized() {
|
isAuthorized() {
|
||||||
|
@ -207,7 +207,7 @@ export const useAccessStore = createPersistStore(
|
||||||
this.isValidMoonshot() ||
|
this.isValidMoonshot() ||
|
||||||
this.isValidIflytek() ||
|
this.isValidIflytek() ||
|
||||||
this.isValidXAI() ||
|
this.isValidXAI() ||
|
||||||
this.isValidGLM() ||
|
this.isValidChatGLM() ||
|
||||||
!this.enabledAccessControl() ||
|
!this.enabledAccessControl() ||
|
||||||
(this.enabledAccessControl() && ensure(get(), ["accessCode"]))
|
(this.enabledAccessControl() && ensure(get(), ["accessCode"]))
|
||||||
);
|
);
|
||||||
|
|
|
@ -279,7 +279,7 @@ export function showPlugins(provider: ServiceProvider, model: string) {
|
||||||
provider == ServiceProvider.OpenAI ||
|
provider == ServiceProvider.OpenAI ||
|
||||||
provider == ServiceProvider.Azure ||
|
provider == ServiceProvider.Azure ||
|
||||||
provider == ServiceProvider.Moonshot ||
|
provider == ServiceProvider.Moonshot ||
|
||||||
provider == ServiceProvider.GLM
|
provider == ServiceProvider.ChatGLM
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue