Skip to content

Commit

Permalink
restructure with memory as higher-level term
Browse files Browse the repository at this point in the history
Signed-off-by: HenryL27 <[email protected]>
  • Loading branch information
HenryL27 committed Aug 29, 2023
1 parent 92328e8 commit f683ac9
Show file tree
Hide file tree
Showing 68 changed files with 216 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.common.conversational;
package org.opensearch.ml.common.conversation;

/**
* Constants for conversational actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.common.conversational;
package org.opensearch.ml.common.conversation;

import java.io.IOException;
import java.time.Instant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.common.conversational;
package org.opensearch.ml.common.conversation;

/**
* Class containing a bunch of constant defining how the conversational indices are formatted
Expand All @@ -42,7 +42,7 @@ public class ConversationalIndexConstants {
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ META_CREATED_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_optional_time||epoch_millis\"},\n"
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ " \""
+ USER_FIELD
+ "\": {\"type\": \"keyword\"}\n"
Expand Down Expand Up @@ -78,7 +78,7 @@ public class ConversationalIndexConstants {
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ INTERACTIONS_TIMESTAMP_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_optional_time||epoch_millis\"},\n"
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ " \""
+ INTERACTIONS_INPUT_FIELD
+ "\": {\"type\": \"text\"},\n"
Expand All @@ -93,10 +93,7 @@ public class ConversationalIndexConstants {
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ INTERACTIONS_METADATA_FIELD
+ "\": {\"type\": \"text\"},\n"
+ " \""
+ USER_FIELD
+ "\": {\"type\": \"keyword\"}\n"
+ "\": {\"type\": \"text\"}\n"
+ " }\n"
+ "}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.common.conversational;
package org.opensearch.ml.common.conversation;

import java.io.IOException;
import java.time.Instant;
Expand Down Expand Up @@ -68,9 +68,9 @@ public static Interaction fromMap(String id, Map<String, Object> fields) {
String input = (String) fields.get(ConversationalIndexConstants.INTERACTIONS_INPUT_FIELD);
String promptTemplate = (String) fields.get(ConversationalIndexConstants.INTERACTIONS_PROMPT_TEMPLATE_FIELD);
String response = (String) fields.get(ConversationalIndexConstants.INTERACTIONS_RESPONSE_FIELD);
String agent = (String) fields.get(ConversationalIndexConstants.INTERACTIONS_ORIGIN_FIELD);
String origin = (String) fields.get(ConversationalIndexConstants.INTERACTIONS_ORIGIN_FIELD);
String metadata = (String) fields.get(ConversationalIndexConstants.INTERACTIONS_METADATA_FIELD);
return new Interaction(id, timestamp, conversationId, input, promptTemplate, response, agent, metadata);
return new Interaction(id, timestamp, conversationId, input, promptTemplate, response, origin, metadata);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational;
package org.opensearch.ml.memory;

import java.util.List;

import org.opensearch.common.action.ActionFuture;
import org.opensearch.core.action.ActionListener;
import org.opensearch.ml.common.conversational.ConversationMeta;
import org.opensearch.ml.common.conversational.Interaction;
import org.opensearch.ml.common.conversational.Interaction.InteractionBuilder;
import org.opensearch.ml.common.conversation.ConversationMeta;
import org.opensearch.ml.common.conversation.Interaction;
import org.opensearch.ml.common.conversation.Interaction.InteractionBuilder;

/**
* Interface for handling all Conversational Memory operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.conversation;
package org.opensearch.ml.memory.action.conversation;

import org.opensearch.action.ActionType;

Expand All @@ -26,7 +26,7 @@ public class CreateConversationAction extends ActionType<CreateConversationRespo
/** Instance of this */
public static final CreateConversationAction INSTANCE = new CreateConversationAction();
/** Name of this action */
public static final String NAME = "cluster:admin/opensearch/ml/conversational/conversation/create";
public static final String NAME = "cluster:admin/opensearch/ml/memory/conversation/create";

private CreateConversationAction() {
super(NAME, CreateConversationResponse::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.conversation;
package org.opensearch.ml.memory.action.conversation;

import java.io.IOException;
import java.util.Map;
Expand All @@ -24,7 +24,7 @@
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.ml.common.conversational.ActionConstants;
import org.opensearch.ml.common.conversation.ActionConstants;
import org.opensearch.rest.RestRequest;

import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.conversation;
package org.opensearch.ml.memory.action.conversation;

import java.io.IOException;

Expand All @@ -25,7 +25,7 @@
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.ml.common.conversational.ActionConstants;
import org.opensearch.ml.common.conversation.ActionConstants;

import lombok.AllArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.conversation;
package org.opensearch.ml.memory.action.conversation;

import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.HandledTransportAction;
import org.opensearch.client.Client;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.core.action.ActionListener;
import org.opensearch.ml.conversational.ConversationalMemoryHandler;
import org.opensearch.ml.conversational.index.OpenSearchConversationalMemoryHandler;
import org.opensearch.ml.memory.ConversationalMemoryHandler;
import org.opensearch.ml.memory.index.OpenSearchConversationalMemoryHandler;
import org.opensearch.tasks.Task;
import org.opensearch.transport.TransportService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.interaction;
package org.opensearch.ml.memory.action.conversation;

import org.opensearch.action.ActionType;

Expand All @@ -26,7 +26,7 @@ public class CreateInteractionAction extends ActionType<CreateInteractionRespons
/** Instance of this */
public static CreateInteractionAction INSTANCE = new CreateInteractionAction();
/** Name of this action */
public static final String NAME = "cluster:admin/opensearch/ml/conversational/interaction/create";
public static final String NAME = "cluster:admin/opensearch/ml/memory/interaction/create";

private CreateInteractionAction() {
super(NAME, CreateInteractionResponse::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.interaction;
package org.opensearch.ml.memory.action.conversation;

import static org.opensearch.action.ValidateActions.addValidationError;

Expand All @@ -26,7 +26,7 @@
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.ml.common.conversational.ActionConstants;
import org.opensearch.ml.common.conversation.ActionConstants;
import org.opensearch.rest.RestRequest;

import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.interaction;
package org.opensearch.ml.memory.action.conversation;

import java.io.IOException;

Expand All @@ -24,7 +24,7 @@
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.ml.common.conversational.ActionConstants;
import org.opensearch.ml.common.conversation.ActionConstants;

import lombok.AllArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.interaction;
package org.opensearch.ml.memory.action.conversation;

import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.HandledTransportAction;
import org.opensearch.client.Client;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.core.action.ActionListener;
import org.opensearch.ml.conversational.ConversationalMemoryHandler;
import org.opensearch.ml.conversational.index.OpenSearchConversationalMemoryHandler;
import org.opensearch.ml.memory.ConversationalMemoryHandler;
import org.opensearch.ml.memory.index.OpenSearchConversationalMemoryHandler;
import org.opensearch.tasks.Task;
import org.opensearch.transport.TransportService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.conversation;
package org.opensearch.ml.memory.action.conversation;

import org.opensearch.action.ActionType;

Expand All @@ -26,7 +26,7 @@ public class DeleteConversationAction extends ActionType<DeleteConversationRespo
/** Instance of this */
public static final DeleteConversationAction INSTANCE = new DeleteConversationAction();
/** Name of this action */
public static final String NAME = "cluster:admin/opensearch/ml/conversational/conversation/delete";
public static final String NAME = "cluster:admin/opensearch/ml/memory/conversation/delete";

private DeleteConversationAction() {
super(NAME, DeleteConversationResponse::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.conversation;
package org.opensearch.ml.memory.action.conversation;

import static org.opensearch.action.ValidateActions.addValidationError;

Expand All @@ -25,7 +25,7 @@
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.ml.common.conversational.ActionConstants;
import org.opensearch.ml.common.conversation.ActionConstants;
import org.opensearch.rest.RestRequest;

import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.conversation;
package org.opensearch.ml.memory.action.conversation;

import java.io.IOException;

Expand All @@ -24,7 +24,7 @@
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.ml.common.conversational.ActionConstants;
import org.opensearch.ml.common.conversation.ActionConstants;

import lombok.AllArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.conversation;
package org.opensearch.ml.memory.action.conversation;

import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.HandledTransportAction;
import org.opensearch.client.Client;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.core.action.ActionListener;
import org.opensearch.ml.conversational.ConversationalMemoryHandler;
import org.opensearch.ml.conversational.index.OpenSearchConversationalMemoryHandler;
import org.opensearch.ml.memory.ConversationalMemoryHandler;
import org.opensearch.ml.memory.index.OpenSearchConversationalMemoryHandler;
import org.opensearch.tasks.Task;
import org.opensearch.transport.TransportService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.conversation;
package org.opensearch.ml.memory.action.conversation;

import org.opensearch.action.ActionType;

Expand All @@ -26,7 +26,7 @@ public class GetConversationsAction extends ActionType<GetConversationsResponse>
/** Instance of this */
public static final GetConversationsAction INSTANCE = new GetConversationsAction();
/** Name of this action */
public static final String NAME = "cluster:admin/opensearch/ml/conversational/conversation/list";
public static final String NAME = "cluster:admin/opensearch/ml/memory/conversation/list";

private GetConversationsAction() {
super(NAME, GetConversationsResponse::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.conversation;
package org.opensearch.ml.memory.action.conversation;

import static org.opensearch.action.ValidateActions.addValidationError;

Expand All @@ -25,7 +25,7 @@
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.ml.common.conversational.ActionConstants;
import org.opensearch.ml.common.conversation.ActionConstants;
import org.opensearch.rest.RestRequest;

import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.conversation;
package org.opensearch.ml.memory.action.conversation;

import java.io.IOException;
import java.util.List;
Expand All @@ -26,8 +26,8 @@
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.ml.common.conversational.ActionConstants;
import org.opensearch.ml.common.conversational.ConversationMeta;
import org.opensearch.ml.common.conversation.ActionConstants;
import org.opensearch.ml.common.conversation.ConversationMeta;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.opensearch.ml.conversational.action.memory.conversation;
package org.opensearch.ml.memory.action.conversation;

import java.util.List;

Expand All @@ -25,9 +25,9 @@
import org.opensearch.common.inject.Inject;
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.core.action.ActionListener;
import org.opensearch.ml.common.conversational.ConversationMeta;
import org.opensearch.ml.conversational.ConversationalMemoryHandler;
import org.opensearch.ml.conversational.index.OpenSearchConversationalMemoryHandler;
import org.opensearch.ml.common.conversation.ConversationMeta;
import org.opensearch.ml.memory.ConversationalMemoryHandler;
import org.opensearch.ml.memory.index.OpenSearchConversationalMemoryHandler;
import org.opensearch.tasks.Task;
import org.opensearch.transport.TransportService;

Expand Down
Loading

0 comments on commit f683ac9

Please sign in to comment.