MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / _primitive_schema

Function _primitive_schema

utils/function_catalog.py:281–300  ·  view source on GitHub ↗
(annotation: Any)

Source from the content-addressed store, hash-verified

279
280
281def _primitive_schema(annotation: Any) -> Dict[str, Any]:
282 if isinstance(annotation, type) and issubclass(annotation, Enum):
283 values = [member.value for member in annotation]
284 schema = _literal_schema(values)
285 return schema if schema else {"type": "string"}
286
287 if annotation in {str}:
288 return {"type": "string"}
289 if annotation in {int}:
290 return {"type": "integer"}
291 if annotation in {float}:
292 return {"type": "number"}
293 if annotation in {bool}:
294 return {"type": "boolean"}
295 if annotation in {dict, abc.Mapping}:
296 return {"type": "object"}
297 if annotation in {list, abc.Sequence}:
298 return {"type": "array", "items": {"type": "string"}}
299
300 return {"type": "string"}
301
302
303def _apply_param_meta(schema: Dict[str, Any], meta: ParamMeta | None) -> Dict[str, Any]:

Callers 1

_annotation_to_schemaFunction · 0.85

Calls 1

_literal_schemaFunction · 0.85

Tested by

no test coverage detected