constant.ts 6.3 KB

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