feat: default resign

このコミットが含まれているのは:
xiang 2023-05-07 19:34:12 +08:00
コミット 26a89a89db
2個のファイルの変更10行の追加7行の削除

ファイルの表示

@ -62,7 +62,7 @@ resignup?: number; // default 0 if set 1, auto sign up when gpt4 times use up
common request
```shell
# test default model chat.forefront.at
curl "http://127.0.0.1:3000/ask?prompt=hello&model=forefront&gptmodel=gpt-4&resignup=0"
curl "http://127.0.0.1:3000/ask?prompt=hello&model=forefront&gptmodel=gpt-4&resignup=1"
# test you.com
curl "http://127.0.0.1:3000/ask?prompt=hello&model=you"
@ -71,7 +71,7 @@ curl "http://127.0.0.1:3000/ask?prompt=hello&model=you"
request event-stream
```shell
# test default model chat.forefront.at
curl "http://127.0.0.1:3000/ask/stream?prompt=hello&model=forefront&gptmodel=gpt-4&resignup=0"
curl "http://127.0.0.1:3000/ask/stream?prompt=hello&model=forefront&gptmodel=gpt-4&resignup=1"
# test you
curl "http://127.0.0.1:3000/ask/stream?prompt=hello&model=you"

ファイルの表示

@ -137,7 +137,10 @@ export class Forefront extends Chat {
return;
}
if (str.indexOf('event: error') !== -1) {
cb(null, 'GPT-4 rate limit exceeded (>5 messages every 3 hours). Time remaining: 180 minutes; try set resignup=true in query')
cb(null, 'GPT-4 rate limit exceeded (>5 messages every 3 hours). Time remaining: 180 minutes; try set resignup=1 in query')
if (+resignup) {
this.client = undefined;
}
return;
}
const data = parseJSON(str, {}) as ChatCompletionChunk;
@ -156,7 +159,7 @@ export class Forefront extends Chat {
// do not retry auto, avoid loss control
throw new Error('retry again, will sign up again');
}
throw new Error('try change model to gpt-3.5-turbo or set resignup = true')
throw new Error('try change model to gpt-3.5-turbo or set resignup=1')
}
throw e;
} finally {
@ -167,7 +170,7 @@ export class Forefront extends Chat {
this.client = undefined;
this.gpt4times = 0;
} else {
throw new Error('try set resignup=true in query');
throw new Error('try set resignup=1 in query');
}
}
}
@ -199,7 +202,7 @@ export class Forefront extends Chat {
}
async createToken(): Promise<ForefrontSessionInfo> {
const mailbox = CreateEmail(TempEmailType.TempEmail44);
const mailbox = CreateEmail(TempEmailType.TempEmail);
const mailAddress = await mailbox.getMailAddress();
const agent = new UserAgent().toString();
const session = new tlsClient.Session({clientIdentifier: 'chrome_108'});
@ -251,7 +254,7 @@ export class Forefront extends Chat {
} catch (e) {
console.error(e);
}
}, 30 * 1000);
}, 50 * 1000);
return {token, agent, sessionID, userID};
}
}