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