constant.ts 8.4 KB

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