constant.ts 9.2 KB

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