Class ChatController

java.lang.Object
com.masai.controller.ChatController

@RestController public class ChatController extends Object
The ChatController class is a Spring RestController responsible for handling HTTP requests related to the chat functionality in the ChatBotSpringAI application. This controller acts as an interface between the client making requests to the "/mychat" endpoint and the OpenAiService that handles the actual chatbot interactions using the OpenAI API.
Since:
2023-08-05
Version:
1.0
See Also:
  • Constructor Details

    • ChatController

      public ChatController()
  • Method Details

    • openAiHandler

      @GetMapping("/mychat") public String openAiHandler(@RequestParam("userInput") String userInput)
      Handles HTTP GET requests to "/mychat" endpoint. This method receives user input as a request parameter and delegates the processing to the OpenAiService. The OpenAiService is responsible for invoking the OpenAI's ChatGPT API to generate a response based on the user input and return it to the client.
      Parameters:
      userInput - The text input provided by the user in the "userInput" request parameter.
      Returns:
      String - The response generated by the OpenAI service for the given user input.