Download codex-rs/codex-api/src/search.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 10.2 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/codex-api/src/search.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/codex-api/src/search.rs
-
curl -L -o search.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/codex-api/src/search.rs
10.2 kB
| use crate::common::Reasoning; | |
| use codex_protocol::models::ResponseItem; | |
| use schemars::JsonSchema; | |
| use serde::Deserialize; | |
| use serde::Serialize; | |
| use serde_json::Value as JsonValue; | |
| pub struct SearchRequest { | |
| pub id: String, | |
| pub model: String, | |
| pub reasoning: Option<Reasoning>, | |
| pub input: Option<SearchInput>, | |
| pub commands: Option<SearchCommands>, | |
| pub settings: Option<SearchSettings>, | |
| pub max_output_tokens: Option<u64>, | |
| } | |
| pub enum SearchInput { | |
| Text(String), | |
| Items(Vec<ResponseItem>), | |
| } | |
| pub struct SearchCommands { | |
| /// Query the internet search engine for a given list of queries. | |
| pub search_query: Option<Vec<SearchQuery>>, | |
| /// Query the image search engine for a given list of queries. | |
| pub image_query: Option<Vec<SearchQuery>>, | |
| /// Open pages by reference id or URL. | |
| pub open: Option<Vec<OpenOperation>>, | |
| /// Open links from previously opened pages. | |
| pub click: Option<Vec<ClickOperation>>, | |
| /// Find text patterns in pages. | |
| pub find: Option<Vec<FindOperation>>, | |
| /// Take screenshots of PDF pages. | |
| pub screenshot: Option<Vec<ScreenshotOperation>>, | |
| /// Look up prices for the given stock symbols. | |
| pub finance: Option<Vec<FinanceOperation>>, | |
| /// Look up weather forecasts. | |
| pub weather: Option<Vec<WeatherOperation>>, | |
| /// Look up sports schedules and standings. | |
| pub sports: Option<Vec<SportsOperation>>, | |
| /// Get time for the given UTC offsets. | |
| pub time: Option<Vec<TimeOperation>>, | |
| /// Set the length of the response to be returned. | |
| pub response_length: Option<SearchResponseLength>, | |
| } | |
| pub struct SearchQuery { | |
| /// Search query. | |
| pub q: String, | |
| /// Whether to filter by recency, as a number of recent days. | |
| pub recency: Option<u64>, | |
| /// Whether to filter by a specific list of domains. | |
| pub domains: Option<Vec<String>>, | |
| } | |
| pub struct OpenOperation { | |
| /// Reference id or URL to open. | |
| pub ref_id: String, | |
| /// Line number to position the page at. | |
| pub lineno: Option<u64>, | |
| } | |
| pub struct ClickOperation { | |
| /// Reference id containing the numbered link. | |
| pub ref_id: String, | |
| /// Numbered link id to open. | |
| pub id: u64, | |
| } | |
| pub struct FindOperation { | |
| /// Reference id or URL to search within. | |
| pub ref_id: String, | |
| /// Text pattern to find. | |
| pub pattern: String, | |
| } | |
| pub struct ScreenshotOperation { | |
| /// Reference id or URL to screenshot. | |
| pub ref_id: String, | |
| /// Zero-indexed PDF page number. | |
| pub pageno: u64, | |
| } | |
| pub struct FinanceOperation { | |
| /// Ticker symbol to look up. | |
| pub ticker: String, | |
| /// Asset type to look up. | |
| pub r#type: FinanceAssetType, | |
| /// ISO 3166-1 alpha-3 country code, "OTC", or "" for cryptocurrency. | |
| pub market: Option<String>, | |
| } | |
| pub enum FinanceAssetType { | |
| Equity, | |
| Fund, | |
| Crypto, | |
| Index, | |
| } | |
| pub struct WeatherOperation { | |
| /// Location in "Country, Area, City" format. | |
| pub location: String, | |
| /// Start date in YYYY-MM-DD format. Defaults to today. | |
| pub start: Option<String>, | |
| /// Number of days to return. Defaults to 7. | |
| pub duration: Option<u64>, | |
| } | |
| pub struct SportsOperation { | |
| /// Tool name for sports requests. | |
| pub tool: Option<SportsToolName>, | |
| /// Sports function to call. | |
| pub r#fn: SportsFunction, | |
| /// League to look up. | |
| pub league: SportsLeague, | |
| /// Team to look up, using the common 3 or 4 letter alias used in broadcasts. | |
| pub team: Option<String>, | |
| /// Opponent to use with `team` when narrowing the lookup. | |
| pub opponent: Option<String>, | |
| /// Start date in YYYY-MM-DD format. | |
| pub date_from: Option<String>, | |
| /// End date in YYYY-MM-DD format. | |
| pub date_to: Option<String>, | |
| /// Number of games to return. | |
| pub num_games: Option<u64>, | |
| /// Locale for the lookup. | |
| pub locale: Option<String>, | |
| } | |
| pub enum SportsToolName { | |
| Sports, | |
| } | |
| pub enum SportsFunction { | |
| Schedule, | |
| Standings, | |
| } | |
| pub enum SportsLeague { | |
| Nba, | |
| Wnba, | |
| Nfl, | |
| Nhl, | |
| Mlb, | |
| Epl, | |
| Ncaamb, | |
| Ncaawb, | |
| Ipl, | |
| } | |
| pub struct TimeOperation { | |
| /// UTC offset formatted like "+03:00". | |
| pub utc_offset: String, | |
| } | |
| pub enum SearchResponseLength { | |
| Short, | |
| Medium, | |
| Long, | |
| } | |
| pub enum ExternalWebAccessMode { | |
| Cached, | |
| Indexed, | |
| Live, | |
| } | |
| pub enum ExternalWebAccess { | |
| Boolean(bool), | |
| Mode(ExternalWebAccessMode), | |
| } | |
| pub struct SearchSettings { | |
| pub user_location: Option<ApproximateLocation>, | |
| pub search_context_size: Option<SearchContextSize>, | |
| pub filters: Option<SearchFilters>, | |
| pub image_settings: Option<SearchImageSettings>, | |
| pub allowed_callers: Option<Vec<AllowedCaller>>, | |
| pub external_web_access: Option<ExternalWebAccess>, | |
| } | |
| pub struct ApproximateLocation { | |
| pub r#type: LocationType, | |
| pub country: Option<String>, | |
| pub region: Option<String>, | |
| pub city: Option<String>, | |
| pub timezone: Option<String>, | |
| } | |
| pub enum LocationType { | |
| Approximate, | |
| } | |
| pub enum SearchContextSize { | |
| Low, | |
| Medium, | |
| High, | |
| } | |
| pub struct SearchFilters { | |
| pub allowed_domains: Option<Vec<String>>, | |
| pub blocked_domains: Option<Vec<String>>, | |
| } | |
| pub struct SearchImageSettings { | |
| pub max_results: Option<u64>, | |
| pub caption: Option<bool>, | |
| } | |
| pub enum AllowedCaller { | |
| Direct, | |
| Shell, | |
| CodeInterpreter, | |
| } | |
| pub struct SearchResponse { | |
| pub encrypted_output: Option<String>, | |
| pub output: String, | |
| /// Structured result DTOs are passed to clients out-of-band from `output`. | |
| /// Keep them opaque here so newer result variants remain forward-compatible. | |
| pub results: Option<Vec<JsonValue>>, | |
| } | |