constant.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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 ISSUE_URL = `https://github.com/${OWNER}/${REPO}/issues`;
  5. export const UPDATE_URL = `${REPO_URL}#keep-updated`;
  6. export const RELEASE_URL = `${REPO_URL}/releases`;
  7. export const FETCH_COMMIT_URL = `https://api.github.com/repos/${OWNER}/${REPO}/commits?per_page=1`;
  8. export const FETCH_TAG_URL = `https://api.github.com/repos/${OWNER}/${REPO}/tags?per_page=1`;
  9. export const RUNTIME_CONFIG_DOM = "danger-runtime-config";
  10. export const STABILITY_BASE_URL = "https://api.stability.ai";
  11. export const DEFAULT_API_HOST = "https://api.nextchat.dev";
  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 CACHE_URL_PREFIX = "/api/cache";
  23. export const UPLOAD_URL = `${CACHE_URL_PREFIX}/upload`;
  24. export enum Path {
  25. Home = "/",
  26. Chat = "/chat",
  27. Settings = "/settings",
  28. NewChat = "/new-chat",
  29. Masks = "/masks",
  30. Auth = "/auth",
  31. Artifacts = "/artifacts",
  32. }
  33. export enum ApiPath {
  34. Cors = "",
  35. Azure = "/api/azure",
  36. OpenAI = "/api/openai",
  37. Anthropic = "/api/anthropic",
  38. Google = "/api/google",
  39. Baidu = "/api/baidu",
  40. ByteDance = "/api/bytedance",
  41. Alibaba = "/api/alibaba",
  42. Tencent = "/api/tencent",
  43. Moonshot = "/api/moonshot",
  44. Iflytek = "/api/iflytek",
  45. Stability = "/api/stability",
  46. Artifacts = "/api/artifacts",
  47. BigModel = "/api/bigModel",
  48. }
  49. export enum SlotID {
  50. AppBody = "app-body",
  51. CustomModel = "custom-model",
  52. }
  53. export enum FileName {
  54. Masks = "masks.json",
  55. Prompts = "prompts.json",
  56. }
  57. export enum Plugin {
  58. Artifacts = "artifacts",
  59. }
  60. export enum Plugin {
  61. BigModel = "bigModel",
  62. }
  63. export enum StoreKey {
  64. Chat = "chat-next-web-store",
  65. Access = "access-control",
  66. Config = "app-config",
  67. Mask = "mask-store",
  68. Prompt = "prompt-store",
  69. Update = "chat-update",
  70. Sync = "sync",
  71. }
  72. export const DEFAULT_SIDEBAR_WIDTH = 300;
  73. export const MAX_SIDEBAR_WIDTH = 500;
  74. export const MIN_SIDEBAR_WIDTH = 200;
  75. export const NARROW_SIDEBAR_WIDTH = 200;
  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. BigModel = "BigModel",
  84. DeepSeek = "DeepSeek",
  85. OpenAI = "OpenAI",
  86. Azure = "Azure",
  87. Google = "Google",
  88. Anthropic = "Anthropic",
  89. Baidu = "Baidu",
  90. ByteDance = "ByteDance",
  91. Alibaba = "Alibaba",
  92. Tencent = "Tencent",
  93. Moonshot = "Moonshot",
  94. Stability = "Stability",
  95. Iflytek = "Iflytek",
  96. }
  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. BigModel = "bigModel",
  105. DeepSeek = "deepSeek",
  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. }
  117. export const Stability = {
  118. GeneratePath: "v2beta/stable-image/generate",
  119. ExampleEndpoint: "https://api.stability.ai",
  120. };
  121. export const Anthropic = {
  122. ChatPath: "v1/messages",
  123. ChatPath1: "v1/complete",
  124. ExampleEndpoint: "https://api.anthropic.com",
  125. Vision: "2023-06-01",
  126. };
  127. export const OpenaiPath = {
  128. ChatPath: "v1/chat/completions",
  129. ImagePath: "v1/images/generations",
  130. UsagePath: "dashboard/billing/usage",
  131. SubsPath: "dashboard/billing/subscription",
  132. ListModelPath: "v1/models",
  133. };
  134. export const Azure = {
  135. ChatPath: (deployName: string, apiVersion: string) =>
  136. `deployments/${deployName}/chat/completions?api-version=${apiVersion}`,
  137. // https://<your_resource_name>.openai.azure.com/openai/deployments/<your_deployment_name>/images/generations?api-version=<api_version>
  138. ImagePath: (deployName: string, apiVersion: string) =>
  139. `deployments/${deployName}/images/generations?api-version=${apiVersion}`,
  140. ExampleEndpoint: "https://{resource-url}/openai",
  141. };
  142. export const Google = {
  143. ExampleEndpoint: "https://generativelanguage.googleapis.com/",
  144. ChatPath: (modelName: string) =>
  145. `v1beta/models/${modelName}:streamGenerateContent`,
  146. };
  147. export const Baidu = {
  148. ExampleEndpoint: BAIDU_BASE_URL,
  149. ChatPath: (modelName: string) => {
  150. let endpoint = modelName;
  151. if (modelName === "ernie-4.0-8k") {
  152. endpoint = "completions_pro";
  153. }
  154. if (modelName === "ernie-4.0-8k-preview-0518") {
  155. endpoint = "completions_adv_pro";
  156. }
  157. if (modelName === "ernie-3.5-8k") {
  158. endpoint = "completions";
  159. }
  160. if (modelName === "ernie-speed-8k") {
  161. endpoint = "ernie_speed";
  162. }
  163. return `rpc/2.0/ai_custom/v1/wenxinworkshop/chat/${endpoint}`;
  164. },
  165. };
  166. export const ByteDance = {
  167. ExampleEndpoint: "https://ark.cn-beijing.volces.com/api/",
  168. ChatPath: "api/v3/chat/completions",
  169. };
  170. export const Alibaba = {
  171. ExampleEndpoint: ALIBABA_BASE_URL,
  172. ChatPath: "v1/services/aigc/text-generation/generation",
  173. };
  174. export const Tencent = {
  175. ExampleEndpoint: TENCENT_BASE_URL,
  176. };
  177. export const Moonshot = {
  178. ExampleEndpoint: MOONSHOT_BASE_URL,
  179. ChatPath: "v1/chat/completions",
  180. };
  181. export const Iflytek = {
  182. ExampleEndpoint: IFLYTEK_BASE_URL,
  183. ChatPath: "v1/chat/completions",
  184. };
  185. export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
  186. // export const DEFAULT_SYSTEM_TEMPLATE = `
  187. // You are ChatGPT, a large language model trained by {{ServiceProvider}}.
  188. // Knowledge cutoff: {{cutoff}}
  189. // Current model: {{model}}
  190. // Current time: {{time}}
  191. // Latex inline: $x^2$
  192. // Latex block: $$e=mc^2$$
  193. // `;
  194. export const DEFAULT_SYSTEM_TEMPLATE: any = null;
  195. // `
  196. // You are ChatGPT, a large language model trained by {{ServiceProvider}}.
  197. // Knowledge cutoff: {{cutoff}}
  198. // Current model: {{model}}
  199. // Current time: {{time}}
  200. // Latex inline: \\(x^2\\)
  201. // Latex block: $$e=mc^2$$
  202. // `;
  203. export const SUMMARIZE_MODEL = "gpt-4o-mini";
  204. export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";
  205. export const KnowledgeCutOffDate: Record<string, string> = {
  206. default: "2021-09",
  207. "gpt-4-turbo": "2023-12",
  208. "gpt-4-turbo-2024-04-09": "2023-12",
  209. "gpt-4-turbo-preview": "2023-12",
  210. "gpt-4o": "2023-10",
  211. "gpt-4o-2024-05-13": "2023-10",
  212. "gpt-4o-2024-08-06": "2023-10",
  213. "gpt-4o-mini": "2023-10",
  214. "gpt-4o-mini-2024-07-18": "2023-10",
  215. "gpt-4-vision-preview": "2023-04",
  216. // After improvements,
  217. // it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously.
  218. "gemini-pro": "2023-12",
  219. "gemini-pro-vision": "2023-12",
  220. };
  221. const openaiModels = [
  222. "gpt-3.5-turbo",
  223. "gpt-3.5-turbo-1106",
  224. "gpt-3.5-turbo-0125",
  225. "gpt-4",
  226. "gpt-4-0613",
  227. "gpt-4-32k",
  228. "gpt-4-32k-0613",
  229. "gpt-4-turbo",
  230. "gpt-4-turbo-preview",
  231. "gpt-4o",
  232. "gpt-4o-2024-05-13",
  233. "gpt-4o-2024-08-06",
  234. "gpt-4o-mini",
  235. "gpt-4o-mini-2024-07-18",
  236. "gpt-4-vision-preview",
  237. "gpt-4-turbo-2024-04-09",
  238. "gpt-4-1106-preview",
  239. "dall-e-3",
  240. ];
  241. const googleModels = [
  242. "gemini-1.0-pro",
  243. "gemini-1.5-pro-latest",
  244. "gemini-1.5-flash-latest",
  245. "gemini-pro-vision",
  246. ];
  247. const anthropicModels = [
  248. "claude-instant-1.2",
  249. "claude-2.0",
  250. "claude-2.1",
  251. "claude-3-sonnet-20240229",
  252. "claude-3-opus-20240229",
  253. "claude-3-haiku-20240307",
  254. "claude-3-5-sonnet-20240620",
  255. ];
  256. const baiduModels = [
  257. "ernie-4.0-turbo-8k",
  258. "ernie-4.0-8k",
  259. "ernie-4.0-8k-preview",
  260. "ernie-4.0-8k-preview-0518",
  261. "ernie-4.0-8k-latest",
  262. "ernie-3.5-8k",
  263. "ernie-3.5-8k-0205",
  264. "ernie-speed-128k",
  265. "ernie-speed-8k",
  266. "ernie-lite-8k",
  267. "ernie-tiny-8k",
  268. ];
  269. const bytedanceModels = [
  270. "Doubao-lite-4k",
  271. "Doubao-lite-32k",
  272. "Doubao-lite-128k",
  273. "Doubao-pro-4k",
  274. "Doubao-pro-32k",
  275. "Doubao-pro-128k",
  276. ];
  277. const alibabaModes = [
  278. "qwen-turbo",
  279. "qwen-plus",
  280. "qwen-max",
  281. "qwen-max-0428",
  282. "qwen-max-0403",
  283. "qwen-max-0107",
  284. "qwen-max-longcontext",
  285. ];
  286. const tencentModels = [
  287. "hunyuan-pro",
  288. "hunyuan-standard",
  289. "hunyuan-lite",
  290. "hunyuan-role",
  291. "hunyuan-functioncall",
  292. "hunyuan-code",
  293. "hunyuan-vision",
  294. ];
  295. const moonshotModes = ["moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k"];
  296. const iflytekModels = [
  297. "general",
  298. "generalv3",
  299. "pro-128k",
  300. "generalv3.5",
  301. "4.0Ultra",
  302. ];
  303. let seq = 1000; // 内置的模型序号生成器从1000开始
  304. export const DEFAULT_MODELS = [
  305. ...openaiModels.map((name) => ({
  306. name,
  307. available: true,
  308. sorted: seq++, // Global sequence sort(index)
  309. provider: {
  310. id: "openai",
  311. providerName: "OpenAI",
  312. providerType: "openai",
  313. sorted: 1, // 这里是固定的,确保顺序与之前内置的版本一致
  314. },
  315. })),
  316. ...openaiModels.map((name) => ({
  317. name,
  318. available: true,
  319. sorted: seq++,
  320. provider: {
  321. id: "azure",
  322. providerName: "Azure",
  323. providerType: "azure",
  324. sorted: 2,
  325. },
  326. })),
  327. ...googleModels.map((name) => ({
  328. name,
  329. available: true,
  330. sorted: seq++,
  331. provider: {
  332. id: "google",
  333. providerName: "Google",
  334. providerType: "google",
  335. sorted: 3,
  336. },
  337. })),
  338. ...anthropicModels.map((name) => ({
  339. name,
  340. available: true,
  341. sorted: seq++,
  342. provider: {
  343. id: "anthropic",
  344. providerName: "Anthropic",
  345. providerType: "anthropic",
  346. sorted: 4,
  347. },
  348. })),
  349. ...baiduModels.map((name) => ({
  350. name,
  351. available: true,
  352. sorted: seq++,
  353. provider: {
  354. id: "baidu",
  355. providerName: "Baidu",
  356. providerType: "baidu",
  357. sorted: 5,
  358. },
  359. })),
  360. ...bytedanceModels.map((name) => ({
  361. name,
  362. available: true,
  363. sorted: seq++,
  364. provider: {
  365. id: "bytedance",
  366. providerName: "ByteDance",
  367. providerType: "bytedance",
  368. sorted: 6,
  369. },
  370. })),
  371. ...alibabaModes.map((name) => ({
  372. name,
  373. available: true,
  374. sorted: seq++,
  375. provider: {
  376. id: "alibaba",
  377. providerName: "Alibaba",
  378. providerType: "alibaba",
  379. sorted: 7,
  380. },
  381. })),
  382. ...tencentModels.map((name) => ({
  383. name,
  384. available: true,
  385. sorted: seq++,
  386. provider: {
  387. id: "tencent",
  388. providerName: "Tencent",
  389. providerType: "tencent",
  390. sorted: 8,
  391. },
  392. })),
  393. ...moonshotModes.map((name) => ({
  394. name,
  395. available: true,
  396. sorted: seq++,
  397. provider: {
  398. id: "moonshot",
  399. providerName: "Moonshot",
  400. providerType: "moonshot",
  401. sorted: 9,
  402. },
  403. })),
  404. ...iflytekModels.map((name) => ({
  405. name,
  406. available: true,
  407. sorted: seq++,
  408. provider: {
  409. id: "iflytek",
  410. providerName: "Iflytek",
  411. providerType: "iflytek",
  412. sorted: 10,
  413. },
  414. })),
  415. ] as const;
  416. export const CHAT_PAGE_SIZE = 15;
  417. export const MAX_RENDER_MSG_COUNT = 45;
  418. // some famous webdav endpoints
  419. export const internalAllowedWebDavEndpoints = [
  420. "https://dav.jianguoyun.com/dav/",
  421. "https://dav.dropdav.com/",
  422. "https://dav.box.com/dav",
  423. "https://nanao.teracloud.jp/dav/",
  424. "https://bora.teracloud.jp/dav/",
  425. "https://webdav.4shared.com/",
  426. "https://dav.idrivesync.com",
  427. "https://webdav.yandex.com",
  428. "https://app.koofr.net/dav/Koofr",
  429. ];