From 26a89a89db52bf367d4f2f5511398973799a9759 Mon Sep 17 00:00:00 2001 From: xiang <1984871009@qq.com> Date: Sun, 7 May 2023 19:34:12 +0800 Subject: [PATCH] feat: default resign --- README.md | 4 ++-- model/forefront/index.ts | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 97a513f..b51bf9d 100644 --- a/README.md +++ b/README.md @@ -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" diff --git a/model/forefront/index.ts b/model/forefront/index.ts index 90f27ee..c86624a 100644 --- a/model/forefront/index.ts +++ b/model/forefront/index.ts @@ -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 { - 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}; } }