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