-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement] Fetch system index mappings from json file instead of string constants #3153
Changes from all commits
18eedf6
7068729
abd4b25
d2f3c0e
fa81560
63a6d62
8cbaf01
3423026
67a1810
63bc70d
88673ed
56d945b
4ea99ea
ce72e53
e714c35
d50a9f9
86d2b76
1cd16b2
369475d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,15 +18,15 @@ | |
package org.opensearch.ml.common.conversation; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @austintlee @HenryL27 I have also modified this class to use the MLIndex enum, please review the same. I didn't want to do a full refactor for now as it may impact functionality. Added as a todo on top of the class. |
||
|
||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.ml.common.MLIndex; | ||
|
||
/** | ||
* Class containing a bunch of constant defining how the conversational indices are formatted | ||
* ToDo: use MLIndex.MEMORY_MESSAGE and MLIndex.MEMORY_META directly for index names and mappings rather than constants | ||
*/ | ||
public class ConversationalIndexConstants { | ||
/** Version of the meta index schema */ | ||
public final static Integer META_INDEX_SCHEMA_VERSION = 2; | ||
/** Name of the conversational metadata index */ | ||
public final static String META_INDEX_NAME = ".plugins-ml-memory-meta"; | ||
public final static String META_INDEX_NAME = MLIndex.MEMORY_META.getIndexName(); | ||
/** Name of the metadata field for initial timestamp */ | ||
public final static String META_CREATED_TIME_FIELD = "create_time"; | ||
/** Name of the metadata field for updated timestamp */ | ||
|
@@ -41,38 +41,10 @@ public class ConversationalIndexConstants { | |
public final static String META_ADDITIONAL_INFO_FIELD = "additional_info"; | ||
|
||
/** Mappings for the conversational metadata index */ | ||
public final static String META_MAPPING = "{\n" | ||
+ " \"_meta\": {\n" | ||
+ " \"schema_version\": " | ||
+ META_INDEX_SCHEMA_VERSION | ||
+ "\n" | ||
+ " },\n" | ||
+ " \"properties\": {\n" | ||
+ " \"" | ||
+ META_NAME_FIELD | ||
+ "\": {\"type\": \"text\"},\n" | ||
+ " \"" | ||
+ META_CREATED_TIME_FIELD | ||
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n" | ||
+ " \"" | ||
+ META_UPDATED_TIME_FIELD | ||
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n" | ||
+ " \"" | ||
+ USER_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ APPLICATION_TYPE_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ META_ADDITIONAL_INFO_FIELD | ||
+ "\": {\"type\": \"flat_object\"}\n" | ||
+ " }\n" | ||
+ "}"; | ||
public final static String META_MAPPING = MLIndex.MEMORY_META.getMapping(); | ||
|
||
/** Version of the interactions index schema */ | ||
public final static Integer INTERACTIONS_INDEX_SCHEMA_VERSION = 1; | ||
/** Name of the conversational interactions index */ | ||
public final static String INTERACTIONS_INDEX_NAME = ".plugins-ml-memory-message"; | ||
public final static String INTERACTIONS_INDEX_NAME = MLIndex.MEMORY_MESSAGE.getIndexName(); | ||
/** Name of the interaction field for the conversation Id */ | ||
public final static String INTERACTIONS_CONVERSATION_ID_FIELD = "memory_id"; | ||
/** Name of the interaction field for the human input */ | ||
|
@@ -92,42 +64,7 @@ public class ConversationalIndexConstants { | |
/** The trace number of an interaction */ | ||
public final static String INTERACTIONS_TRACE_NUMBER_FIELD = "trace_number"; | ||
/** Mappings for the interactions index */ | ||
public final static String INTERACTIONS_MAPPINGS = "{\n" | ||
+ " \"_meta\": {\n" | ||
+ " \"schema_version\": " | ||
+ INTERACTIONS_INDEX_SCHEMA_VERSION | ||
+ "\n" | ||
+ " },\n" | ||
+ " \"properties\": {\n" | ||
+ " \"" | ||
+ INTERACTIONS_CONVERSATION_ID_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ INTERACTIONS_CREATE_TIME_FIELD | ||
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n" | ||
+ " \"" | ||
+ INTERACTIONS_INPUT_FIELD | ||
+ "\": {\"type\": \"text\"},\n" | ||
+ " \"" | ||
+ INTERACTIONS_PROMPT_TEMPLATE_FIELD | ||
+ "\": {\"type\": \"text\"},\n" | ||
+ " \"" | ||
+ INTERACTIONS_RESPONSE_FIELD | ||
+ "\": {\"type\": \"text\"},\n" | ||
+ " \"" | ||
+ INTERACTIONS_ORIGIN_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ INTERACTIONS_ADDITIONAL_INFO_FIELD | ||
+ "\": {\"type\": \"flat_object\"},\n" | ||
+ " \"" | ||
+ PARENT_INTERACTIONS_ID_FIELD | ||
+ "\": {\"type\": \"keyword\"},\n" | ||
+ " \"" | ||
+ INTERACTIONS_TRACE_NUMBER_FIELD | ||
+ "\": {\"type\": \"long\"}\n" | ||
+ " }\n" | ||
+ "}"; | ||
public final static String INTERACTIONS_MAPPINGS = MLIndex.MEMORY_MESSAGE.getMapping(); | ||
|
||
/** Feature Flag setting for conversational memory */ | ||
public static final Setting<Boolean> ML_COMMONS_MEMORY_FEATURE_ENABLED = Setting | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"_meta": { | ||
"schema_version": 2 | ||
}, | ||
"properties": { | ||
"name": { | ||
"type": "text", | ||
"fields": { | ||
"keyword": { | ||
"type": "keyword", | ||
"ignore_above": 256 | ||
} | ||
} | ||
}, | ||
"type": { | ||
"type": "keyword" | ||
}, | ||
"description": { | ||
"type": "text" | ||
}, | ||
"llm": { | ||
"type": "flat_object" | ||
}, | ||
"tools": { | ||
"type": "flat_object" | ||
}, | ||
"parameters": { | ||
"type": "flat_object" | ||
}, | ||
"memory": { | ||
"type": "flat_object" | ||
}, | ||
"is_hidden": { | ||
"type": "boolean" | ||
}, | ||
"created_time": { | ||
"type": "date", | ||
"format": "strict_date_time||epoch_millis" | ||
}, | ||
"last_updated_time": { | ||
"type": "date", | ||
"format": "strict_date_time||epoch_millis" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"_meta": { | ||
"schema_version": 4 | ||
}, | ||
"properties": { | ||
"master_key": { | ||
"type": "keyword" | ||
}, | ||
"config_type": { | ||
"type": "keyword" | ||
}, | ||
"ml_configuration": { | ||
"type": "flat_object" | ||
}, | ||
"create_time": { | ||
"type": "date", | ||
"format": "strict_date_time||epoch_millis" | ||
}, | ||
"last_updated_time": { | ||
"type": "date", | ||
"format": "strict_date_time||epoch_millis" | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implementation group: 'org.json', name: 'json', version: '20231013'
I think this serves as both line 28 + 29 so no needs to declare twice here for the same dependency. Also if you want to go the extra mile, using "api group: 'org.json', name: 'json', version: '20231013'" can remove the duplicate of this dependency in other modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to keep the dependency strictly based on the requirement,
implementation
will add it during runtime as well and here we only needed it during testing runtime. Wdyt?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough and fine with this new line. But if you check this (https://github.com/opensearch-project/ml-commons/blob/main/ml-algorithms/build.gradle#L76), it's already added in runtime in several module too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I actually tried setting it as
implementation
initially but i received a lot of JarHell errorsCaused by: java.lang.IllegalStateException at JarHell.java:316
due to multiple implementations of this package and which is why i left it astestImplementation
, I remember attempting to resolve the dependencies but it became a bit convolutedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ref PR: https://github.com/opensearch-project/ml-commons/pull/1062/files