merge main

This commit is contained in:
lloydzhou
2024-07-09 16:53:15 +08:00
17 changed files with 708 additions and 8 deletions

23
app/utils/baidu.ts Normal file
View File

@@ -0,0 +1,23 @@
import { BAIDU_OATUH_URL } from "../constant";
/**
* 使用 AKSK 生成鉴权签名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;
}

View File

@@ -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