constant.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. export enum ModelProvider {
  61. GPT = "GPT",
  62. GeminiPro = "GeminiPro",
  63. Claude = "Claude",
  64. }
  65. export const Anthropic = {
  66. ChatPath: "v1/messages",
  67. ChatPath1: "v1/complete",
  68. ExampleEndpoint: "https://api.anthropic.com",
  69. Vision: "2023-06-01",
  70. };
  71. export const OpenaiPath = {
  72. ChatPath: "v1/chat/completions",
  73. UsagePath: "dashboard/billing/usage",
  74. SubsPath: "dashboard/billing/subscription",
  75. ListModelPath: "v1/models",
  76. };
  77. export const Azure = {
  78. ExampleEndpoint: "https://{resource-url}/openai/deployments/{deploy-id}",
  79. };
  80. export const Google = {
  81. ExampleEndpoint: "https://generativelanguage.googleapis.com/",
  82. ChatPath: (modelName: string) => `v1beta/models/${modelName}:generateContent`,
  83. VisionChatPath: (modelName: string) => `v1beta/models/${modelName}:generateContent`,
  84. };
  85. export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
  86. // export const DEFAULT_SYSTEM_TEMPLATE = `
  87. // You are ChatGPT, a large language model trained by {{ServiceProvider}}.
  88. // Knowledge cutoff: {{cutoff}}
  89. // Current model: {{model}}
  90. // Current time: {{time}}
  91. // Latex inline: $x^2$
  92. // Latex block: $$e=mc^2$$
  93. // `;
  94. export const DEFAULT_SYSTEM_TEMPLATE = `
  95. You are ChatGPT, a large language model trained by {{ServiceProvider}}.
  96. Knowledge cutoff: {{cutoff}}
  97. Current model: {{model}}
  98. Current time: {{time}}
  99. Latex inline: \\(x^2\\)
  100. Latex block: $$e=mc^2$$
  101. `;
  102. export const SUMMARIZE_MODEL = "gpt-3.5-turbo";
  103. export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";
  104. export const KnowledgeCutOffDate: Record<string, string> = {
  105. default: "2021-09",
  106. "gpt-4-turbo": "2023-12",
  107. "gpt-4-turbo-2024-04-09": "2023-12",
  108. "gpt-4-turbo-preview": "2023-12",
  109. "gpt-4-1106-preview": "2023-04",
  110. "gpt-4-0125-preview": "2023-12",
  111. "gpt-4-vision-preview": "2023-04",
  112. // After improvements,
  113. // it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously.
  114. "gemini-pro": "2023-12",
  115. "gemini-pro-vision": "2023-12",
  116. };
  117. const openaiModels = [
  118. "gpt-3.5-turbo",
  119. "gpt-3.5-turbo-0301",
  120. "gpt-3.5-turbo-0613",
  121. "gpt-3.5-turbo-1106",
  122. "gpt-3.5-turbo-0125",
  123. "gpt-3.5-turbo-16k",
  124. "gpt-3.5-turbo-16k-0613",
  125. "gpt-4",
  126. "gpt-4-0314",
  127. "gpt-4-0613",
  128. "gpt-4-1106-preview",
  129. "gpt-4-0125-preview",
  130. "gpt-4-32k",
  131. "gpt-4-32k-0314",
  132. "gpt-4-32k-0613",
  133. "gpt-4-turbo",
  134. "gpt-4-turbo-preview",
  135. "gpt-4-vision-preview",
  136. "gpt-4-turbo-2024-04-09",
  137. ];
  138. const googleModels = [
  139. "gemini-1.0-pro",
  140. "gemini-1.5-pro-latest",
  141. "gemini-pro-vision",
  142. ];
  143. const anthropicModels = [
  144. "claude-instant-1.2",
  145. "claude-2.0",
  146. "claude-2.1",
  147. "claude-3-sonnet-20240229",
  148. "claude-3-opus-20240229",
  149. "claude-3-haiku-20240307",
  150. ];
  151. export const DEFAULT_MODELS = [
  152. ...openaiModels.map((name) => ({
  153. name,
  154. available: true,
  155. provider: {
  156. id: "openai",
  157. providerName: "OpenAI",
  158. providerType: "openai",
  159. },
  160. })),
  161. ...googleModels.map((name) => ({
  162. name,
  163. available: true,
  164. provider: {
  165. id: "google",
  166. providerName: "Google",
  167. providerType: "google",
  168. },
  169. })),
  170. ...anthropicModels.map((name) => ({
  171. name,
  172. available: true,
  173. provider: {
  174. id: "anthropic",
  175. providerName: "Anthropic",
  176. providerType: "anthropic",
  177. },
  178. })),
  179. ] as const;
  180. export const CHAT_PAGE_SIZE = 15;
  181. export const MAX_RENDER_MSG_COUNT = 45;
  182. // some famous webdav endpoints
  183. export const internalWhiteWebDavEndpoints = [
  184. "https://dav.jianguoyun.com/dav/",
  185. "https://dav.dropdav.com/",
  186. "https://dav.box.com/dav",
  187. "https://nanao.teracloud.jp/dav/",
  188. "https://webdav.4shared.com/",
  189. "https://dav.idrivesync.com",
  190. "https://webdav.yandex.com",
  191. "https://app.koofr.net/dav/Koofr",
  192. ];