(&self)
| 167 | } |
| 168 | |
| 169 | fn get_tools(&self) -> Vec<Tool> { |
| 170 | let mut tool_calls = Vec::new(); |
| 171 | for (name, fn_def) in &self.tools { |
| 172 | let properties = fn_def |
| 173 | .params |
| 174 | .iter() |
| 175 | .map(|(name, ty)| { |
| 176 | ( |
| 177 | name.to_owned(), |
| 178 | Box::new(JSONSchemaDefine { |
| 179 | schema_type: Some(JSONSchemaType::from(*ty)), |
| 180 | ..Default::default() |
| 181 | }), |
| 182 | ) |
| 183 | }) |
| 184 | .collect(); |
| 185 | let tool_call = Tool { |
| 186 | r#type: ToolType::Function, |
| 187 | function: types::Function { |
| 188 | name: name.clone(), |
| 189 | description: Some(fn_def.doc.clone()), |
| 190 | parameters: FunctionParameters { |
| 191 | schema_type: JSONSchemaType::Object, |
| 192 | properties: Some(properties), |
| 193 | required: Some(fn_def.params.keys().cloned().collect()), |
| 194 | }, |
| 195 | }, |
| 196 | }; |
| 197 | tool_calls.push(tool_call); |
| 198 | } |
| 199 | tool_calls |
| 200 | } |
| 201 | |
| 202 | fn handle_tool_call( |
| 203 | &self, |
no test coverage detected