Package com.masai.service
Class OpenAiService
java.lang.Object
com.masai.service.OpenAiService
The OpenAiService class is a Spring Service responsible for interacting with
the OpenAI's ChatGPT API and processing chatbot interactions.
This service class is an essential component of the ChatBotSpringAI
application, as it encapsulates the logic for making HTTP requests to the
OpenAI API, handling responses, and extracting relevant information to
provide intelligent chatbot responses.
- Since:
- 2023-08-05
- Version:
- 1.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionOpenAiServiceCall
(String userInput) Handles the chatbot interaction with the OpenAI's ChatGPT API based on the user input.
-
Constructor Details
-
OpenAiService
public OpenAiService()
-
-
Method Details
-
OpenAiServiceCall
Handles the chatbot interaction with the OpenAI's ChatGPT API based on the user input. This method constructs the HTTP request payload with user input and authorization headers, then sends the request to the OpenAI API. It retrieves the response from the API and extracts the relevant content using JsonPath to provide an intelligent chatbot response.- Parameters:
userInput
- The text input provided by the user.- Returns:
- String - The response generated by the OpenAI API for the given user input.
-