constant.ts 10 KB

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