Package com.storedobject.ai
Class ChatConnector
java.lang.Object
com.storedobject.ai.ChatConnector
- All Implemented Interfaces:
JSONService
ChatConnector is a service responsible for managing chat-related actions, including creating
and interacting with chats, listing available topics, and managing chat lifecycle operations.
This class implements the
JSONService
interface and processes specific commands
sent through JSON input to perform its functions so that it can be invoked via SO Connector API.
The supported actions include: - action = "close" - Closing an active chat session. - action = "listTopics" - Listing available chat topics. - action = "chat" - Starting a new chat session or interacting with an ongoing one.The class supports customization of chat behavior by allowing subclasses to override specific methods for creating, customizing, or handling knowledge instances.
- Author:
- Syam
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Knowledge
createKnowledge
(Device device, JSON json, JSONMap result) Creates a Knowledge instance based on the provided device.protected void
Allows customization of the provided Knowledge instance.final void
This method should be implemented to serve the connector API call.protected void
executeAction
(String action, Device device, JSON json, JSONMap result) Executes a specified action on a given device using JSON data, and stores the result in a JSON map.
-
Constructor Details
-
ChatConnector
public ChatConnector()
-
-
Method Details
-
execute
Description copied from interface:JSONService
This method should be implemented to serve the connector API call. It carries out the execution logic of the call.- Specified by:
execute
in interfaceJSONService
- Parameters:
device
- Device on which the call is made.json
- JSON request object received from the device.result
- A JSONMap where response data is inserted. To highlight an error, respond withJSONMap.error(String)
.
-
executeAction
Executes a specified action on a given device using JSON data, and stores the result in a JSON map.- Parameters:
action
- The action to be executed, represented as a string.device
- The device on which the action is to be executed.json
- The JSON data containing parameters or information required to execute the action.result
- The JSON map where the output or result of the action execution will be stored.
-
createKnowledge
Creates a Knowledge instance based on the provided device. This method is typically used to prepare or initialize knowledge associated with a specific device and its context.- Parameters:
device
- The device for which the knowledge is created.json
- The JSON data containing additional parameters or context related to the knowledge creation.result
- A JSON map where any additional information or results related to the knowledge creation might be stored.- Returns:
- The created Knowledge instance associated with the specified device.
-
customize
Allows customization of the provided Knowledge instance. This method can be overridden to perform specific actions or adjustments on the Knowledge object as required by the context or implementation.- Parameters:
knowledge
- The Knowledge instance to be customized. This object may be modified to fulfill specific customization requirements.
-