constant.ts 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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 BAIDU_BASE_URL = "https://aip.baidubce.com";
  14. export const BAIDU_OATUH_URL = `${BAIDU_BASE_URL}/oauth/2.0/token`;
  15. export const BYTEDANCE_BASE_URL = "https://ark.cn-beijing.volces.com";
  16. export const ALIBABA_BASE_URL = "https://dashscope.aliyuncs.com/api/";
  17. export const TENCENT_BASE_URL = "https://hunyuan.tencentcloudapi.com";
  18. export const IFLYTEK_BASE_URL = "https://spark-api-open.xf-yun.com";
  19. export const CACHE_URL_PREFIX = "/api/cache";
  20. export const UPLOAD_URL = `${CACHE_URL_PREFIX}/upload`;
  21. export enum Path {
  22. Home = "/",
  23. Chat = "/chat",
  24. Settings = "/settings",
  25. MaskChat = "/mask-chat",
  26. Masks = "/masks",
  27. Auth = "/auth",
  28. Artifacts = "/artifacts",
  29. }
  30. export enum ApiPath {
  31. Cors = "",
  32. Azure = "/api/azure",
  33. OpenAI = "/api/openai",
  34. Baidu = "/api/baidu",
  35. ByteDance = "/api/bytedance",
  36. Alibaba = "/api/alibaba",
  37. Tencent = "/api/tencent",
  38. Iflytek = "/api/iflytek",
  39. Artifacts = "/api/artifacts",
  40. BigModel = "/api/bigModel",
  41. }
  42. export enum SlotID {
  43. AppBody = "app-body",
  44. CustomModel = "custom-model",
  45. }
  46. export enum FileName {
  47. Masks = "masks.json",
  48. Prompts = "prompts.json",
  49. }
  50. export enum Plugin {
  51. Artifacts = "artifacts",
  52. }
  53. export enum Plugin {
  54. BigModel = "bigModel",
  55. }
  56. export enum StoreKey {
  57. Chat = "chat-next-web-store",
  58. Access = "access-control",
  59. Config = "app-config",
  60. Mask = "mask-store",
  61. Prompt = "prompt-store",
  62. Update = "chat-update",
  63. Sync = "sync",
  64. }
  65. export const DEFAULT_SIDEBAR_WIDTH = 300;
  66. export const MAX_SIDEBAR_WIDTH = 500;
  67. export const MIN_SIDEBAR_WIDTH = 200;
  68. export const NARROW_SIDEBAR_WIDTH = 200;
  69. export const ACCESS_CODE_PREFIX = "nk-";
  70. export const LAST_INPUT_KEY = "last-input";
  71. export const UNFINISHED_INPUT = (id: string) => "unfinished-input-" + id;
  72. export const STORAGE_KEY = "chatgpt-next-web";
  73. export const REQUEST_TIMEOUT_MS = 60000;
  74. export const EXPORT_MESSAGE_CLASS_NAME = "export-markdown";
  75. export enum ServiceProvider {
  76. BigModel = "BigModel",
  77. DeepSeek = "DeepSeek",
  78. OpenAI = "OpenAI",
  79. Azure = "Azure",
  80. Baidu = "Baidu",
  81. ByteDance = "ByteDance",
  82. Alibaba = "Alibaba",
  83. Tencent = "Tencent",
  84. Iflytek = "Iflytek",
  85. }
  86. export enum ModelProvider {
  87. BigModel = "bigModel",
  88. DeepSeek = "deepSeek",
  89. GPT = "GPT",
  90. Ernie = "Ernie",
  91. Doubao = "Doubao",
  92. Qwen = "Qwen",
  93. Hunyuan = "Hunyuan",
  94. Iflytek = "Iflytek",
  95. }
  96. export const OpenaiPath = {
  97. ChatPath: "v1/chat/completions",
  98. ImagePath: "v1/images/generations",
  99. UsagePath: "dashboard/billing/usage",
  100. SubsPath: "dashboard/billing/subscription",
  101. ListModelPath: "v1/models",
  102. };
  103. export const Azure = {
  104. ChatPath: (deployName: string, apiVersion: string) =>
  105. `deployments/${deployName}/chat/completions?api-version=${apiVersion}`,
  106. // https://<your_resource_name>.openai.azure.com/openai/deployments/<your_deployment_name>/images/generations?api-version=<api_version>
  107. ImagePath: (deployName: string, apiVersion: string) =>
  108. `deployments/${deployName}/images/generations?api-version=${apiVersion}`,
  109. ExampleEndpoint: "https://{resource-url}/openai",
  110. };
  111. export const Baidu = {
  112. ExampleEndpoint: BAIDU_BASE_URL,
  113. ChatPath: (modelName: string) => {
  114. let endpoint = modelName;
  115. if (modelName === "ernie-4.0-8k") {
  116. endpoint = "completions_pro";
  117. }
  118. if (modelName === "ernie-4.0-8k-preview-0518") {
  119. endpoint = "completions_adv_pro";
  120. }
  121. if (modelName === "ernie-3.5-8k") {
  122. endpoint = "completions";
  123. }
  124. if (modelName === "ernie-speed-8k") {
  125. endpoint = "ernie_speed";
  126. }
  127. return `rpc/2.0/ai_custom/v1/wenxinworkshop/chat/${endpoint}`;
  128. },
  129. };
  130. export const ByteDance = {
  131. ExampleEndpoint: "https://ark.cn-beijing.volces.com/api/",
  132. ChatPath: "api/v3/chat/completions",
  133. };
  134. export const Alibaba = {
  135. ExampleEndpoint: ALIBABA_BASE_URL,
  136. ChatPath: "v1/services/aigc/text-generation/generation",
  137. };
  138. export const Tencent = {
  139. ExampleEndpoint: TENCENT_BASE_URL,
  140. };
  141. export const Iflytek = {
  142. ExampleEndpoint: IFLYTEK_BASE_URL,
  143. ChatPath: "v1/chat/completions",
  144. };
  145. export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
  146. // export const DEFAULT_SYSTEM_TEMPLATE = `
  147. // You are ChatGPT, a large language model trained by {{ServiceProvider}}.
  148. // Knowledge cutoff: {{cutoff}}
  149. // Current model: {{model}}
  150. // Current time: {{time}}
  151. // Latex inline: $x^2$
  152. // Latex block: $$e=mc^2$$
  153. // `;
  154. export const DEFAULT_SYSTEM_TEMPLATE: any = null;
  155. // `
  156. // You are ChatGPT, a large language model trained by {{ServiceProvider}}.
  157. // Knowledge cutoff: {{cutoff}}
  158. // Current model: {{model}}
  159. // Current time: {{time}}
  160. // Latex inline: \\(x^2\\)
  161. // Latex block: $$e=mc^2$$
  162. // `;
  163. export const SUMMARIZE_MODEL = "gpt-4o-mini";
  164. export const KnowledgeCutOffDate: Record<string, string> = {
  165. default: "2021-09",
  166. "gpt-4-turbo": "2023-12",
  167. "gpt-4-turbo-2024-04-09": "2023-12",
  168. "gpt-4-turbo-preview": "2023-12",
  169. "gpt-4o": "2023-10",
  170. "gpt-4o-2024-05-13": "2023-10",
  171. "gpt-4o-2024-08-06": "2023-10",
  172. "gpt-4o-mini": "2023-10",
  173. "gpt-4o-mini-2024-07-18": "2023-10",
  174. "gpt-4-vision-preview": "2023-04",
  175. // After improvements,
  176. // it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously.
  177. };
  178. const openaiModels = [
  179. "gpt-3.5-turbo",
  180. "gpt-3.5-turbo-1106",
  181. "gpt-3.5-turbo-0125",
  182. "gpt-4",
  183. "gpt-4-0613",
  184. "gpt-4-32k",
  185. "gpt-4-32k-0613",
  186. "gpt-4-turbo",
  187. "gpt-4-turbo-preview",
  188. "gpt-4o",
  189. "gpt-4o-2024-05-13",
  190. "gpt-4o-2024-08-06",
  191. "gpt-4o-mini",
  192. "gpt-4o-mini-2024-07-18",
  193. "gpt-4-vision-preview",
  194. "gpt-4-turbo-2024-04-09",
  195. "gpt-4-1106-preview",
  196. "dall-e-3",
  197. ];
  198. const baiduModels = [
  199. "ernie-4.0-turbo-8k",
  200. "ernie-4.0-8k",
  201. "ernie-4.0-8k-preview",
  202. "ernie-4.0-8k-preview-0518",
  203. "ernie-4.0-8k-latest",
  204. "ernie-3.5-8k",
  205. "ernie-3.5-8k-0205",
  206. "ernie-speed-128k",
  207. "ernie-speed-8k",
  208. "ernie-lite-8k",
  209. "ernie-tiny-8k",
  210. ];
  211. const bytedanceModels = [
  212. "Doubao-lite-4k",
  213. "Doubao-lite-32k",
  214. "Doubao-lite-128k",
  215. "Doubao-pro-4k",
  216. "Doubao-pro-32k",
  217. "Doubao-pro-128k",
  218. ];
  219. const alibabaModes = [
  220. "qwen-turbo",
  221. "qwen-plus",
  222. "qwen-max",
  223. "qwen-max-0428",
  224. "qwen-max-0403",
  225. "qwen-max-0107",
  226. "qwen-max-longcontext",
  227. ];
  228. const tencentModels = [
  229. "hunyuan-pro",
  230. "hunyuan-standard",
  231. "hunyuan-lite",
  232. "hunyuan-role",
  233. "hunyuan-functioncall",
  234. "hunyuan-code",
  235. "hunyuan-vision",
  236. ];
  237. const iflytekModels = [
  238. "general",
  239. "generalv3",
  240. "pro-128k",
  241. "generalv3.5",
  242. "4.0Ultra",
  243. ];
  244. let seq = 1000; // 内置的模型序号生成器从1000开始
  245. export const DEFAULT_MODELS = [
  246. ...openaiModels.map((name) => ({
  247. name,
  248. available: true,
  249. sorted: seq++, // Global sequence sort(index)
  250. provider: {
  251. id: "openai",
  252. providerName: "OpenAI",
  253. providerType: "openai",
  254. sorted: 1, // 这里是固定的,确保顺序与之前内置的版本一致
  255. },
  256. })),
  257. ...openaiModels.map((name) => ({
  258. name,
  259. available: true,
  260. sorted: seq++,
  261. provider: {
  262. id: "azure",
  263. providerName: "Azure",
  264. providerType: "azure",
  265. sorted: 2,
  266. },
  267. })),
  268. ...baiduModels.map((name) => ({
  269. name,
  270. available: true,
  271. sorted: seq++,
  272. provider: {
  273. id: "baidu",
  274. providerName: "Baidu",
  275. providerType: "baidu",
  276. sorted: 5,
  277. },
  278. })),
  279. ...bytedanceModels.map((name) => ({
  280. name,
  281. available: true,
  282. sorted: seq++,
  283. provider: {
  284. id: "bytedance",
  285. providerName: "ByteDance",
  286. providerType: "bytedance",
  287. sorted: 6,
  288. },
  289. })),
  290. ...alibabaModes.map((name) => ({
  291. name,
  292. available: true,
  293. sorted: seq++,
  294. provider: {
  295. id: "alibaba",
  296. providerName: "Alibaba",
  297. providerType: "alibaba",
  298. sorted: 7,
  299. },
  300. })),
  301. ...tencentModels.map((name) => ({
  302. name,
  303. available: true,
  304. sorted: seq++,
  305. provider: {
  306. id: "tencent",
  307. providerName: "Tencent",
  308. providerType: "tencent",
  309. sorted: 8,
  310. },
  311. })),
  312. ...iflytekModels.map((name) => ({
  313. name,
  314. available: true,
  315. sorted: seq++,
  316. provider: {
  317. id: "iflytek",
  318. providerName: "Iflytek",
  319. providerType: "iflytek",
  320. sorted: 10,
  321. },
  322. })),
  323. ] as const;
  324. export const CHAT_PAGE_SIZE = 15;
  325. export const MAX_RENDER_MSG_COUNT = 45;
  326. // some famous webdav endpoints
  327. export const internalAllowedWebDavEndpoints = [
  328. "https://dav.jianguoyun.com/dav/",
  329. "https://dav.dropdav.com/",
  330. "https://dav.box.com/dav",
  331. "https://nanao.teracloud.jp/dav/",
  332. "https://bora.teracloud.jp/dav/",
  333. "https://webdav.4shared.com/",
  334. "https://dav.idrivesync.com",
  335. "https://webdav.yandex.com",
  336. "https://app.koofr.net/dav/Koofr",
  337. ];