Class Request

java.lang.Object
com.jackdaw.chatwithnpc.openaiapi.Request

public class Request extends Object
  • Field Details

    • url

      private static String url
  • Constructor Details

    • Request

      public Request()
  • Method Details

    • updateSetting

      public static void updateSetting()
      Update the url setting of the OpenAI API
    • sendRequest

      @NotNull public static @NotNull String sendRequest(@Nullable @Nullable String requestJson, @NotNull @NotNull String routing, @NotNull @NotNull Map<String,String> headers, @NotNull @NotNull Request.Action action) throws Exception
      Send a request to the OpenAI API
      Parameters:
      requestJson - The request to send
      routing - The routing of the request, should like "chat/completions" or "assistants"
      Returns:
      The response from the API in Json format
      Throws:
      Exception - If the request fails
    • getHttpRequestBase

      @NotNull private static @NotNull org.apache.http.client.methods.HttpRequestBase getHttpRequestBase(@NotNull @NotNull String routing, @NotNull @NotNull Map<String,String> headers, @NotNull @NotNull Request.Action action)