@@ -559,6 +559,57 @@ pub enum ChatCompletionToolChoiceOption {
559
559
Named ( ChatCompletionNamedToolChoice ) ,
560
560
}
561
561
562
+ #[ derive( Clone , Serialize , Debug , Deserialize , PartialEq , Default ) ]
563
+ #[ serde( rename_all = "lowercase" ) ]
564
+ /// The amount of context window space to use for the search.
565
+ pub enum WebSearchContextSize {
566
+ Low ,
567
+ #[ default]
568
+ Medium ,
569
+ High ,
570
+ }
571
+
572
+
573
+ #[ derive( Clone , Serialize , Debug , Deserialize , PartialEq ) ]
574
+ #[ serde( rename_all = "lowercase" ) ]
575
+ pub enum WebSearchUserLocationType {
576
+
577
+ Approximate ,
578
+ }
579
+
580
+ /// Approximate location parameters for the search.
581
+ #[ derive( Clone , Serialize , Debug , Default , Deserialize , PartialEq ) ]
582
+ pub struct WebSearchLocation {
583
+ /// The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, e.g. `US`.
584
+ pub country : Option < String > ,
585
+ /// Free text input for the region of the user, e.g. `California`.
586
+ pub region : Option < String > ,
587
+ /// Free text input for the city of the user, e.g. `San Francisco`.
588
+ pub city : Option < String > ,
589
+ /// The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user, e.g. `America/Los_Angeles`.
590
+ pub timezone : Option < String > ,
591
+ }
592
+
593
+
594
+ #[ derive( Clone , Serialize , Debug , Deserialize , PartialEq ) ]
595
+ pub struct WebSearchUserLocation {
596
+ // The type of location approximation. Always `approximate`.
597
+ pub r#type : WebSearchUserLocationType ,
598
+
599
+ pub approximate : WebSearchLocation ,
600
+ }
601
+
602
+ /// Options for the web search tool.
603
+ #[ derive( Clone , Serialize , Debug , Default , Deserialize , PartialEq ) ]
604
+ pub struct WebSearchOptions {
605
+ /// High level guidance for the amount of context window space to use for the search. One of `low`, `medium`, or `high`. `medium` is the default.
606
+
607
+ pub search_context_size : Option < WebSearchContextSize > ,
608
+
609
+ /// Approximate location parameters for the search.
610
+ pub user_location : Option < WebSearchUserLocation > ,
611
+ }
612
+
562
613
#[ derive( Clone , Serialize , Debug , Deserialize , PartialEq ) ]
563
614
#[ serde( rename_all = "lowercase" ) ]
564
615
pub enum ServiceTier {
@@ -803,6 +854,11 @@ pub struct CreateChatCompletionRequest {
803
854
#[ serde( skip_serializing_if = "Option::is_none" ) ]
804
855
pub user : Option < String > ,
805
856
857
+ /// This tool searches the web for relevant results to use in a response.
858
+ /// Learn more about the [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
859
+
860
+ pub web_search_options : Option < WebSearchOptions > ,
861
+
806
862
/// Deprecated in favor of `tool_choice`.
807
863
///
808
864
/// Controls which (if any) function is called by the model.
0 commit comments