constant.ts 8.0 KB

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