constant.ts 12 KB

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