Commit 7efe8cd6 authored by nanahira's avatar nanahira

fallback to davinci if keys are there

parent c8541e7c
......@@ -30,7 +30,10 @@ export class ChatgptService extends ConsoleLogger {
previousConversation?.account,
failedAccounts,
);
if (!account) {
if (
!account ||
(failedAccounts.length > 1 && (await this.davinciService.isAvailable()))
) {
/*throw new BlankReturnMessageDto(
500,
'No available accounts',
......
......@@ -16,6 +16,15 @@ export class DavinciService extends ConsoleLogger implements OnModuleInit {
this.ChatGPTApiConstructor = ChatGPTAPI;
}
private _isAvailable = false;
async isAvailable() {
if (this._isAvailable) return true;
const keys = await this.keyProvider.get();
if (!keys.length) return false;
this._isAvailable = true;
return true;
}
private pointer = 0;
private async getKey(exclude: string[] = []) {
const excludeSet = new Set(exclude);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment