hanzo_engine/tools/
response.rs1#[cfg_attr(feature = "pyo3_macros", pyo3::pyclass(eq, eq_int))]
3#[cfg_attr(feature = "pyo3_macros", pyo3(get_all))]
4#[derive(Clone, Debug, serde::Serialize, PartialEq)]
5#[serde(rename_all = "snake_case")]
6pub enum ToolCallType {
7 Function,
8}
9
10impl std::fmt::Display for ToolCallType {
11 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12 match self {
13 ToolCallType::Function => write!(f, "function"),
14 }
15 }
16}
17
18use hanzo_llm_mcp::CalledFunction;
19
20#[cfg_attr(feature = "pyo3_macros", pyo3::pyclass)]
21#[cfg_attr(feature = "pyo3_macros", pyo3(get_all))]
22#[derive(Clone, Debug, serde::Serialize)]
23pub struct ToolCallResponse {
24 pub index: usize,
25 pub id: String,
26 #[serde(rename = "type")]
27 pub tp: ToolCallType,
28 pub function: CalledFunction,
29}
30
31#[cfg(test)]
32mod tests {
33 use super::*;
34
35 #[test]
36 fn serializes_index_field() {
37 let resp = ToolCallResponse {
38 index: 0,
39 id: "call-1".to_string(),
40 tp: ToolCallType::Function,
41 function: CalledFunction {
42 name: "foo".to_string(),
43 arguments: "{}".to_string(),
44 },
45 };
46
47 let json = serde_json::to_value(&resp).unwrap();
48 assert_eq!(json.get("index").and_then(|v| v.as_u64()), Some(0));
49 }
50}