constant.ts 9.2 KB

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