Class Request
java.lang.Object
com.jackdaw.chatwithnpc.openaiapi.Request
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static @NotNull org.apache.http.client.methods.HttpRequestBase
getHttpRequestBase
(@NotNull String routing, @NotNull Map<String, String> headers, @NotNull Request.Action action) static @NotNull String
sendRequest
(@Nullable String requestJson, @NotNull String routing, @NotNull Map<String, String> headers, @NotNull Request.Action action) Send a request to the OpenAI APIstatic void
Update the url setting of the OpenAI API
-
Field Details
-
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 ExceptionSend a request to the OpenAI API- Parameters:
requestJson
- The request to sendrouting
- 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)
-