1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Web search related types and configurations
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// Web search configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WebSearchConfig {
/// Whether web search is enabled
pub enabled: bool,
/// Maximum number of search results to retrieve
pub max_results: Option<u32>,
/// Search context size for providers that support it
pub context_size: Option<WebSearchContextSize>,
/// Custom search prompt for result integration
pub search_prompt: Option<String>,
/// Web search implementation strategy
pub strategy: WebSearchStrategy,
/// Provider-specific search parameters
pub provider_params: HashMap<String, serde_json::Value>,
}
impl Default for WebSearchConfig {
fn default() -> Self {
Self {
enabled: false,
max_results: Some(5),
context_size: None,
search_prompt: None,
strategy: WebSearchStrategy::Auto,
provider_params: HashMap::new(),
}
}
}
/// Web search context size for providers that support it
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum WebSearchContextSize {
Small,
Medium,
Large,
}
/// Web search implementation strategy
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum WebSearchStrategy {
/// Automatically choose the best strategy for the provider
Auto,
/// Use provider's built-in search tools (`OpenAI` Responses API, xAI Live Search)
BuiltIn,
/// Use provider's web search tool (Anthropic `web_search` tool)
Tool,
/// Use external search API and inject results into context
External,
}
/// Web search result
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WebSearchResult {
/// Search result title
pub title: String,
/// Search result URL
pub url: String,
/// Search result snippet/description
pub snippet: String,
/// Additional metadata
pub metadata: HashMap<String, serde_json::Value>,
}