(
tools: Optional[List[ChatTemplateTool]],
)
| 5188 | |
| 5189 | @staticmethod |
| 5190 | def _tool_schema_map( |
| 5191 | tools: Optional[List[ChatTemplateTool]], |
| 5192 | ) -> Dict[str, Dict[str, Any]]: |
| 5193 | if tools is None: |
| 5194 | return {} |
| 5195 | mapping: Dict[str, Dict[str, Any]] = {} |
| 5196 | for tool in tools: |
| 5197 | if tool.get("type") != "function": |
| 5198 | continue |
| 5199 | function = tool.get("function", {}) |
| 5200 | name = function.get("name") |
| 5201 | parameters = function.get("parameters") |
| 5202 | if isinstance(name, str) and isinstance(parameters, dict): |
| 5203 | mapping[name] = { |
| 5204 | "parameters": parameters, |
| 5205 | "content_type": function.get("content_type"), |
| 5206 | } |
| 5207 | return mapping |
| 5208 | |
| 5209 | @classmethod |
| 5210 | def _cached_tool_schema_map( |
no outgoing calls
no test coverage detected