mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-08 16:15:50 +08:00
merge main
This commit is contained in:
23
app/utils/baidu.ts
Normal file
23
app/utils/baidu.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { BAIDU_OATUH_URL } from "../constant";
|
||||
/**
|
||||
* 使用 AK,SK 生成鉴权签名(Access Token)
|
||||
* @return 鉴权签名信息
|
||||
*/
|
||||
export async function getAccessToken(
|
||||
clientId: string,
|
||||
clientSecret: string,
|
||||
): Promise<{
|
||||
access_token: string;
|
||||
expires_in: number;
|
||||
error?: number;
|
||||
}> {
|
||||
const res = await fetch(
|
||||
`${BAIDU_OATUH_URL}?grant_type=client_credentials&client_id=${clientId}&client_secret=${clientSecret}`,
|
||||
{
|
||||
method: "POST",
|
||||
mode: "cors",
|
||||
},
|
||||
);
|
||||
const resJson = await res.json();
|
||||
return resJson;
|
||||
}
|
@@ -47,11 +47,16 @@ export function collectModelTable(
|
||||
(model) => (model.available = available),
|
||||
);
|
||||
} else {
|
||||
// 1. find model by name(), and set available value
|
||||
// 1. find model by name, and set available value
|
||||
const [customModelName, customProviderName] = name.split("@");
|
||||
let count = 0;
|
||||
for (const fullName in modelTable) {
|
||||
const [modelName, providerName] = fullName.split("@");
|
||||
if (modelName === name) {
|
||||
if (
|
||||
customModelName == modelName &&
|
||||
(customProviderName === undefined ||
|
||||
customProviderName === providerName)
|
||||
) {
|
||||
count += 1;
|
||||
modelTable[fullName]["available"] = available;
|
||||
// swap name and displayName for bytedance
|
||||
|
Reference in New Issue
Block a user