@@ -475,7 +475,21 @@ public enum ChatModel implements ChatModelDescription {
475
475
* Context window: 4,096 tokens. Max output tokens: 4,096 tokens. Knowledge
476
476
* cutoff: September, 2021.
477
477
*/
478
- GPT_3_5_TURBO_INSTRUCT ("gpt-3.5-turbo-instruct" );
478
+ GPT_3_5_TURBO_INSTRUCT ("gpt-3.5-turbo-instruct" ),
479
+
480
+ /**
481
+ * <b>GPT-4o Search Preview</b> is a specialized model for web search in Chat
482
+ * Completions. It is trained to understand and execute web search queries. See
483
+ * the web search guide for more information.
484
+ */
485
+ GPT_4_O_SEARCH_PREVIEW ("gpt-4o-search-preview" ),
486
+
487
+ /**
488
+ * <b>GPT-4o mini Search Preview</b> is a specialized model for web search in Chat
489
+ * Completions. It is trained to understand and execute web search queries. See
490
+ * the web search guide for more information.
491
+ */
492
+ GPT_4_O_MINI_SEARCH_PREVIEW ("gpt-4o-mini-search-preview" );
479
493
480
494
public final String value ;
481
495
@@ -835,6 +849,10 @@ public enum OutputModality {
835
849
* @param parallelToolCalls If set to true, the model will call all functions in the
836
850
* tools list in parallel. Otherwise, the model will call the functions in the tools
837
851
* list in the order they are provided.
852
+ * @param reasoningEffort Constrains effort on reasoning for reasoning models.
853
+ * Currently supported values are low, medium, and high. Reducing reasoning effort can
854
+ * result in faster responses and fewer tokens used on reasoning in a response.
855
+ * @param webSearchOptions Options for web search.
838
856
*/
839
857
@ JsonInclude (Include .NON_NULL )
840
858
public record ChatCompletionRequest (// @formatter:off
@@ -864,7 +882,8 @@ public record ChatCompletionRequest(// @formatter:off
864
882
@ JsonProperty ("tool_choice" ) Object toolChoice ,
865
883
@ JsonProperty ("parallel_tool_calls" ) Boolean parallelToolCalls ,
866
884
@ JsonProperty ("user" ) String user ,
867
- @ JsonProperty ("reasoning_effort" ) String reasoningEffort ) {
885
+ @ JsonProperty ("reasoning_effort" ) String reasoningEffort ,
886
+ @ JsonProperty ("web_search_options" ) WebSearchOptions webSearchOptions ) {
868
887
869
888
/**
870
889
* Shortcut constructor for a chat completion request with the given messages, model and temperature.
@@ -876,7 +895,7 @@ public record ChatCompletionRequest(// @formatter:off
876
895
public ChatCompletionRequest (List <ChatCompletionMessage > messages , String model , Double temperature ) {
877
896
this (messages , model , null , null , null , null , null , null , null , null , null , null , null , null , null ,
878
897
null , null , null , false , null , temperature , null ,
879
- null , null , null , null , null );
898
+ null , null , null , null , null , null );
880
899
}
881
900
882
901
/**
@@ -890,7 +909,7 @@ public ChatCompletionRequest(List<ChatCompletionMessage> messages, String model,
890
909
this (messages , model , null , null , null , null , null , null ,
891
910
null , null , null , List .of (OutputModality .AUDIO , OutputModality .TEXT ), audio , null , null ,
892
911
null , null , null , stream , null , null , null ,
893
- null , null , null , null , null );
912
+ null , null , null , null , null , null );
894
913
}
895
914
896
915
/**
@@ -905,7 +924,7 @@ public ChatCompletionRequest(List<ChatCompletionMessage> messages, String model,
905
924
public ChatCompletionRequest (List <ChatCompletionMessage > messages , String model , Double temperature , boolean stream ) {
906
925
this (messages , model , null , null , null , null , null , null , null , null , null ,
907
926
null , null , null , null , null , null , null , stream , null , temperature , null ,
908
- null , null , null , null , null );
927
+ null , null , null , null , null , null );
909
928
}
910
929
911
930
/**
@@ -921,7 +940,7 @@ public ChatCompletionRequest(List<ChatCompletionMessage> messages, String model,
921
940
List <FunctionTool > tools , Object toolChoice ) {
922
941
this (messages , model , null , null , null , null , null , null , null , null , null ,
923
942
null , null , null , null , null , null , null , false , null , 0.8 , null ,
924
- tools , toolChoice , null , null , null );
943
+ tools , toolChoice , null , null , null , null );
925
944
}
926
945
927
946
/**
@@ -934,7 +953,7 @@ public ChatCompletionRequest(List<ChatCompletionMessage> messages, String model,
934
953
public ChatCompletionRequest (List <ChatCompletionMessage > messages , Boolean stream ) {
935
954
this (messages , null , null , null , null , null , null , null , null , null , null ,
936
955
null , null , null , null , null , null , null , stream , null , null , null ,
937
- null , null , null , null , null );
956
+ null , null , null , null , null , null );
938
957
}
939
958
940
959
/**
@@ -947,7 +966,7 @@ public ChatCompletionRequest streamOptions(StreamOptions streamOptions) {
947
966
return new ChatCompletionRequest (this .messages , this .model , this .store , this .metadata , this .frequencyPenalty , this .logitBias , this .logprobs ,
948
967
this .topLogprobs , this .maxTokens , this .maxCompletionTokens , this .n , this .outputModalities , this .audioParameters , this .presencePenalty ,
949
968
this .responseFormat , this .seed , this .serviceTier , this .stop , this .stream , streamOptions , this .temperature , this .topP ,
950
- this .tools , this .toolChoice , this .parallelToolCalls , this .user , this .reasoningEffort );
969
+ this .tools , this .toolChoice , this .parallelToolCalls , this .user , this .reasoningEffort , this . webSearchOptions );
951
970
}
952
971
953
972
/**
@@ -1029,6 +1048,61 @@ public record StreamOptions(
1029
1048
1030
1049
public static StreamOptions INCLUDE_USAGE = new StreamOptions (true );
1031
1050
}
1051
+
1052
+ /**
1053
+ * This tool searches the web for relevant results to use in a response.
1054
+ *
1055
+ * @param searchContextSize
1056
+ * @param userLocation
1057
+ */
1058
+ @ JsonInclude (Include .NON_NULL )
1059
+ public record WebSearchOptions (@ JsonProperty ("search_context_size" ) SearchContextSize searchContextSize ,
1060
+ @ JsonProperty ("user_location" ) UserLocation userLocation ) {
1061
+
1062
+ /**
1063
+ * High level guidance for the amount of context window space to use for the
1064
+ * search. One of low, medium, or high. medium is the default.
1065
+ */
1066
+ public enum SearchContextSize {
1067
+
1068
+ /**
1069
+ * Low context size.
1070
+ */
1071
+ @ JsonProperty ("low" )
1072
+ LOW ,
1073
+
1074
+ /**
1075
+ * Medium context size. This is the default.
1076
+ */
1077
+ @ JsonProperty ("medium" )
1078
+ MEDIUM ,
1079
+
1080
+ /**
1081
+ * High context size.
1082
+ */
1083
+ @ JsonProperty ("high" )
1084
+ HIGH
1085
+
1086
+ }
1087
+
1088
+ /**
1089
+ * Approximate location parameters for the search.
1090
+ *
1091
+ * @param type The type of location approximation. Always "approximate".
1092
+ * @param approximate The approximate location details.
1093
+ */
1094
+ @ JsonInclude (Include .NON_NULL )
1095
+ public record UserLocation (@ JsonProperty ("type" ) String type ,
1096
+ @ JsonProperty ("approximate" ) Approximate approximate ) {
1097
+
1098
+ @ JsonInclude (Include .NON_NULL )
1099
+ public record Approximate (@ JsonProperty ("city" ) String city , @ JsonProperty ("country" ) String country ,
1100
+ @ JsonProperty ("region" ) String region , @ JsonProperty ("timezone" ) String timezone ) {
1101
+ }
1102
+ }
1103
+
1104
+ }
1105
+
1032
1106
} // @formatter:on
1033
1107
1034
1108
/**
@@ -1047,19 +1121,22 @@ public record StreamOptions(
1047
1121
* Applicable only for {@link Role#ASSISTANT} role and null otherwise.
1048
1122
* @param refusal The refusal message by the assistant. Applicable only for
1049
1123
* {@link Role#ASSISTANT} role and null otherwise.
1050
- * @param audioOutput Audio response from the model. >>>>>>> bdb66e577 (OpenAI -
1051
- * Support audio input modality)
1124
+ * @param audioOutput Audio response from the model.
1125
+ * @param annotations Annotations for the message, when applicable, as when using the
1126
+ * web search tool.
1052
1127
*/
1053
- @ JsonInclude (Include .NON_NULL )
1054
- public record ChatCompletionMessage (// @formatter:off
1128
+ @ JsonInclude (JsonInclude .Include .NON_NULL )
1129
+ public record ChatCompletionMessage (
1130
+ // @formatter:off
1055
1131
@ JsonProperty ("content" ) Object rawContent ,
1056
1132
@ JsonProperty ("role" ) Role role ,
1057
1133
@ JsonProperty ("name" ) String name ,
1058
1134
@ JsonProperty ("tool_call_id" ) String toolCallId ,
1059
- @ JsonProperty ("tool_calls" )
1060
- @ JsonFormat (with = JsonFormat .Feature .ACCEPT_SINGLE_VALUE_AS_ARRAY ) List <ToolCall > toolCalls ,
1135
+ @ JsonProperty ("tool_calls" ) @ JsonFormat (with = JsonFormat .Feature .ACCEPT_SINGLE_VALUE_AS_ARRAY ) List <ToolCall > toolCalls ,
1061
1136
@ JsonProperty ("refusal" ) String refusal ,
1062
- @ JsonProperty ("audio" ) AudioOutput audioOutput ) { // @formatter:on
1137
+ @ JsonProperty ("audio" ) AudioOutput audioOutput ,
1138
+ @ JsonProperty ("annotations" ) List <Annotation > annotations
1139
+ ) { // @formatter:on
1063
1140
1064
1141
/**
1065
1142
* Create a chat completion message with the given content and role. All other
@@ -1068,8 +1145,7 @@ public record ChatCompletionMessage(// @formatter:off
1068
1145
* @param role The role of the author of this message.
1069
1146
*/
1070
1147
public ChatCompletionMessage (Object content , Role role ) {
1071
- this (content , role , null , null , null , null , null );
1072
-
1148
+ this (content , role , null , null , null , null , null , null );
1073
1149
}
1074
1150
1075
1151
/**
@@ -1246,6 +1322,29 @@ public record AudioOutput(// @formatter:off
1246
1322
@ JsonProperty ("transcript" ) String transcript
1247
1323
) { // @formatter:on
1248
1324
}
1325
+
1326
+ /**
1327
+ * Represents an annotation within a message, specifically for URL citations.
1328
+ */
1329
+ @ JsonInclude (JsonInclude .Include .NON_NULL )
1330
+ public record Annotation (@ JsonProperty ("type" ) String type ,
1331
+ @ JsonProperty ("url_citation" ) UrlCitation urlCitation ) {
1332
+ /**
1333
+ * A URL citation when using web search.
1334
+ *
1335
+ * @param endIndex The index of the last character of the URL citation in the
1336
+ * message.
1337
+ * @param startIndex The index of the first character of the URL citation in
1338
+ * the message.
1339
+ * @param title The title of the web resource.
1340
+ * @param url The URL of the web resource.
1341
+ */
1342
+ @ JsonInclude (JsonInclude .Include .NON_NULL )
1343
+ public record UrlCitation (@ JsonProperty ("end_index" ) Integer endIndex ,
1344
+ @ JsonProperty ("start_index" ) Integer startIndex , @ JsonProperty ("title" ) String title ,
1345
+ @ JsonProperty ("url" ) String url ) {
1346
+ }
1347
+ }
1249
1348
}
1250
1349
1251
1350
/**
0 commit comments