Class OpenaiServlet
java.lang.Object
com.qubitpi.chatbotws.web.endpoints.OpenaiServlet
@Singleton
@Immutable
@ThreadSafe
@Path("/openai")
@Produces("application/json")
public class OpenaiServlet
extends Object
Endpoint that delegates chatbot to OpenAI API.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
OpenaiServlet
@Inject public OpenaiServlet()Constructor for dependency injection.
-
-
Method Details
-
chat
@POST @Path("/chat") @Consumes("application/json") @Produces("application/json") public jakarta.ws.rs.core.Response chat(@NotNull @NotNull Map<String, String> payload) throws IOException, InterruptedExceptionChatbot endpoint.- Parameters:
payload
- A JSON object containing amessage
field which contains the message sent to ask the bot.- Returns:
- 200 OK response with the chatbot's response message
- Throws:
IOException
- if an I/ O error occurs when sending or receiving from the OpenAIInterruptedException
- if the OpenAI request is interrupted
-