ChatGPT-Next-Web/app/constant.ts

273 lines
6.8 KiB
TypeScript
Raw Normal View History

export const OWNER = "Yidadaa";
export const REPO = "ChatGPT-Next-Web";
export const REPO_URL = `https://github.com/${OWNER}/${REPO}`;
export const ISSUE_URL = `https://github.com/${OWNER}/${REPO}/issues`;
2023-04-06 00:41:44 +08:00
export const UPDATE_URL = `${REPO_URL}#keep-updated`;
export const RELEASE_URL = `${REPO_URL}/releases`;
export const FETCH_COMMIT_URL = `https://api.github.com/repos/${OWNER}/${REPO}/commits?per_page=1`;
2023-03-31 00:46:17 +08:00
export const FETCH_TAG_URL = `https://api.github.com/repos/${OWNER}/${REPO}/tags?per_page=1`;
2023-04-11 01:21:34 +08:00
export const RUNTIME_CONFIG_DOM = "danger-runtime-config";
2023-09-13 02:51:02 +08:00
export const DEFAULT_API_HOST = "https://api.nextchat.dev";
2023-11-08 00:20:34 +08:00
export const OPENAI_BASE_URL = "https://api.openai.com";
2024-04-07 11:32:57 +08:00
export const ANTHROPIC_BASE_URL = "https://api.anthropic.com";
2023-04-21 01:12:39 +08:00
2023-12-24 02:15:30 +08:00
export const GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/";
2024-07-06 13:05:09 +08:00
export const BAIDU_BASE_URL = "https://aip.baidubce.com";
export const BAIDU_OATUH_URL = `${BAIDU_BASE_URL}/oauth/2.0/token`;
2023-04-21 01:12:39 +08:00
export enum Path {
Home = "/",
Chat = "/chat",
Settings = "/settings",
2023-04-24 01:15:44 +08:00
NewChat = "/new-chat",
2023-04-25 00:49:27 +08:00
Masks = "/masks",
2023-06-07 02:18:24 +08:00
Auth = "/auth",
2023-04-24 01:15:44 +08:00
}
2023-09-13 02:51:02 +08:00
export enum ApiPath {
2024-03-14 01:33:41 +08:00
Cors = "",
2024-07-05 19:59:45 +08:00
Azure = "/api/azure",
2023-11-10 02:43:30 +08:00
OpenAI = "/api/openai",
2023-11-07 23:22:11 +08:00
Anthropic = "/api/anthropic",
2024-07-06 13:05:09 +08:00
Baidu = "/api/baidu",
2023-09-13 02:51:02 +08:00
}
2023-04-24 01:15:44 +08:00
export enum SlotID {
AppBody = "app-body",
2023-11-10 02:43:30 +08:00
CustomModel = "custom-model",
2023-04-21 01:12:39 +08:00
}
2023-04-21 02:52:53 +08:00
2023-04-27 01:16:21 +08:00
export enum FileName {
Masks = "masks.json",
Prompts = "prompts.json",
}
2023-04-27 02:00:22 +08:00
export enum StoreKey {
Chat = "chat-next-web-store",
Access = "access-control",
Config = "app-config",
Mask = "mask-store",
Prompt = "prompt-store",
Update = "chat-update",
2023-06-28 00:34:01 +08:00
Sync = "sync",
2023-04-27 02:00:22 +08:00
}
export const DEFAULT_SIDEBAR_WIDTH = 300;
2023-04-21 02:52:53 +08:00
export const MAX_SIDEBAR_WIDTH = 500;
export const MIN_SIDEBAR_WIDTH = 230;
export const NARROW_SIDEBAR_WIDTH = 100;
export const ACCESS_CODE_PREFIX = "nk-";
export const LAST_INPUT_KEY = "last-input";
export const UNFINISHED_INPUT = (id: string) => "unfinished-input-" + id;
2023-05-14 23:00:17 +08:00
2023-09-13 02:51:02 +08:00
export const STORAGE_KEY = "chatgpt-next-web";
2023-05-14 23:00:17 +08:00
export const REQUEST_TIMEOUT_MS = 60000;
2023-05-25 01:04:37 +08:00
export const EXPORT_MESSAGE_CLASS_NAME = "export-markdown";
2023-11-10 02:43:30 +08:00
export enum ServiceProvider {
OpenAI = "OpenAI",
Azure = "Azure",
2023-12-24 02:15:30 +08:00
Google = "Google",
2024-04-07 11:32:57 +08:00
Anthropic = "Anthropic",
2024-07-06 13:05:09 +08:00
Baidu = "Baidu",
2023-12-24 02:15:30 +08:00
}
export enum ModelProvider {
GPT = "GPT",
2023-12-24 04:22:12 +08:00
GeminiPro = "GeminiPro",
2024-04-07 11:32:57 +08:00
Claude = "Claude",
2024-07-06 13:05:09 +08:00
Ernie = "Ernie",
2023-11-10 02:43:30 +08:00
}
2024-04-07 11:32:57 +08:00
export const Anthropic = {
ChatPath: "v1/messages",
ChatPath1: "v1/complete",
ExampleEndpoint: "https://api.anthropic.com",
Vision: "2023-06-01",
};
export const OpenaiPath = {
ChatPath: "v1/chat/completions",
UsagePath: "dashboard/billing/usage",
SubsPath: "dashboard/billing/subscription",
ListModelPath: "v1/models",
};
2023-11-10 02:43:30 +08:00
export const Azure = {
2024-07-05 19:59:45 +08:00
ChatPath: (deployName: string, apiVersion: string) =>
`deployments/${deployName}/chat/completions?api-version=${apiVersion}`,
2023-11-10 02:43:30 +08:00
ExampleEndpoint: "https://{resource-url}/openai/deployments/{deploy-id}",
};
2023-12-24 02:15:30 +08:00
export const Google = {
ExampleEndpoint: "https://generativelanguage.googleapis.com/",
2024-03-28 15:51:06 +08:00
ChatPath: (modelName: string) => `v1beta/models/${modelName}:generateContent`,
2023-12-24 02:15:30 +08:00
};
2024-07-06 13:05:09 +08:00
export const Baidu = {
2024-07-09 12:27:44 +08:00
ExampleEndpoint: BAIDU_BASE_URL,
ChatPath: (modelName: string) => {
let endpoint = modelName;
if (modelName === "ernie-4.0-8k") {
endpoint = "completions_pro";
}
if (modelName === "ernie-4.0-8k-preview-0518") {
endpoint = "completions_adv_pro";
}
if (modelName === "ernie-3.5-8k") {
endpoint = "completions";
}
return `/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/${endpoint}`;
},
2024-07-06 13:05:09 +08:00
};
2023-06-24 16:50:05 +08:00
export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
// export const DEFAULT_SYSTEM_TEMPLATE = `
// You are ChatGPT, a large language model trained by {{ServiceProvider}}.
// Knowledge cutoff: {{cutoff}}
// Current model: {{model}}
// Current time: {{time}}
// Latex inline: $x^2$
// Latex block: $$e=mc^2$$
// `;
2023-06-26 13:18:59 +08:00
export const DEFAULT_SYSTEM_TEMPLATE = `
You are ChatGPT, a large language model trained by {{ServiceProvider}}.
Knowledge cutoff: {{cutoff}}
2023-06-26 13:18:59 +08:00
Current model: {{model}}
Current time: {{time}}
2024-04-09 10:45:09 +08:00
Latex inline: \\(x^2\\)
Latex block: $$e=mc^2$$
`;
export const SUMMARIZE_MODEL = "gpt-3.5-turbo";
2024-02-20 18:04:32 +08:00
export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";
export const KnowledgeCutOffDate: Record<string, string> = {
default: "2021-09",
2024-04-10 17:18:39 +08:00
"gpt-4-turbo": "2023-12",
"gpt-4-turbo-2024-04-09": "2023-12",
2024-02-27 10:28:54 +08:00
"gpt-4-turbo-preview": "2023-12",
2024-05-14 05:28:13 +08:00
"gpt-4o": "2023-10",
"gpt-4o-2024-05-13": "2023-10",
"gpt-4-vision-preview": "2023-04",
// After improvements,
// it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously.
"gemini-pro": "2023-12",
2024-03-28 15:51:06 +08:00
"gemini-pro-vision": "2023-12",
};
2024-04-15 18:14:14 +08:00
const openaiModels = [
"gpt-3.5-turbo",
"gpt-3.5-turbo-1106",
"gpt-3.5-turbo-0125",
"gpt-4",
"gpt-4-0613",
"gpt-4-32k",
"gpt-4-32k-0613",
"gpt-4-turbo",
"gpt-4-turbo-preview",
2024-05-14 05:28:13 +08:00
"gpt-4o",
"gpt-4o-2024-05-13",
2024-04-15 18:14:14 +08:00
"gpt-4-vision-preview",
"gpt-4-turbo-2024-04-09",
2024-07-05 23:56:10 +08:00
"gpt-4-1106-preview",
2024-04-15 18:14:14 +08:00
];
const googleModels = [
"gemini-1.0-pro",
"gemini-1.5-pro-latest",
2024-05-15 15:29:38 +08:00
"gemini-1.5-flash-latest",
2024-04-15 18:14:14 +08:00
"gemini-pro-vision",
];
const anthropicModels = [
"claude-instant-1.2",
"claude-2.0",
"claude-2.1",
"claude-3-sonnet-20240229",
"claude-3-opus-20240229",
"claude-3-haiku-20240307",
"claude-3-5-sonnet-20240620",
2024-04-15 18:14:14 +08:00
];
2024-07-06 13:05:09 +08:00
const baiduModels = [
"ernie-4.0-turbo-8k",
2024-07-09 12:27:44 +08:00
"ernie-4.0-8k",
2024-07-06 13:05:09 +08:00
"ernie-4.0-8k-preview",
2024-07-09 12:27:44 +08:00
"ernie-4.0-8k-preview-0518",
2024-07-06 13:05:09 +08:00
"ernie-4.0-8k-latest",
2024-07-09 12:27:44 +08:00
"ernie-3.5-8k",
2024-07-06 13:05:09 +08:00
"ernie-3.5-8k-0205",
];
export const DEFAULT_MODELS = [
2024-04-15 18:14:14 +08:00
...openaiModels.map((name) => ({
name,
2024-01-26 15:00:02 +08:00
available: true,
provider: {
id: "openai",
providerName: "OpenAI",
providerType: "openai",
},
2024-04-15 18:14:14 +08:00
})),
2024-07-05 19:59:45 +08:00
...openaiModels.map((name) => ({
name,
available: true,
provider: {
id: "azure",
providerName: "Azure",
providerType: "azure",
},
})),
2024-04-15 18:14:14 +08:00
...googleModels.map((name) => ({
name,
2023-12-24 02:15:30 +08:00
available: true,
provider: {
id: "google",
providerName: "Google",
providerType: "google",
},
2024-04-15 18:14:14 +08:00
})),
...anthropicModels.map((name) => ({
name,
2024-02-20 18:04:32 +08:00
available: true,
provider: {
2024-04-07 11:32:57 +08:00
id: "anthropic",
providerName: "Anthropic",
providerType: "anthropic",
2024-02-20 18:04:32 +08:00
},
2024-04-15 18:14:14 +08:00
})),
2024-07-06 13:05:09 +08:00
...baiduModels.map((name) => ({
name,
available: true,
provider: {
id: "baidu",
providerName: "Baidu",
providerType: "baidu",
},
})),
] as const;
2023-08-04 19:24:10 +08:00
export const CHAT_PAGE_SIZE = 15;
export const MAX_RENDER_MSG_COUNT = 45;
2024-04-09 18:05:56 +08:00
// some famous webdav endpoints
export const internalAllowedWebDavEndpoints = [
"https://dav.jianguoyun.com/dav/",
"https://dav.dropdav.com/",
"https://dav.box.com/dav",
"https://nanao.teracloud.jp/dav/",
"https://bora.teracloud.jp/dav/",
"https://webdav.4shared.com/",
"https://dav.idrivesync.com",
"https://webdav.yandex.com",
"https://app.koofr.net/dav/Koofr",
];