constant.ts 12 KB

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