MCPcopy Create free account
hub / github.com/Mercury7353/PyBench / property2dict

Function property2dict

llms/utils.py:6–28  ·  view source on GitHub ↗

把传入的ToolProperty转换为OpenAI接口需要的dict格式 Args: property (ToolProperty): ToolProperty对话 Returns: Dict: 参数的dict形式描述

(property_: ToolProperty)

Source from the content-addressed store, hash-verified

4
5
6def property2dict(property_: ToolProperty) -> Dict:
7 """把传入的ToolProperty转换为OpenAI接口需要的dict格式
8
9 Args:
10 property (ToolProperty): ToolProperty对话
11
12 Returns:
13 Dict: 参数的dict形式描述
14 """
15 new_property = {"type": property_.type.value}
16 if property_.description is not None:
17 new_property["description"] = property_.description
18 if property_.type == DataType.OBJECT:
19 new_property["properties"] = {
20 key: property2dict(value) for key, value in property_.properties.items()
21 }
22 if property_.required is not None:
23 new_property["required"] = property_.required
24 elif property_.type == DataType.ARRAY:
25 new_property["items"] = property2dict(property_.items)
26 elif property_.enum is not None:
27 new_property["enum"] = property_.enum
28 return new_property
29
30
31def tool2dict(tool: Tool) -> Dict[str, str]:

Callers 1

tool2dictFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected