constant.ts 11 KB

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