constant.ts 6.5 KB

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