use serde_json::{json, Value};
#[must_use]
pub fn code_interpreter(container: Option<String>) -> Value {
let mut tool = json!({ "type": "code_interpreter" });
if let Some(c) = container {
tool["container"] = json!(c);
}
tool
}
#[must_use]
pub fn file_search(vector_store_ids: Vec<String>, max_num_results: Option<u32>) -> Value {
let mut tool = json!({
"type": "file_search",
"vector_store_ids": vector_store_ids,
});
if let Some(m) = max_num_results {
tool["max_num_results"] = json!(m);
}
tool
}
#[must_use]
pub fn web_search_preview(search_context_size: Option<String>) -> Value {
let mut tool = json!({ "type": "web_search_preview" });
if let Some(s) = search_context_size {
tool["search_context_size"] = json!(s);
}
tool
}
#[must_use]
pub fn web_search(
search_context_size: Option<String>,
user_location: Option<Value>,
filters: Option<Value>,
) -> Value {
let mut tool = json!({ "type": "web_search" });
if let Some(s) = search_context_size {
tool["search_context_size"] = json!(s);
}
if let Some(ul) = user_location {
tool["user_location"] = ul;
}
if let Some(f) = filters {
tool["filters"] = f;
}
tool
}
#[must_use]
pub fn image_generation(
model: Option<String>,
quality: Option<String>,
size: Option<String>,
background: Option<String>,
output_format: Option<String>,
) -> Value {
let mut tool = json!({ "type": "image_generation" });
if let Some(m) = model {
tool["model"] = json!(m);
}
if let Some(q) = quality {
tool["quality"] = json!(q);
}
if let Some(s) = size {
tool["size"] = json!(s);
}
if let Some(b) = background {
tool["background"] = json!(b);
}
if let Some(f) = output_format {
tool["output_format"] = json!(f);
}
tool
}
#[must_use]
pub fn shell() -> Value {
json!({ "type": "shell" })
}
#[must_use]
pub fn local_shell() -> Value {
json!({ "type": "local_shell" })
}
#[must_use]
pub fn apply_patch() -> Value {
json!({ "type": "apply_patch" })
}
#[must_use]
pub fn custom_tool(name: String, description: Option<String>, format: Option<Value>) -> Value {
let mut tool = json!({
"type": "custom_tool",
"name": name,
});
if let Some(d) = description {
tool["description"] = json!(d);
}
if let Some(f) = format {
tool["format"] = f;
}
tool
}
#[must_use]
pub fn mcp(
server_label: String,
server_url: Option<String>,
allowed_tools: Option<Value>,
headers: Option<Value>,
) -> Value {
let mut tool = json!({
"type": "mcp",
"server_label": server_label,
});
if let Some(u) = server_url {
tool["server_url"] = json!(u);
}
if let Some(at) = allowed_tools {
tool["allowed_tools"] = at;
}
if let Some(h) = headers {
tool["headers"] = h;
}
tool
}
#[must_use]
pub fn tool_search() -> Value {
json!({ "type": "tool_search" })
}