constant.ts 9.1 KB

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