constant.ts 8.7 KB

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