feat: support baidu model

This commit is contained in:
Dogtiti
2024-07-06 13:05:09 +08:00
parent 2d1f522aaf
commit 785d3748e1
14 changed files with 586 additions and 4 deletions

View File

@@ -14,6 +14,10 @@ export const ANTHROPIC_BASE_URL = "https://api.anthropic.com";
export const GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/";
export const BAIDU_BASE_URL = "https://aip.baidubce.com";
export const BAIDU_OATUH_URL = `${BAIDU_BASE_URL}/oauth/2.0/token`;
export enum Path {
Home = "/",
Chat = "/chat",
@@ -28,6 +32,7 @@ export enum ApiPath {
Azure = "/api/azure",
OpenAI = "/api/openai",
Anthropic = "/api/anthropic",
Baidu = "/api/baidu",
}
export enum SlotID {
@@ -71,12 +76,14 @@ export enum ServiceProvider {
Azure = "Azure",
Google = "Google",
Anthropic = "Anthropic",
Baidu = "Baidu",
}
export enum ModelProvider {
GPT = "GPT",
GeminiPro = "GeminiPro",
Claude = "Claude",
Ernie = "Ernie",
}
export const Anthropic = {
@@ -104,6 +111,12 @@ export const Google = {
ChatPath: (modelName: string) => `v1beta/models/${modelName}:generateContent`,
};
export const Baidu = {
ExampleEndpoint: "https://aip.baidubce.com",
ChatPath: (modelName: string) =>
`/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/${modelName}`,
};
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}}.
@@ -173,6 +186,16 @@ const anthropicModels = [
"claude-3-5-sonnet-20240620",
];
const baiduModels = [
"ernie-4.0-turbo-8k",
"completions_pro=ernie-4.0-8k",
"ernie-4.0-8k-preview",
"completions_adv_pro=ernie-4.0-8k-preview-0518",
"ernie-4.0-8k-latest",
"completions=ernie-3.5-8k",
"ernie-3.5-8k-0205",
];
export const DEFAULT_MODELS = [
...openaiModels.map((name) => ({
name,
@@ -210,6 +233,15 @@ export const DEFAULT_MODELS = [
providerType: "anthropic",
},
})),
...baiduModels.map((name) => ({
name,
available: true,
provider: {
id: "baidu",
providerName: "Baidu",
providerType: "baidu",
},
})),
] as const;
export const CHAT_PAGE_SIZE = 15;