constant.ts 5.8 KB

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