1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
4#[serde(rename_all = "lowercase")]
5pub enum ToolFormat {
6 #[default]
8 Tools,
9 Functions,
11}
12
13impl ToolFormat {
14 pub fn parse(raw: Option<&str>) -> Self {
15 match raw.map(str::trim).map(str::to_ascii_lowercase).as_deref() {
16 Some("tools") => Self::Tools,
17 Some("functions") | Some("function") | Some("function_calling") => Self::Functions,
18 _ => Self::default(),
19 }
20 }
21}