Package com.github.copilot.sdk.json
Class SectionOverride
java.lang.Object
com.github.copilot.sdk.json.SectionOverride
Override operation for a single system prompt section in
SystemMessageMode#CUSTOMIZE mode.
Each SectionOverride describes how one named section of the default
system prompt should be modified. The section name keys come from
SystemPromptSections.
Static override example
var config = new SystemMessageConfig().setMode(SystemMessageMode.CUSTOMIZE).setSections(Map.of(
SystemPromptSections.TONE,
new SectionOverride().setAction(SectionOverrideAction.REPLACE).setContent("Be concise and formal."),
SystemPromptSections.CODE_CHANGE_RULES, new SectionOverride().setAction(SectionOverrideAction.REMOVE)));
Transform callback example
var config = new SystemMessageConfig().setMode(SystemMessageMode.CUSTOMIZE)
.setSections(Map.of(SystemPromptSections.IDENTITY, new SectionOverride().setTransform(
content -> CompletableFuture.completedFuture(content + "\nAlways end replies with DONE."))));
- Since:
- 1.2.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the override action.Gets the content for the override.Gets the transform callback.setAction(SectionOverrideAction action) Sets the override action.setContent(String content) Sets the content for the override.setTransform(Function<String, CompletableFuture<String>> transform) Sets the transform callback for this section.
-
Constructor Details
-
SectionOverride
public SectionOverride()
-
-
Method Details
-
getAction
Gets the override action.- Returns:
- the action, or
nullif a transform callback is set
-
setAction
Sets the override action.- Parameters:
action- the action to perform on this section- Returns:
- this override for method chaining
-
getContent
Gets the content for the override.- Returns:
- the content, or
null
-
setContent
Sets the content for the override.Used for
SectionOverrideAction.REPLACE,SectionOverrideAction.APPEND, andSectionOverrideAction.PREPEND. Ignored forSectionOverrideAction.REMOVE.- Parameters:
content- the content string- Returns:
- this override for method chaining
-
getTransform
Gets the transform callback.- Returns:
- the transform function, or
nullif not set
-
setTransform
Sets the transform callback for this section.The function receives the current section content as a
Stringand returns the transformed content via aCompletableFuture. When set, this takes precedence overaction.- Parameters:
transform- a function that transforms the section content- Returns:
- this override for method chaining
-