constant.ts 9.8 KB

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