Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#283 from Yidadaa/fix-credit-cache
Browse files Browse the repository at this point in the history
fix: ChatGPTNextWeb#277 no cache for credit query
  • Loading branch information
Yidadaa authored Mar 31, 2023
2 parents 66dae01 + 560fa54 commit a266bb8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const makeRequestParam = (
options?: {
filterBot?: boolean;
stream?: boolean;
},
}
): ChatRequest => {
let sendMessages = messages.map((v) => ({
role: v.role,
Expand Down Expand Up @@ -69,10 +69,9 @@ export async function requestChat(messages: Message[]) {
}

export async function requestUsage() {
const res = await requestOpenaiClient("dashboard/billing/credit_grants")(
null,
"GET",
);
const res = await requestOpenaiClient(
"dashboard/billing/credit_grants?_vercel_no_cache=1"
)(null, "GET");

try {
const response = (await res.json()) as {
Expand All @@ -94,7 +93,7 @@ export async function requestChatStream(
onMessage: (message: string, done: boolean) => void;
onError: (error: Error) => void;
onController?: (controller: AbortController) => void;
},
}
) {
const req = makeRequestParam(messages, {
stream: true,
Expand Down Expand Up @@ -189,7 +188,7 @@ export const ControllerPool = {
addController(
sessionIndex: number,
messageIndex: number,
controller: AbortController,
controller: AbortController
) {
const key = this.key(sessionIndex, messageIndex);
this.controllers[key] = controller;
Expand Down

0 comments on commit a266bb8

Please sign in to comment.