11
11
import java .util .ArrayList ;
12
12
import java .util .Collections ;
13
13
import java .util .HashMap ;
14
+ import java .util .HashSet ;
14
15
import java .util .List ;
15
16
import java .util .Map ;
16
17
import java .util .Objects ;
18
+ import java .util .Set ;
17
19
import javax .annotation .Nullable ;
18
20
19
21
/**
@@ -43,6 +45,7 @@ public class PromptTemplateConfig {
43
45
@ Nullable
44
46
private final String template ;
45
47
private final String templateFormat ;
48
+ private final Set <PromptTemplateOption > promptTemplateOptions ;
46
49
@ Nullable
47
50
private final String description ;
48
51
private final List <InputVariable > inputVariables ;
@@ -61,6 +64,7 @@ protected PromptTemplateConfig(String template) {
61
64
DEFAULT_CONFIG_NAME ,
62
65
template ,
63
66
SEMANTIC_KERNEL_TEMPLATE_FORMAT ,
67
+ Collections .emptySet (),
64
68
"" ,
65
69
Collections .emptyList (),
66
70
new OutputVariable (String .class .getName (), "out" ),
@@ -70,21 +74,23 @@ protected PromptTemplateConfig(String template) {
70
74
/**
71
75
* Constructor for a prompt template config
72
76
*
73
- * @param schema Schema version
74
- * @param name Name of the template
75
- * @param template Template string
76
- * @param templateFormat Template format
77
- * @param description Description of the template
78
- * @param inputVariables Input variables
79
- * @param outputVariable Output variable
80
- * @param executionSettings Execution settings
77
+ * @param schema Schema version
78
+ * @param name Name of the template
79
+ * @param template Template string
80
+ * @param templateFormat Template format
81
+ * @param promptTemplateOptions Prompt template options
82
+ * @param description Description of the template
83
+ * @param inputVariables Input variables
84
+ * @param outputVariable Output variable
85
+ * @param executionSettings Execution settings
81
86
*/
82
87
@ JsonCreator
83
88
public PromptTemplateConfig (
84
89
@ JsonProperty ("schema" ) int schema ,
85
90
@ Nullable @ JsonProperty ("name" ) String name ,
86
91
@ Nullable @ JsonProperty ("template" ) String template ,
87
92
@ Nullable @ JsonProperty (value = "template_format" , defaultValue = SEMANTIC_KERNEL_TEMPLATE_FORMAT ) String templateFormat ,
93
+ @ Nullable @ JsonProperty (value = "prompt_template_options" ) Set <PromptTemplateOption > promptTemplateOptions ,
88
94
@ Nullable @ JsonProperty ("description" ) String description ,
89
95
@ Nullable @ JsonProperty ("input_variables" ) List <InputVariable > inputVariables ,
90
96
@ Nullable @ JsonProperty ("output_variable" ) OutputVariable outputVariable ,
@@ -96,6 +102,10 @@ public PromptTemplateConfig(
96
102
templateFormat = SEMANTIC_KERNEL_TEMPLATE_FORMAT ;
97
103
}
98
104
this .templateFormat = templateFormat ;
105
+ if (promptTemplateOptions == null ) {
106
+ promptTemplateOptions = new HashSet <>();
107
+ }
108
+ this .promptTemplateOptions = promptTemplateOptions ;
99
109
this .description = description ;
100
110
if (inputVariables == null ) {
101
111
this .inputVariables = new ArrayList <>();
@@ -127,6 +137,7 @@ protected PromptTemplateConfig(
127
137
@ Nullable String name ,
128
138
@ Nullable String template ,
129
139
@ Nullable String templateFormat ,
140
+ @ Nullable Set <PromptTemplateOption > promptTemplateOptions ,
130
141
@ Nullable String description ,
131
142
@ Nullable List <InputVariable > inputVariables ,
132
143
@ Nullable OutputVariable outputVariable ,
@@ -136,6 +147,7 @@ protected PromptTemplateConfig(
136
147
name ,
137
148
template ,
138
149
templateFormat ,
150
+ promptTemplateOptions ,
139
151
description ,
140
152
inputVariables ,
141
153
outputVariable ,
@@ -152,6 +164,7 @@ public PromptTemplateConfig(PromptTemplateConfig promptTemplate) {
152
164
promptTemplate .name ,
153
165
promptTemplate .template ,
154
166
promptTemplate .templateFormat ,
167
+ promptTemplate .promptTemplateOptions ,
155
168
promptTemplate .description ,
156
169
promptTemplate .inputVariables ,
157
170
promptTemplate .outputVariable ,
@@ -300,6 +313,15 @@ public int getSchema() {
300
313
return schema ;
301
314
}
302
315
316
+ /**
317
+ * Get the prompt template options of the prompt template config.
318
+ *
319
+ * @return The prompt template options of the prompt template config.
320
+ */
321
+ public Set <PromptTemplateOption > getPromptTemplateOptions () {
322
+ return Collections .unmodifiableSet (promptTemplateOptions );
323
+ }
324
+
303
325
/**
304
326
* Create a builder for a prompt template config which is a clone of the current object.
305
327
*
@@ -358,6 +380,7 @@ public static class Builder {
358
380
@ Nullable
359
381
private String template ;
360
382
private String templateFormat = SEMANTIC_KERNEL_TEMPLATE_FORMAT ;
383
+ private final Set <PromptTemplateOption > promptTemplateOptions = new HashSet <>();
361
384
@ Nullable
362
385
private String description = null ;
363
386
private List <InputVariable > inputVariables = new ArrayList <>();
@@ -433,6 +456,11 @@ public Builder withTemplateFormat(String templateFormat) {
433
456
return this ;
434
457
}
435
458
459
+ public Builder addPromptTemplateOption (PromptTemplateOption option ) {
460
+ promptTemplateOptions .add (option );
461
+ return this ;
462
+ }
463
+
436
464
/**
437
465
* Set the inputVariables of the prompt template config.
438
466
*
@@ -477,6 +505,7 @@ public PromptTemplateConfig build() {
477
505
name ,
478
506
template ,
479
507
templateFormat ,
508
+ promptTemplateOptions ,
480
509
description ,
481
510
inputVariables ,
482
511
outputVariable ,
0 commit comments