constant.ts 7.4 KB

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