|
5 | 5 | package io.modelcontextprotocol.spec;
|
6 | 6 |
|
7 | 7 | import java.io.IOException;
|
| 8 | +import java.util.ArrayList; |
8 | 9 | import java.util.HashMap;
|
9 | 10 | import java.util.List;
|
10 | 11 | import java.util.Map;
|
@@ -763,15 +764,61 @@ public record CallToolResult( // @formatter:off
|
763 | 764 | @JsonInclude(JsonInclude.Include.NON_ABSENT)
|
764 | 765 | @JsonIgnoreProperties(ignoreUnknown = true)
|
765 | 766 | public record ModelPreferences(// @formatter:off
|
766 |
| - @JsonProperty("hints") List<ModelHint> hints, |
767 |
| - @JsonProperty("costPriority") Double costPriority, |
768 |
| - @JsonProperty("speedPriority") Double speedPriority, |
769 |
| - @JsonProperty("intelligencePriority") Double intelligencePriority) { |
770 |
| - } // @formatter:on |
| 767 | + @JsonProperty("hints") List<ModelHint> hints, |
| 768 | + @JsonProperty("costPriority") Double costPriority, |
| 769 | + @JsonProperty("speedPriority") Double speedPriority, |
| 770 | + @JsonProperty("intelligencePriority") Double intelligencePriority) { |
| 771 | + |
| 772 | + public static Builder builder() { |
| 773 | + return new Builder(); |
| 774 | + } |
| 775 | + |
| 776 | + public static class Builder { |
| 777 | + private List<ModelHint> hints; |
| 778 | + private Double costPriority; |
| 779 | + private Double speedPriority; |
| 780 | + private Double intelligencePriority; |
| 781 | + |
| 782 | + public Builder hints(List<ModelHint> hints) { |
| 783 | + this.hints = hints; |
| 784 | + return this; |
| 785 | + } |
| 786 | + |
| 787 | + public Builder addHint(String name) { |
| 788 | + if (this.hints == null) { |
| 789 | + this.hints = new ArrayList<>(); |
| 790 | + } |
| 791 | + this.hints.add(new ModelHint(name)); |
| 792 | + return this; |
| 793 | + } |
| 794 | + |
| 795 | + public Builder costPriority(Double costPriority) { |
| 796 | + this.costPriority = costPriority; |
| 797 | + return this; |
| 798 | + } |
| 799 | + |
| 800 | + public Builder speedPriority(Double speedPriority) { |
| 801 | + this.speedPriority = speedPriority; |
| 802 | + return this; |
| 803 | + } |
| 804 | + |
| 805 | + public Builder intelligencePriority(Double intelligencePriority) { |
| 806 | + this.intelligencePriority = intelligencePriority; |
| 807 | + return this; |
| 808 | + } |
| 809 | + |
| 810 | + public ModelPreferences build() { |
| 811 | + return new ModelPreferences(hints, costPriority, speedPriority, intelligencePriority); |
| 812 | + } |
| 813 | + } |
| 814 | +} // @formatter:on |
771 | 815 |
|
772 | 816 | @JsonInclude(JsonInclude.Include.NON_ABSENT)
|
773 | 817 | @JsonIgnoreProperties(ignoreUnknown = true)
|
774 | 818 | public record ModelHint(@JsonProperty("name") String name) {
|
| 819 | + public static ModelHint of(String name) { |
| 820 | + return new ModelHint(name); |
| 821 | + } |
775 | 822 | }
|
776 | 823 |
|
777 | 824 | @JsonInclude(JsonInclude.Include.NON_ABSENT)
|
@@ -799,6 +846,66 @@ public enum ContextInclusionStrategy {
|
799 | 846 | @JsonProperty("thisServer") THIS_SERVER,
|
800 | 847 | @JsonProperty("allServers") ALL_SERVERS
|
801 | 848 | }
|
| 849 | + |
| 850 | + public static Builder builder() { |
| 851 | + return new Builder(); |
| 852 | + } |
| 853 | + |
| 854 | + public static class Builder { |
| 855 | + private List<SamplingMessage> messages; |
| 856 | + private ModelPreferences modelPreferences; |
| 857 | + private String systemPrompt; |
| 858 | + private ContextInclusionStrategy includeContext; |
| 859 | + private Double temperature; |
| 860 | + private int maxTokens; |
| 861 | + private List<String> stopSequences; |
| 862 | + private Map<String, Object> metadata; |
| 863 | + |
| 864 | + public Builder messages(List<SamplingMessage> messages) { |
| 865 | + this.messages = messages; |
| 866 | + return this; |
| 867 | + } |
| 868 | + |
| 869 | + public Builder modelPreferences(ModelPreferences modelPreferences) { |
| 870 | + this.modelPreferences = modelPreferences; |
| 871 | + return this; |
| 872 | + } |
| 873 | + |
| 874 | + public Builder systemPrompt(String systemPrompt) { |
| 875 | + this.systemPrompt = systemPrompt; |
| 876 | + return this; |
| 877 | + } |
| 878 | + |
| 879 | + public Builder includeContext(ContextInclusionStrategy includeContext) { |
| 880 | + this.includeContext = includeContext; |
| 881 | + return this; |
| 882 | + } |
| 883 | + |
| 884 | + public Builder temperature(Double temperature) { |
| 885 | + this.temperature = temperature; |
| 886 | + return this; |
| 887 | + } |
| 888 | + |
| 889 | + public Builder maxTokens(int maxTokens) { |
| 890 | + this.maxTokens = maxTokens; |
| 891 | + return this; |
| 892 | + } |
| 893 | + |
| 894 | + public Builder stopSequences(List<String> stopSequences) { |
| 895 | + this.stopSequences = stopSequences; |
| 896 | + return this; |
| 897 | + } |
| 898 | + |
| 899 | + public Builder metadata(Map<String, Object> metadata) { |
| 900 | + this.metadata = metadata; |
| 901 | + return this; |
| 902 | + } |
| 903 | + |
| 904 | + public CreateMessageRequest build() { |
| 905 | + return new CreateMessageRequest(messages, modelPreferences, systemPrompt, |
| 906 | + includeContext, temperature, maxTokens, stopSequences, metadata); |
| 907 | + } |
| 908 | + } |
802 | 909 | }// @formatter:on
|
803 | 910 |
|
804 | 911 | @JsonInclude(JsonInclude.Include.NON_ABSENT)
|
|
0 commit comments