Handle 5xx errors by repeating requests

the number of tries is stored in the extension of the array class
the shift method is extended to reset the number of tries
on the queue shift.

also I accidently refactored types in execution.ts
there were duplicate types declared

fixes #9
This commit is contained in:
Wroclaw 2023-07-31 21:44:03 +02:00
parent 853bf183ee
commit d9a97cce8d
2 changed files with 22 additions and 11 deletions

View file

@ -4,14 +4,14 @@ import FoldToAscii from "fold-to-ascii";
import config from "./config";
import countTokens from "./tokenCounter";
import { request } from "./execution";
import { RequestMessage } from "./execution";
/**
* formats the request to use as a message contend in OpenAI api
* @param request the request to format
* @returns the formatted request
*/
export async function formatRequestOrResponse(request: request | InteractionResponse): Promise<string> {
export async function formatRequestOrResponse(request: RequestMessage | InteractionResponse): Promise<string> {
if (request instanceof DiscordMessage) {
return formatMessage(request);
}