constant.ts 9.3 KB

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