fix: apikey

This commit is contained in:
archer
2023-06-25 13:20:00 +08:00
parent cfb31afbd9
commit 426176db47
3 changed files with 22 additions and 16 deletions

View File

@@ -39,7 +39,12 @@ export async function openaiEmbedding({
input,
mustPay = false
}: { userId: string; mustPay?: boolean } & Props) {
const apiKey = getSystemOpenAiKey();
const { userOpenAiKey, systemAuthKey } = await getApiKey({
model: 'gpt-3.5-turbo',
userId,
mustPay
});
const apiKey = userOpenAiKey || systemAuthKey;
// 获取 chatAPI
const chatAPI = getOpenAIApi(apiKey);
@@ -68,7 +73,7 @@ export async function openaiEmbedding({
});
pushGenerateVectorBill({
isPay: mustPay,
isPay: !userOpenAiKey,
userId,
text: input.join(''),
tokenLen: result.tokenLen