constant.ts 8.3 KB

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