constant.ts 8.9 KB

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