Skip to content

Commit fe90810

Browse files
Add taskSettings parameter to LlamaChatCompletionModel and LlamaEmbeddingsModel for enhanced customization
1 parent 45966dd commit fe90810

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/llama/completion/LlamaChatCompletionModel.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class LlamaChatCompletionModel extends LlamaModel {
3333
* @param taskType the type of task this model is designed for
3434
* @param service the name of the inference service
3535
* @param serviceSettings the settings for the inference service, specific to chat completion
36+
* @param taskSettings the settings for the task, such as user or other parameters
3637
* @param secrets the secret settings for the model, such as API keys or tokens
3738
* @param context the context for parsing configuration settings
3839
*/
@@ -61,6 +62,7 @@ public LlamaChatCompletionModel(
6162
* @param taskType the type of task this model is designed for
6263
* @param service the name of the inference service
6364
* @param serviceSettings the settings for the inference service, specific to chat completion
65+
* @param taskSettings the settings for the task, such as user or other parameters
6466
* @param secrets the secret settings for the model, such as API keys or tokens
6567
*/
6668
public LlamaChatCompletionModel(
@@ -75,6 +77,14 @@ public LlamaChatCompletionModel(
7577
setPropertiesFromServiceSettings(serviceSettings);
7678
}
7779

80+
/**
81+
* Factory method to create a LlamaChatCompletionModel with overridden task settings based on the request.
82+
* If the request does not specify task settings, the original model is returned.
83+
*
84+
* @param model the original LlamaChatCompletionModel
85+
* @param taskSettings the task settings to override, which may include parameters like user
86+
* @return a new LlamaChatCompletionModel with overridden task settings or the original model if no overrides are specified
87+
*/
7888
public static LlamaChatCompletionModel of(LlamaChatCompletionModel model, Map<String, Object> taskSettings) {
7989
if (taskSettings == null || taskSettings.isEmpty()) {
8090
return model;

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/llama/embeddings/LlamaEmbeddingsModel.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public class LlamaEmbeddingsModel extends LlamaModel {
3434
* @param taskType the type of task this model is designed for
3535
* @param service the name of the inference service
3636
* @param serviceSettings the settings for the inference service, specific to embeddings
37+
* @param taskSettings the settings for the task, such as user or other parameters
38+
* @param chunkingSettings the chunking settings for processing input data
3739
* @param secrets the secret settings for the model, such as API keys or tokens
3840
* @param context the context for parsing configuration settings
3941
*/
@@ -86,6 +88,7 @@ private void setPropertiesFromServiceSettings(LlamaEmbeddingsServiceSettings ser
8688
* @param taskType the type of task this model is designed for
8789
* @param service the name of the inference service
8890
* @param serviceSettings the settings for the inference service, specific to embeddings
91+
* @param taskSettings the settings for the task, such as user or other parameters
8992
* @param chunkingSettings the chunking settings for processing input data
9093
* @param secrets the secret settings for the model, such as API keys or tokens
9194
*/
@@ -105,6 +108,14 @@ public LlamaEmbeddingsModel(
105108
setPropertiesFromServiceSettings(serviceSettings);
106109
}
107110

111+
/**
112+
* Factory method to create a LlamaEmbeddingsModel with overridden task settings based on the request.
113+
* If the request does not specify task settings, the original model is returned.
114+
*
115+
* @param model the original LlamaEmbeddingsModel
116+
* @param taskSettings the task settings to override, which may include parameters like user
117+
* @return a new LlamaEmbeddingsModel with overridden task settings or the original model if no overrides are specified
118+
*/
108119
public static LlamaEmbeddingsModel of(LlamaEmbeddingsModel model, Map<String, Object> taskSettings) {
109120
if (taskSettings == null || taskSettings.isEmpty()) {
110121
return model;

0 commit comments

Comments
 (0)