constant.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. import { stabilityRequestCall } from "@/app/store/sd";
  2. export const OWNER = "Yidadaa";
  3. export const REPO = "ChatGPT-Next-Web";
  4. export const REPO_URL = `https://github.com/${OWNER}/${REPO}`;
  5. export const ISSUE_URL = `https://github.com/${OWNER}/${REPO}/issues`;
  6. export const UPDATE_URL = `${REPO_URL}#keep-updated`;
  7. export const RELEASE_URL = `${REPO_URL}/releases`;
  8. export const FETCH_COMMIT_URL = `https://api.github.com/repos/${OWNER}/${REPO}/commits?per_page=1`;
  9. export const FETCH_TAG_URL = `https://api.github.com/repos/${OWNER}/${REPO}/tags?per_page=1`;
  10. export const RUNTIME_CONFIG_DOM = "danger-runtime-config";
  11. export const DEFAULT_API_HOST = "https://api.nextchat.dev";
  12. export const OPENAI_BASE_URL = "https://api.openai.com";
  13. export const ANTHROPIC_BASE_URL = "https://api.anthropic.com";
  14. export const GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/";
  15. export const STABILITY_BASE_URL = "https://api.stability.ai";
  16. export enum Path {
  17. Home = "/",
  18. Chat = "/chat",
  19. Settings = "/settings",
  20. NewChat = "/new-chat",
  21. Masks = "/masks",
  22. Auth = "/auth",
  23. Sd = "/sd",
  24. SdPanel = "/sd-panel",
  25. }
  26. export enum ApiPath {
  27. Cors = "",
  28. OpenAI = "/api/openai",
  29. Anthropic = "/api/anthropic",
  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. SdList = "sd-list",
  48. }
  49. export const DEFAULT_SIDEBAR_WIDTH = 300;
  50. export const MAX_SIDEBAR_WIDTH = 500;
  51. export const MIN_SIDEBAR_WIDTH = 230;
  52. export const NARROW_SIDEBAR_WIDTH = 100;
  53. export const ACCESS_CODE_PREFIX = "nk-";
  54. export const LAST_INPUT_KEY = "last-input";
  55. export const UNFINISHED_INPUT = (id: string) => "unfinished-input-" + id;
  56. export const STORAGE_KEY = "chatgpt-next-web";
  57. export const REQUEST_TIMEOUT_MS = 60000;
  58. export const EXPORT_MESSAGE_CLASS_NAME = "export-markdown";
  59. export enum ServiceProvider {
  60. OpenAI = "OpenAI",
  61. Azure = "Azure",
  62. Google = "Google",
  63. Anthropic = "Anthropic",
  64. }
  65. export enum ModelProvider {
  66. GPT = "GPT",
  67. GeminiPro = "GeminiPro",
  68. Claude = "Claude",
  69. Stability = "Stability",
  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. ExampleEndpoint: "https://{resource-url}/openai/deployments/{deploy-id}",
  85. };
  86. export const Google = {
  87. ExampleEndpoint: "https://generativelanguage.googleapis.com/",
  88. ChatPath: (modelName: string) => `v1beta/models/${modelName}:generateContent`,
  89. };
  90. export const StabilityPath = {
  91. GeneratePath: "v2beta/stable-image/generate",
  92. };
  93. export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
  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 DEFAULT_SYSTEM_TEMPLATE = `
  103. You are ChatGPT, a large language model trained by {{ServiceProvider}}.
  104. Knowledge cutoff: {{cutoff}}
  105. Current model: {{model}}
  106. Current time: {{time}}
  107. Latex inline: \\(x^2\\)
  108. Latex block: $$e=mc^2$$
  109. `;
  110. export const SUMMARIZE_MODEL = "gpt-3.5-turbo";
  111. export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";
  112. export const KnowledgeCutOffDate: Record<string, string> = {
  113. default: "2021-09",
  114. "gpt-4-turbo": "2023-12",
  115. "gpt-4-turbo-2024-04-09": "2023-12",
  116. "gpt-4-turbo-preview": "2023-12",
  117. "gpt-4o": "2023-10",
  118. "gpt-4o-2024-05-13": "2023-10",
  119. "gpt-4-vision-preview": "2023-04",
  120. // After improvements,
  121. // it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously.
  122. "gemini-pro": "2023-12",
  123. "gemini-pro-vision": "2023-12",
  124. };
  125. const openaiModels = [
  126. "gpt-3.5-turbo",
  127. "gpt-3.5-turbo-1106",
  128. "gpt-3.5-turbo-0125",
  129. "gpt-4",
  130. "gpt-4-0613",
  131. "gpt-4-32k",
  132. "gpt-4-32k-0613",
  133. "gpt-4-turbo",
  134. "gpt-4-turbo-preview",
  135. "gpt-4o",
  136. "gpt-4o-2024-05-13",
  137. "gpt-4-vision-preview",
  138. "gpt-4-turbo-2024-04-09",
  139. ];
  140. const googleModels = [
  141. "gemini-1.0-pro",
  142. "gemini-1.5-pro-latest",
  143. "gemini-1.5-flash-latest",
  144. "gemini-pro-vision",
  145. ];
  146. const anthropicModels = [
  147. "claude-instant-1.2",
  148. "claude-2.0",
  149. "claude-2.1",
  150. "claude-3-sonnet-20240229",
  151. "claude-3-opus-20240229",
  152. "claude-3-haiku-20240307",
  153. ];
  154. export const DEFAULT_MODELS = [
  155. ...openaiModels.map((name) => ({
  156. name,
  157. available: true,
  158. provider: {
  159. id: "openai",
  160. providerName: "OpenAI",
  161. providerType: "openai",
  162. },
  163. })),
  164. ...googleModels.map((name) => ({
  165. name,
  166. available: true,
  167. provider: {
  168. id: "google",
  169. providerName: "Google",
  170. providerType: "google",
  171. },
  172. })),
  173. ...anthropicModels.map((name) => ({
  174. name,
  175. available: true,
  176. provider: {
  177. id: "anthropic",
  178. providerName: "Anthropic",
  179. providerType: "anthropic",
  180. },
  181. })),
  182. ] as const;
  183. export const CHAT_PAGE_SIZE = 15;
  184. export const MAX_RENDER_MSG_COUNT = 45;
  185. // some famous webdav endpoints
  186. export const internalAllowedWebDavEndpoints = [
  187. "https://dav.jianguoyun.com/dav/",
  188. "https://dav.dropdav.com/",
  189. "https://dav.box.com/dav",
  190. "https://nanao.teracloud.jp/dav/",
  191. "https://bora.teracloud.jp/dav/",
  192. "https://webdav.4shared.com/",
  193. "https://dav.idrivesync.com",
  194. "https://webdav.yandex.com",
  195. "https://app.koofr.net/dav/Koofr",
  196. ];
  197. export const PLUGINS = [{ name: "Stable Diffusion", path: Path.Sd }];