Function sendChatRequest

  • Sends a chat request to the OpenAI API. This function first calculates the number of tokens in the request and determines the appropriate GPT model to use based on the token count. If the request is too large, the function will exit and prompt the user to try again with a smaller request. If the request is within the acceptable token range, the function will send the request to the OpenAI API using the selected GPT model. The function then counts the tokens in the response and returns the response. Exits the process if the request is too large.

    Parameters

    • options: ISendChatRequestOptions

      The options for the chat request. This includes the maximum expected response tokens and the request itself.

    Returns Promise<string>

    A promise that resolves to the response from the OpenAI API.

Generated using TypeDoc