- github.com/ChatGPTNextWeb/ChatGPT-Next-Web
+ github.com/Yidadaa/ChatGPT-Next-Web
diff --git a/app/components/settings.tsx b/app/components/settings.tsx
index 235e0e187..1c5a1e5ce 100644
--- a/app/components/settings.tsx
+++ b/app/components/settings.tsx
@@ -56,6 +56,7 @@ import {
Baidu,
ByteDance,
Alibaba,
+ Moonshot,
Google,
GoogleSafetySettingsThreshold,
OPENAI_BASE_URL,
@@ -1042,6 +1043,45 @@ export function Settings() {
>
);
+ const moonshotConfigComponent = accessStore.provider ===
+ ServiceProvider.Moonshot && (
+ <>
+
+
+ accessStore.update(
+ (access) => (access.moonshotUrl = e.currentTarget.value),
+ )
+ }
+ >
+
+
+ {
+ accessStore.update(
+ (access) => (access.moonshotApiKey = e.currentTarget.value),
+ );
+ }}
+ />
+
+ >
+ );
+
const stabilityConfigComponent = accessStore.provider ===
ServiceProvider.Stability && (
<>
@@ -1364,6 +1404,7 @@ export function Settings() {
{/* {baiduConfigComponent}*/}
{/* {byteDanceConfigComponent}*/}
{/* {alibabaConfigComponent}*/}
+ {/* {moonshotConfigComponent}*/}
{/* {stabilityConfigComponent}*/}
{/* >*/}
{/* )}*/}
diff --git a/app/config/server.ts b/app/config/server.ts
index 450305251..3e94999e3 100644
--- a/app/config/server.ts
+++ b/app/config/server.ts
@@ -59,6 +59,10 @@ declare global {
ALIBABA_URL?: string;
ALIBABA_API_KEY?: string;
+ // moonshot only
+ MOONSHOT_URL?: string;
+ MOONSHOT_API_KEY?: string;
+
// custom template for preprocessing user input
DEFAULT_INPUT_TEMPLATE?: string;
}
@@ -126,6 +130,7 @@ export const getServerSideConfig = () => {
const isBaidu = !!process.env.BAIDU_API_KEY;
const isBytedance = !!process.env.BYTEDANCE_API_KEY;
const isAlibaba = !!process.env.ALIBABA_API_KEY;
+ const isMoonshot = !!process.env.MOONSHOT_API_KEY;
// const apiKeyEnvVar = process.env.OPENAI_API_KEY ?? "";
// const apiKeys = apiKeyEnvVar.split(",").map((v) => v.trim());
// const randomIndex = Math.floor(Math.random() * apiKeys.length);
@@ -176,6 +181,10 @@ export const getServerSideConfig = () => {
alibabaUrl: process.env.ALIBABA_URL,
alibabaApiKey: getApiKey(process.env.ALIBABA_API_KEY),
+ isMoonshot,
+ moonshotUrl: process.env.MOONSHOT_URL,
+ moonshotApiKey: getApiKey(process.env.MOONSHOT_API_KEY),
+
cloudflareAccountId: process.env.CLOUDFLARE_ACCOUNT_ID,
cloudflareKVNamespaceId: process.env.CLOUDFLARE_KV_NAMESPACE_ID,
cloudflareKVApiKey: getApiKey(process.env.CLOUDFLARE_KV_API_KEY),
diff --git a/app/constant.ts b/app/constant.ts
index 84aaea200..ee8799345 100644
--- a/app/constant.ts
+++ b/app/constant.ts
@@ -1,4 +1,4 @@
-export const OWNER = "ChatGPTNextWeb";
+export const OWNER = "Yidadaa";
export const REPO = "ChatGPT-Next-Web";
export const REPO_URL = `https://github.com/${OWNER}/${REPO}`;
export const ISSUE_URL = `https://github.com/${OWNER}/${REPO}/issues`;
@@ -22,6 +22,7 @@ export const BAIDU_OATUH_URL = `${BAIDU_BASE_URL}/oauth/2.0/token`;
export const BYTEDANCE_BASE_URL = "https://ark.cn-beijing.volces.com";
export const ALIBABA_BASE_URL = "https://dashscope.aliyuncs.com/api/";
+export const MOONSHOT_BASE_URL = "https://api.moonshot.cn";
export const CACHE_URL_PREFIX = "/api/cache";
export const UPLOAD_URL = `${CACHE_URL_PREFIX}/upload`;
@@ -48,6 +49,7 @@ export enum ApiPath {
Baidu = "/api/baidu",
ByteDance = "/api/bytedance",
Alibaba = "/api/alibaba",
+ Moonshot = "/api/moonshot",
Stability = "/api/stability",
Artifacts = "/api/artifacts",
}
@@ -101,6 +103,7 @@ export enum ServiceProvider {
Baidu = "Baidu",
ByteDance = "ByteDance",
Alibaba = "Alibaba",
+ Moonshot = "Moonshot",
Stability = "Stability",
}
@@ -121,6 +124,7 @@ export enum ModelProvider {
Ernie = "Ernie",
Doubao = "Doubao",
Qwen = "Qwen",
+ Moonshot = "Moonshot",
}
export const Stability = {
@@ -187,6 +191,11 @@ export const Alibaba = {
ChatPath: "v1/services/aigc/text-generation/generation",
};
+export const Moonshot = {
+ ExampleEndpoint: MOONSHOT_BASE_URL,
+ ChatPath: "v1/chat/completions",
+};
+
export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
// export const DEFAULT_SYSTEM_TEMPLATE = `
// You are ChatGPT, a large language model trained by {{ServiceProvider}}.
@@ -294,6 +303,8 @@ const alibabaModes = [
"qwen-max-longcontext",
];
+const moonshotModes = ["moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k"];
+
export const DEFAULT_MODELS = [
{
name: "gpt-3.5-turbo",
@@ -385,6 +396,15 @@ export const DEFAULT_MODELS = [
providerType: "openai",
},
},
+ // ...moonshotModes.map((name) => ({
+ // name,
+ // available: true,
+ // provider: {
+ // id: "moonshot",
+ // providerName: "Moonshot",
+ // providerType: "moonshot",
+ // },
+ // })),
] as const;
// export const AZURE_MODELS: string[] = [
diff --git a/app/locales/cn.ts b/app/locales/cn.ts
index fa4578d26..4eae2c32f 100644
--- a/app/locales/cn.ts
+++ b/app/locales/cn.ts
@@ -433,6 +433,17 @@ const cn = {
SubTitle: "样例:",
},
},
+ Moonshot: {
+ ApiKey: {
+ Title: "接口密钥",
+ SubTitle: "使用自定义月之暗面API Key",
+ Placeholder: "Moonshot API Key",
+ },
+ Endpoint: {
+ Title: "接口地址",
+ SubTitle: "样例:",
+ },
+ },
Stability: {
ApiKey: {
Title: "接口密钥",
diff --git a/app/locales/en.ts b/app/locales/en.ts
index 281b2c4b7..a29e5067f 100644
--- a/app/locales/en.ts
+++ b/app/locales/en.ts
@@ -416,6 +416,17 @@ const en: LocaleType = {
SubTitle: "Example: ",
},
},
+ Moonshot: {
+ ApiKey: {
+ Title: "Moonshot API Key",
+ SubTitle: "Use a custom Moonshot API Key",
+ Placeholder: "Moonshot API Key",
+ },
+ Endpoint: {
+ Title: "Endpoint Address",
+ SubTitle: "Example: ",
+ },
+ },
Stability: {
ApiKey: {
Title: "Stability API Key",
diff --git a/app/store/access.ts b/app/store/access.ts
index 7f7cd6588..5dd069a43 100644
--- a/app/store/access.ts
+++ b/app/store/access.ts
@@ -39,6 +39,10 @@ const DEFAULT_ALIBABA_URL = isApp
? DEFAULT_API_HOST + "/api/proxy/alibaba"
: ApiPath.Alibaba;
+const DEFAULT_MOONSHOT_URL = isApp
+ ? DEFAULT_API_HOST + "/api/proxy/moonshot"
+ : ApiPath.Moonshot;
+
const DEFAULT_STABILITY_URL = isApp
? DEFAULT_API_HOST + "/api/proxy/stability"
: ApiPath.Stability;
@@ -83,6 +87,10 @@ const DEFAULT_ACCESS_STATE = {
alibabaUrl: DEFAULT_ALIBABA_URL,
alibabaApiKey: "",
+ // moonshot
+ moonshotUrl: DEFAULT_MOONSHOT_URL,
+ moonshotApiKey: "",
+
//stability
stabilityUrl: DEFAULT_STABILITY_URL,
stabilityApiKey: "",
@@ -138,6 +146,10 @@ export const useAccessStore = createPersistStore(
return ensure(get(), ["alibabaApiKey"]);
},
+ isValidMoonshot() {
+ return ensure(get(), ["moonshotApiKey"]);
+ },
+
isAuthorized() {
this.fetch();
@@ -150,6 +162,7 @@ export const useAccessStore = createPersistStore(
this.isValidBaidu() ||
this.isValidByteDance() ||
this.isValidAlibaba() ||
+ this.isValidMoonshot() ||
!this.enabledAccessControl() ||
(this.enabledAccessControl() && ensure(get(), ["accessCode"]))
);
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index feef57d16..86faf4c3c 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -9,7 +9,7 @@
},
"package": {
"productName": "NextChat",
- "version": "2.14.0"
+ "version": "2.13.1"
},
"tauri": {
"allowlist": {