constant.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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. UsagePath: "dashboard/billing/usage",
  123. SubsPath: "dashboard/billing/subscription",
  124. ListModelPath: "v1/models",
  125. };
  126. export const Azure = {
  127. ChatPath: (deployName: string, apiVersion: string) =>
  128. `deployments/${deployName}/chat/completions?api-version=${apiVersion}`,
  129. ExampleEndpoint: "https://{resource-url}/openai/deployments/{deploy-id}",
  130. };
  131. export const Google = {
  132. ExampleEndpoint: "https://generativelanguage.googleapis.com/",
  133. ChatPath: (modelName: string) =>
  134. `v1beta/models/${modelName}:streamGenerateContent`,
  135. };
  136. export const Baidu = {
  137. ExampleEndpoint: BAIDU_BASE_URL,
  138. ChatPath: (modelName: string) => {
  139. let endpoint = modelName;
  140. if (modelName === "ernie-4.0-8k") {
  141. endpoint = "completions_pro";
  142. }
  143. if (modelName === "ernie-4.0-8k-preview-0518") {
  144. endpoint = "completions_adv_pro";
  145. }
  146. if (modelName === "ernie-3.5-8k") {
  147. endpoint = "completions";
  148. }
  149. if (modelName === "ernie-speed-8k") {
  150. endpoint = "ernie_speed";
  151. }
  152. return `rpc/2.0/ai_custom/v1/wenxinworkshop/chat/${endpoint}`;
  153. },
  154. };
  155. export const ByteDance = {
  156. ExampleEndpoint: "https://ark.cn-beijing.volces.com/api/",
  157. ChatPath: "api/v3/chat/completions",
  158. };
  159. export const Alibaba = {
  160. ExampleEndpoint: ALIBABA_BASE_URL,
  161. ChatPath: "v1/services/aigc/text-generation/generation",
  162. };
  163. export const Tencent = {
  164. ExampleEndpoint: TENCENT_BASE_URL,
  165. };
  166. export const Moonshot = {
  167. ExampleEndpoint: MOONSHOT_BASE_URL,
  168. ChatPath: "v1/chat/completions",
  169. };
  170. export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
  171. // export const DEFAULT_SYSTEM_TEMPLATE = `
  172. // You are ChatGPT, a large language model trained by {{ServiceProvider}}.
  173. // Knowledge cutoff: {{cutoff}}
  174. // Current model: {{model}}
  175. // Current time: {{time}}
  176. // Latex inline: $x^2$
  177. // Latex block: $$e=mc^2$$
  178. // `;
  179. export const DEFAULT_SYSTEM_TEMPLATE = `
  180. You are ChatGPT, a large language model trained by {{ServiceProvider}}.
  181. Knowledge cutoff: {{cutoff}}
  182. Current model: {{model}}
  183. Current time: {{time}}
  184. Latex inline: \\(x^2\\)
  185. Latex block: $$e=mc^2$$
  186. `;
  187. export const SUMMARIZE_MODEL = "gpt-4o-mini";
  188. export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";
  189. export const KnowledgeCutOffDate: Record<string, string> = {
  190. default: "2021-09",
  191. "gpt-4-turbo": "2023-12",
  192. "gpt-4-turbo-2024-04-09": "2023-12",
  193. "gpt-4-turbo-preview": "2023-12",
  194. "gpt-4o": "2023-10",
  195. "gpt-4o-2024-05-13": "2023-10",
  196. "gpt-4o-mini": "2023-10",
  197. "gpt-4o-mini-2024-07-18": "2023-10",
  198. "gpt-4-vision-preview": "2023-04",
  199. // After improvements,
  200. // it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously.
  201. "gemini-pro": "2023-12",
  202. "gemini-pro-vision": "2023-12",
  203. };
  204. const openaiModels = [
  205. "gpt-3.5-turbo",
  206. "gpt-3.5-turbo-1106",
  207. "gpt-3.5-turbo-0125",
  208. "gpt-4",
  209. "gpt-4-0613",
  210. "gpt-4-32k",
  211. "gpt-4-32k-0613",
  212. "gpt-4-turbo",
  213. "gpt-4-turbo-preview",
  214. "gpt-4o",
  215. "gpt-4o-2024-05-13",
  216. "gpt-4o-mini",
  217. "gpt-4o-mini-2024-07-18",
  218. "gpt-4-vision-preview",
  219. "gpt-4-turbo-2024-04-09",
  220. "gpt-4-1106-preview",
  221. ];
  222. const googleModels = [
  223. "gemini-1.0-pro",
  224. "gemini-1.5-pro-latest",
  225. "gemini-1.5-flash-latest",
  226. "gemini-pro-vision",
  227. ];
  228. const anthropicModels = [
  229. "claude-instant-1.2",
  230. "claude-2.0",
  231. "claude-2.1",
  232. "claude-3-sonnet-20240229",
  233. "claude-3-opus-20240229",
  234. "claude-3-haiku-20240307",
  235. "claude-3-5-sonnet-20240620",
  236. ];
  237. const baiduModels = [
  238. "ernie-4.0-turbo-8k",
  239. "ernie-4.0-8k",
  240. "ernie-4.0-8k-preview",
  241. "ernie-4.0-8k-preview-0518",
  242. "ernie-4.0-8k-latest",
  243. "ernie-3.5-8k",
  244. "ernie-3.5-8k-0205",
  245. "ernie-speed-128k",
  246. "ernie-speed-8k",
  247. "ernie-lite-8k",
  248. "ernie-tiny-8k",
  249. ];
  250. const bytedanceModels = [
  251. "Doubao-lite-4k",
  252. "Doubao-lite-32k",
  253. "Doubao-lite-128k",
  254. "Doubao-pro-4k",
  255. "Doubao-pro-32k",
  256. "Doubao-pro-128k",
  257. ];
  258. const alibabaModes = [
  259. "qwen-turbo",
  260. "qwen-plus",
  261. "qwen-max",
  262. "qwen-max-0428",
  263. "qwen-max-0403",
  264. "qwen-max-0107",
  265. "qwen-max-longcontext",
  266. ];
  267. const tencentModels = [
  268. "hunyuan-pro",
  269. "hunyuan-standard",
  270. "hunyuan-lite",
  271. "hunyuan-role",
  272. "hunyuan-functioncall",
  273. "hunyuan-code",
  274. "hunyuan-vision",
  275. ];
  276. const moonshotModes = ["moonshot-v1-8k", "moonshot-v1-32k", "moonshot-v1-128k"];
  277. export const DEFAULT_MODELS = [
  278. ...openaiModels.map((name) => ({
  279. name,
  280. available: true,
  281. provider: {
  282. id: "openai",
  283. providerName: "OpenAI",
  284. providerType: "openai",
  285. },
  286. })),
  287. ...openaiModels.map((name) => ({
  288. name,
  289. available: true,
  290. provider: {
  291. id: "azure",
  292. providerName: "Azure",
  293. providerType: "azure",
  294. },
  295. })),
  296. ...googleModels.map((name) => ({
  297. name,
  298. available: true,
  299. provider: {
  300. id: "google",
  301. providerName: "Google",
  302. providerType: "google",
  303. },
  304. })),
  305. ...anthropicModels.map((name) => ({
  306. name,
  307. available: true,
  308. provider: {
  309. id: "anthropic",
  310. providerName: "Anthropic",
  311. providerType: "anthropic",
  312. },
  313. })),
  314. ...baiduModels.map((name) => ({
  315. name,
  316. available: true,
  317. provider: {
  318. id: "baidu",
  319. providerName: "Baidu",
  320. providerType: "baidu",
  321. },
  322. })),
  323. ...bytedanceModels.map((name) => ({
  324. name,
  325. available: true,
  326. provider: {
  327. id: "bytedance",
  328. providerName: "ByteDance",
  329. providerType: "bytedance",
  330. },
  331. })),
  332. ...alibabaModes.map((name) => ({
  333. name,
  334. available: true,
  335. provider: {
  336. id: "alibaba",
  337. providerName: "Alibaba",
  338. providerType: "alibaba",
  339. },
  340. })),
  341. ...tencentModels.map((name) => ({
  342. name,
  343. available: true,
  344. provider: {
  345. id: "tencent",
  346. providerName: "Tencent",
  347. providerType: "tencent",
  348. },
  349. })),
  350. ...moonshotModes.map((name) => ({
  351. name,
  352. available: true,
  353. provider: {
  354. id: "moonshot",
  355. providerName: "Moonshot",
  356. providerType: "moonshot",
  357. },
  358. })),
  359. ] as const;
  360. export const CHAT_PAGE_SIZE = 15;
  361. export const MAX_RENDER_MSG_COUNT = 45;
  362. // some famous webdav endpoints
  363. export const internalAllowedWebDavEndpoints = [
  364. "https://dav.jianguoyun.com/dav/",
  365. "https://dav.dropdav.com/",
  366. "https://dav.box.com/dav",
  367. "https://nanao.teracloud.jp/dav/",
  368. "https://bora.teracloud.jp/dav/",
  369. "https://webdav.4shared.com/",
  370. "https://dav.idrivesync.com",
  371. "https://webdav.yandex.com",
  372. "https://app.koofr.net/dav/Koofr",
  373. ];
  374. export const PLUGINS = [{ name: "Stable Diffusion", path: Path.Sd }];