@@ -34,7 +34,7 @@ public class KernelArguments implements Map<String, ContextVariable<?>> {
34
34
public static final String MAIN_KEY = "input" ;
35
35
36
36
protected final CaseInsensitiveMap <ContextVariable <?>> variables ;
37
- protected final Map <String , PromptExecutionSettings > promptExecutionSettings ;
37
+ protected final Map <String , PromptExecutionSettings > executionSettings ;
38
38
39
39
/**
40
40
* Create a new instance of KernelArguments.
@@ -43,17 +43,17 @@ public class KernelArguments implements Map<String, ContextVariable<?>> {
43
43
*/
44
44
protected KernelArguments (
45
45
@ Nullable Map <String , ContextVariable <?>> variables ,
46
- @ Nullable Map <String , PromptExecutionSettings > promptExecutionSettings ) {
46
+ @ Nullable Map <String , PromptExecutionSettings > executionSettings ) {
47
47
if (variables == null ) {
48
48
this .variables = new CaseInsensitiveMap <>();
49
49
} else {
50
50
this .variables = new CaseInsensitiveMap <>(variables );
51
51
}
52
52
53
- if (promptExecutionSettings == null ) {
54
- this .promptExecutionSettings = new HashMap <>();
53
+ if (executionSettings == null ) {
54
+ this .executionSettings = new HashMap <>();
55
55
} else {
56
- this .promptExecutionSettings = new HashMap <>(promptExecutionSettings );
56
+ this .executionSettings = new HashMap <>(executionSettings );
57
57
}
58
58
}
59
59
@@ -63,18 +63,16 @@ protected KernelArguments(
63
63
* @param content The content to use for the function invocation.
64
64
*/
65
65
protected KernelArguments (@ NonNull ContextVariable <?> content ) {
66
- this . variables = new CaseInsensitiveMap <> ();
66
+ this ();
67
67
this .variables .put (MAIN_KEY , content );
68
-
69
- this .promptExecutionSettings = new HashMap <>();
70
68
}
71
69
72
70
/**
73
71
* Create a new instance of KernelArguments.
74
72
*/
75
73
protected KernelArguments () {
76
74
this .variables = new CaseInsensitiveMap <>();
77
- this .promptExecutionSettings = new HashMap <>();
75
+ this .executionSettings = new HashMap <>();
78
76
}
79
77
80
78
/**
@@ -84,7 +82,7 @@ protected KernelArguments() {
84
82
*/
85
83
protected KernelArguments (@ NonNull KernelArguments arguments ) {
86
84
this .variables = new CaseInsensitiveMap <>(arguments .variables );
87
- this .promptExecutionSettings = new HashMap <>(arguments .promptExecutionSettings );
85
+ this .executionSettings = new HashMap <>(arguments .executionSettings );
88
86
}
89
87
90
88
/**
@@ -93,8 +91,8 @@ protected KernelArguments(@NonNull KernelArguments arguments) {
93
91
* @return prompt execution settings
94
92
*/
95
93
@ Nonnull
96
- public Map <String , PromptExecutionSettings > getPromptExecutionSettings () {
97
- return Collections .unmodifiableMap (promptExecutionSettings );
94
+ public Map <String , PromptExecutionSettings > getExecutionSettings () {
95
+ return Collections .unmodifiableMap (executionSettings );
98
96
}
99
97
100
98
/**
@@ -233,7 +231,7 @@ public Set<Entry<String, ContextVariable<?>>> entrySet() {
233
231
* @return copy of the current instance
234
232
*/
235
233
public KernelArguments copy () {
236
- return new KernelArguments (variables , promptExecutionSettings );
234
+ return new KernelArguments (variables , executionSettings );
237
235
}
238
236
239
237
/**
@@ -253,13 +251,13 @@ public static class Builder<U extends KernelArguments> implements SemanticKernel
253
251
254
252
private final Function <KernelArguments , U > constructor ;
255
253
private final Map <String , ContextVariable <?>> variables ;
256
- private final Map <String , PromptExecutionSettings > promptExecutionSettings ;
254
+ private final Map <String , PromptExecutionSettings > executionSettings ;
257
255
258
256
259
257
protected Builder (Function <KernelArguments , U > constructor ) {
260
258
this .constructor = constructor ;
261
259
this .variables = new HashMap <>();
262
- this .promptExecutionSettings = new HashMap <>();
260
+ this .executionSettings = new HashMap <>();
263
261
}
264
262
265
263
/**
@@ -365,24 +363,28 @@ public <T> Builder<U> withVariable(String key, T value,
365
363
/**
366
364
* Set prompt execution settings
367
365
*
368
- * @param promptExecutionSettings Prompt execution settings
366
+ * @param executionSettings Execution settings
369
367
* @return {$code this} Builder for fluent coding
370
368
*/
371
- public Builder <U > withPromptExecutionSettings (Map <String , PromptExecutionSettings > promptExecutionSettings ) {
372
- return withPromptExecutionSettings (new ArrayList <>(promptExecutionSettings .values ()));
369
+ public Builder <U > withExecutionSettings (Map <String , PromptExecutionSettings > executionSettings ) {
370
+ return withExecutionSettings (new ArrayList <>(executionSettings .values ()));
373
371
}
374
372
375
373
/**
376
374
* Set prompt execution settings
377
375
*
378
- * @param promptExecutionSettings Prompt execution settings
376
+ * @param executionSettings Execution settings
379
377
* @return {$code this} Builder for fluent coding
380
378
*/
381
- public Builder <U > withPromptExecutionSettings (List <PromptExecutionSettings > promptExecutionSettings ) {
382
- for (PromptExecutionSettings settings : promptExecutionSettings ) {
379
+ public Builder <U > withExecutionSettings (List <PromptExecutionSettings > executionSettings ) {
380
+ if (executionSettings == null ) {
381
+ return this ;
382
+ }
383
+
384
+ for (PromptExecutionSettings settings : executionSettings ) {
383
385
String serviceId = settings .getServiceId ();
384
386
385
- if (this .promptExecutionSettings .containsKey (serviceId )) {
387
+ if (this .executionSettings .containsKey (serviceId )) {
386
388
if (serviceId .equals (PromptExecutionSettings .DEFAULT_SERVICE_ID )) {
387
389
throw new SKException (
388
390
String .format (
@@ -404,7 +406,7 @@ public Builder<U> withPromptExecutionSettings(List<PromptExecutionSettings> prom
404
406
405
407
@ Override
406
408
public U build () {
407
- KernelArguments arguments = new KernelArguments (variables , promptExecutionSettings );
409
+ KernelArguments arguments = new KernelArguments (variables , executionSettings );
408
410
return constructor .apply (arguments );
409
411
}
410
412
}
0 commit comments