constant.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. export const OWNER = "ChatGPTNextWeb";
  2. export const REPO = "ChatGPT-Next-Web";
  3. export const REPO_URL = `https://github.com/${OWNER}/${REPO}`;
  4. export const PLUGINS_REPO_URL = `https://github.com/${OWNER}/NextChat-Awesome-Plugins`;
  5. export const ISSUE_URL = `https://github.com/${OWNER}/${REPO}/issues`;
  6. export const UPDATE_URL = `${REPO_URL}#keep-updated`;
  7. export const RELEASE_URL = `${REPO_URL}/releases`;
  8. export const FETCH_COMMIT_URL = `https://api.github.com/repos/${OWNER}/${REPO}/commits?per_page=1`;
  9. export const FETCH_TAG_URL = `https://api.github.com/repos/${OWNER}/${REPO}/tags?per_page=1`;
  10. export const RUNTIME_CONFIG_DOM = "danger-runtime-config";
  11. export const STABILITY_BASE_URL = "https://api.stability.ai";
  12. export const OPENAI_BASE_URL = "https://api.openai.com";
  13. export const ANTHROPIC_BASE_URL = "https://api.anthropic.com";
  14. export const GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/";
  15. export const BAIDU_BASE_URL = "https://aip.baidubce.com";
  16. export const BAIDU_OATUH_URL = `${BAIDU_BASE_URL}/oauth/2.0/token`;
  17. export const BYTEDANCE_BASE_URL = "https://ark.cn-beijing.volces.com";
  18. export const ALIBABA_BASE_URL = "https://dashscope.aliyuncs.com/api/";
  19. export const TENCENT_BASE_URL = "https://hunyuan.tencentcloudapi.com";
  20. export const MOONSHOT_BASE_URL = "https://api.moonshot.cn";
  21. export const IFLYTEK_BASE_URL = "https://spark-api-open.xf-yun.com";
  22. export const XAI_BASE_URL = "https://api.x.ai";
  23. export const CACHE_URL_PREFIX = "/api/cache";
  24. export const UPLOAD_URL = `${CACHE_URL_PREFIX}/upload`;
  25. export enum Path {
  26. Home = "/",
  27. Chat = "/chat",
  28. Settings = "/settings",
  29. NewChat = "/new-chat",
  30. Masks = "/masks",
  31. Plugins = "/plugins",
  32. Auth = "/auth",
  33. Sd = "/sd",
  34. SdNew = "/sd-new",
  35. Artifacts = "/artifacts",
  36. SearchChat = "/search-chat",
  37. }
  38. export enum ApiPath {
  39. Cors = "",
  40. Azure = "/api/azure",
  41. OpenAI = "/api/openai",
  42. Anthropic = "/api/anthropic",
  43. Google = "/api/google",
  44. Baidu = "/api/baidu",
  45. ByteDance = "/api/bytedance",
  46. Alibaba = "/api/alibaba",
  47. Tencent = "/api/tencent",
  48. Moonshot = "/api/moonshot",
  49. Iflytek = "/api/iflytek",
  50. Stability = "/api/stability",
  51. Artifacts = "/api/artifacts",
  52. XAI = "/api/xai",
  53. }
  54. export enum SlotID {
  55. AppBody = "app-body",
  56. CustomModel = "custom-model",
  57. }
  58. export enum FileName {
  59. Masks = "masks.json",
  60. Prompts = "prompts.json",
  61. }
  62. export enum StoreKey {
  63. Chat = "chat-next-web-store",
  64. Plugin = "chat-next-web-plugin",
  65. Access = "access-control",
  66. Config = "app-config",
  67. Mask = "mask-store",
  68. Prompt = "prompt-store",
  69. Update = "chat-update",
  70. Sync = "sync",
  71. SdList = "sd-list",
  72. }
  73. export const DEFAULT_SIDEBAR_WIDTH = 300;
  74. export const MAX_SIDEBAR_WIDTH = 500;
  75. export const MIN_SIDEBAR_WIDTH = 230;
  76. export const NARROW_SIDEBAR_WIDTH = 100;
  77. export const ACCESS_CODE_PREFIX = "nk-";
  78. export const LAST_INPUT_KEY = "last-input";
  79. export const UNFINISHED_INPUT = (id: string) => "unfinished-input-" + id;
  80. export const STORAGE_KEY = "chatgpt-next-web";
  81. export const REQUEST_TIMEOUT_MS = 60000;
  82. export const EXPORT_MESSAGE_CLASS_NAME = "export-markdown";
  83. export enum ServiceProvider {
  84. OpenAI = "OpenAI",
  85. Azure = "Azure",
  86. Google = "Google",
  87. Anthropic = "Anthropic",
  88. Baidu = "Baidu",
  89. ByteDance = "ByteDance",
  90. Alibaba = "Alibaba",
  91. Tencent = "Tencent",
  92. Moonshot = "Moonshot",
  93. Stability = "Stability",
  94. Iflytek = "Iflytek",
  95. XAI = "XAI",
  96. }
  97. // Google API safety settings, see https://ai.google.dev/gemini-api/docs/safety-settings
  98. // BLOCK_NONE will not block any content, and BLOCK_ONLY_HIGH will block only high-risk content.
  99. export enum GoogleSafetySettingsThreshold {
  100. BLOCK_NONE = "BLOCK_NONE",
  101. BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH",
  102. BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE",
  103. BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
  104. }
  105. export enum ModelProvider {
  106. Stability = "Stability",
  107. GPT = "GPT",
  108. GeminiPro = "GeminiPro",
  109. Claude = "Claude",
  110. Ernie = "Ernie",
  111. Doubao = "Doubao",
  112. Qwen = "Qwen",
  113. Hunyuan = "Hunyuan",
  114. Moonshot = "Moonshot",
  115. Iflytek = "Iflytek",
  116. XAI = "XAI",
  117. }
  118. export const Stability = {
  119. GeneratePath: "v2beta/stable-image/generate",
  120. ExampleEndpoint: "https://api.stability.ai",
  121. };
  122. export const Anthropic = {
  123. ChatPath: "v1/messages",
  124. ChatPath1: "v1/complete",
  125. ExampleEndpoint: "https://api.anthropic.com",
  126. Vision: "2023-06-01",
  127. };
  128. export const OpenaiPath = {
  129. ChatPath: "v1/chat/completions",
  130. SpeechPath: "v1/audio/speech",
  131. ImagePath: "v1/images/generations",
  132. UsagePath: "dashboard/billing/usage",
  133. SubsPath: "dashboard/billing/subscription",
  134. ListModelPath: "v1/models",
  135. };
  136. export const Azure = {
  137. ChatPath: (deployName: string, apiVersion: string) =>
  138. `deployments/${deployName}/chat/completions?api-version=${apiVersion}`,
  139. // https://<your_resource_name>.openai.azure.com/openai/deployments/<your_deployment_name>/images/generations?api-version=<api_version>
  140. ImagePath: (deployName: string, apiVersion: string) =>
  141. `deployments/${deployName}/images/generations?api-version=${apiVersion}`,
  142. ExampleEndpoint: "https://{resource-url}/openai",
  143. };
  144. export const Google = {
  145. ExampleEndpoint: "https://generativelanguage.googleapis.com/",
  146. ChatPath: (modelName: string) =>
  147. `v1beta/models/${modelName}:streamGenerateContent`,
  148. };
  149. export const Baidu = {
  150. ExampleEndpoint: BAIDU_BASE_URL,
  151. ChatPath: (modelName: string) => {
  152. let endpoint = modelName;
  153. if (modelName === "ernie-4.0-8k") {
  154. endpoint = "completions_pro";
  155. }
  156. if (modelName === "ernie-4.0-8k-preview-0518") {
  157. endpoint = "completions_adv_pro";
  158. }
  159. if (modelName === "ernie-3.5-8k") {
  160. endpoint = "completions";
  161. }
  162. if (modelName === "ernie-speed-8k") {
  163. endpoint = "ernie_speed";
  164. }
  165. return `rpc/2.0/ai_custom/v1/wenxinworkshop/chat/${endpoint}`;
  166. },
  167. };
  168. export const ByteDance = {
  169. ExampleEndpoint: "https://ark.cn-beijing.volces.com/api/",
  170. ChatPath: "api/v3/chat/completions",
  171. };
  172. export const Alibaba = {
  173. ExampleEndpoint: ALIBABA_BASE_URL,
  174. ChatPath: "v1/services/aigc/text-generation/generation",
  175. };
  176. export const Tencent = {
  177. ExampleEndpoint: TENCENT_BASE_URL,
  178. };
  179. export const Moonshot = {
  180. ExampleEndpoint: MOONSHOT_BASE_URL,
  181. ChatPath: "v1/chat/completions",
  182. };
  183. export const Iflytek = {
  184. ExampleEndpoint: IFLYTEK_BASE_URL,
  185. ChatPath: "v1/chat/completions",
  186. };
  187. export const XAI = {
  188. ExampleEndpoint: XAI_BASE_URL,
  189. ChatPath: "v1/chat/completions",
  190. };
  191. export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
  192. // export const DEFAULT_SYSTEM_TEMPLATE = `
  193. // You are ChatGPT, a large language model trained by {{ServiceProvider}}.
  194. // Knowledge cutoff: {{cutoff}}
  195. // Current model: {{model}}
  196. // Current time: {{time}}
  197. // Latex inline: $x^2$
  198. // Latex block: $$e=mc^2$$
  199. // `;
  200. export const DEFAULT_SYSTEM_TEMPLATE = `
  201. You are ChatGPT, a large language model trained by {{ServiceProvider}}.
  202. Knowledge cutoff: {{cutoff}}
  203. Current model: {{model}}
  204. Current time: {{time}}
  205. Latex inline: \\(x^2\\)
  206. Latex block: $$e=mc^2$$
  207. `;
  208. export const SUMMARIZE_MODEL = "gpt-4o-mini";
  209. export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";
  210. export const KnowledgeCutOffDate: Record<string, string> = {
  211. default: "2021-09",
  212. "gpt-4-turbo": "2023-12",
  213. "gpt-4-turbo-2024-04-09": "2023-12",
  214. "gpt-4-turbo-preview": "2023-12",
  215. "gpt-4o": "2023-10",
  216. "gpt-4o-2024-05-13": "2023-10",
  217. "gpt-4o-2024-08-06": "2023-10",
  218. "chatgpt-4o-latest": "2023-10",
  219. "gpt-4o-mini": "2023-10",
  220. "gpt-4o-mini-2024-07-18": "2023-10",
  221. "gpt-4-vision-preview": "2023-04",
  222. "o1-mini": "2023-10",
  223. "o1-preview": "2023-10",
  224. // After improvements,
  225. // it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously.
  226. "gemini-pro": "2023-12",
  227. "gemini-pro-vision": "2023-12",
  228. };
  229. export const DEFAULT_TTS_ENGINE = "OpenAI-TTS";
  230. export const DEFAULT_TTS_ENGINES = ["OpenAI-TTS", "Edge-TTS"];
  231. export const DEFAULT_TTS_MODEL = "tts-1";
  232. export const DEFAULT_TTS_VOICE = "alloy";
  233. export const DEFAULT_TTS_MODELS = ["tts-1", "tts-1-hd"];
  234. export const DEFAULT_TTS_VOICES = [
  235. "alloy",
  236. "echo",
  237. "fable",
  238. "onyx",
  239. "nova",
  240. "shimmer",
  241. ];
  242. const openaiModels = [
  243. "gpt-3.5-turbo",
  244. "gpt-3.5-turbo-1106",
  245. "gpt-3.5-turbo-0125",
  246. "gpt-4",
  247. "gpt-4-0613",
  248. "gpt-4-32k",
  249. "gpt-4-32k-0613",
  250. "gpt-4-turbo",
  251. "gpt-4-turbo-preview",
  252. "gpt-4o",
  253. "gpt-4o-2024-05-13",
  254. "gpt-4o-2024-08-06",
  255. "chatgpt-4o-latest",
  256. "gpt-4o-mini",
  257. "gpt-4o-mini-2024-07-18",
  258. "gpt-4-vision-preview",
  259. "gpt-4-turbo-2024-04-09",
  260. "gpt-4-1106-preview",
  261. "dall-e-3",
  262. "o1-mini",
  263. "o1-preview",
  264. ];
  265. const googleModels = [
  266. "gemini-1.0-pro",
  267. "gemini-1.5-pro-latest",
  268. "gemini-1.5-flash-latest",
  269. "gemini-pro-vision",
  270. ];
  271. const anthropicModels = [
  272. "claude-instant-1.2",
  273. "claude-2.0",
  274. "claude-2.1",
  275. "claude-3-sonnet-20240229",
  276. "claude-3-opus-20240229",
  277. "claude-3-haiku-20240307",
  278. "claude-3-5-sonnet-20240620",
  279. "claude-3-5-sonnet-20241022",
  280. "claude-3-5-sonnet-latest",
  281. "claude-3-opus-latest",
  282. ];
  283. const baiduModels = [
  284. "ernie-4.0-turbo-8k",
  285. "ernie-4.0-8k",
  286. "ernie-4.0-8k-preview",
  287. "ernie-4.0-8k-preview-0518",
  288. "ernie-4.0-8k-latest",
  289. "ernie-3.5-8k",
  290. "ernie-3.5-8k-0205",
  291. "ernie-speed-128k",
  292. "ernie-speed-8k",
  293. "ernie-lite-8k",
  294. "ernie-tiny-8k",
  295. ];
  296. const bytedanceModels = [
  297. "Doubao-lite-4k",
  298. "Doubao-lite-32k",
  299. "Doubao-lite-128k",
  300. "Doubao-pro-4k",
  301. "Doubao-pro-32k",
  302. "Doubao-pro-128k",
  303. ];
  304. const alibabaModes = [
  305. "qwen-turbo",
  306. "qwen-plus",
  307. "qwen-max",
  308. "qwen-max-0428",
  309. "qwen-max-0403",
  310. "qwen-max-0107",
  311. "qwen-max-longcontext",
  312. ];
  313. const tencentModels = [
  314. "hunyuan-pro",
  315. "hunyuan-standard",
  316. "hunyuan-lite",
  317. "hunyuan-role",
  318. "hunyuan-functioncall",
  319. "hunyuan-code",
  320. "hunyuan-vision",
  321. ];
  322. const moonshotModes = ["moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k"];
  323. const iflytekModels = [
  324. "general",
  325. "generalv3",
  326. "pro-128k",
  327. "generalv3.5",
  328. "4.0Ultra",
  329. ];
  330. const xAIModes = ["grok-beta"];
  331. let seq = 1000; // 内置的模型序号生成器从1000开始
  332. export const DEFAULT_MODELS = [
  333. ...openaiModels.map((name) => ({
  334. name,
  335. available: true,
  336. sorted: seq++, // Global sequence sort(index)
  337. provider: {
  338. id: "openai",
  339. providerName: "OpenAI",
  340. providerType: "openai",
  341. sorted: 1, // 这里是固定的,确保顺序与之前内置的版本一致
  342. },
  343. })),
  344. ...openaiModels.map((name) => ({
  345. name,
  346. available: true,
  347. sorted: seq++,
  348. provider: {
  349. id: "azure",
  350. providerName: "Azure",
  351. providerType: "azure",
  352. sorted: 2,
  353. },
  354. })),
  355. ...googleModels.map((name) => ({
  356. name,
  357. available: true,
  358. sorted: seq++,
  359. provider: {
  360. id: "google",
  361. providerName: "Google",
  362. providerType: "google",
  363. sorted: 3,
  364. },
  365. })),
  366. ...anthropicModels.map((name) => ({
  367. name,
  368. available: true,
  369. sorted: seq++,
  370. provider: {
  371. id: "anthropic",
  372. providerName: "Anthropic",
  373. providerType: "anthropic",
  374. sorted: 4,
  375. },
  376. })),
  377. ...baiduModels.map((name) => ({
  378. name,
  379. available: true,
  380. sorted: seq++,
  381. provider: {
  382. id: "baidu",
  383. providerName: "Baidu",
  384. providerType: "baidu",
  385. sorted: 5,
  386. },
  387. })),
  388. ...bytedanceModels.map((name) => ({
  389. name,
  390. available: true,
  391. sorted: seq++,
  392. provider: {
  393. id: "bytedance",
  394. providerName: "ByteDance",
  395. providerType: "bytedance",
  396. sorted: 6,
  397. },
  398. })),
  399. ...alibabaModes.map((name) => ({
  400. name,
  401. available: true,
  402. sorted: seq++,
  403. provider: {
  404. id: "alibaba",
  405. providerName: "Alibaba",
  406. providerType: "alibaba",
  407. sorted: 7,
  408. },
  409. })),
  410. ...tencentModels.map((name) => ({
  411. name,
  412. available: true,
  413. sorted: seq++,
  414. provider: {
  415. id: "tencent",
  416. providerName: "Tencent",
  417. providerType: "tencent",
  418. sorted: 8,
  419. },
  420. })),
  421. ...moonshotModes.map((name) => ({
  422. name,
  423. available: true,
  424. sorted: seq++,
  425. provider: {
  426. id: "moonshot",
  427. providerName: "Moonshot",
  428. providerType: "moonshot",
  429. sorted: 9,
  430. },
  431. })),
  432. ...iflytekModels.map((name) => ({
  433. name,
  434. available: true,
  435. sorted: seq++,
  436. provider: {
  437. id: "iflytek",
  438. providerName: "Iflytek",
  439. providerType: "iflytek",
  440. sorted: 10,
  441. },
  442. })),
  443. ...xAIModes.map((name) => ({
  444. name,
  445. available: true,
  446. sorted: seq++,
  447. provider: {
  448. id: "xai",
  449. providerName: "XAI",
  450. providerType: "xai",
  451. sorted: 11,
  452. },
  453. })),
  454. ] as const;
  455. export const CHAT_PAGE_SIZE = 15;
  456. export const MAX_RENDER_MSG_COUNT = 45;
  457. // some famous webdav endpoints
  458. export const internalAllowedWebDavEndpoints = [
  459. "https://dav.jianguoyun.com/dav/",
  460. "https://dav.dropdav.com/",
  461. "https://dav.box.com/dav",
  462. "https://nanao.teracloud.jp/dav/",
  463. "https://bora.teracloud.jp/dav/",
  464. "https://webdav.4shared.com/",
  465. "https://dav.idrivesync.com",
  466. "https://webdav.yandex.com",
  467. "https://app.koofr.net/dav/Koofr",
  468. ];
  469. export const DEFAULT_GA_ID = "G-89WN60ZK2E";
  470. export const PLUGINS = [
  471. { name: "Plugins", path: Path.Plugins },
  472. { name: "Stable Diffusion", path: Path.Sd },
  473. { name: "Search Chat", path: Path.SearchChat },
  474. ];
  475. export const SAAS_CHAT_URL = "https://nextchat.dev/chat";
  476. export const SAAS_CHAT_UTM_URL = "https://nextchat.dev/chat?utm=github";