constant.ts 5.8 KB

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