MCPcopy
hub / github.com/Forethought-Technologies/AutoChain / _parse_input

Method _parse_input

autochain/tools/base.py:58–73  ·  view source on GitHub ↗

Convert tool input to pydantic model.

(
        self,
        tool_input: Union[str, Dict],
    )

Source from the content-addressed store, hash-verified

56 return values
57
58 def _parse_input(
59 self,
60 tool_input: Union[str, Dict],
61 ) -> Union[str, Dict[str, Any]]:
62 """Convert tool input to pydantic model."""
63 input_args = self.args_schema
64 if isinstance(tool_input, str):
65 if input_args is not None:
66 key_ = next(iter(input_args.__fields__.keys()))
67 input_args.validate({key_: tool_input})
68 return tool_input
69 else:
70 if input_args is not None:
71 result = input_args.parse_obj(tool_input)
72 return {k: v for k, v in result.dict().items() if k in tool_input}
73 return tool_input
74
75 def _to_args_and_kwargs(self, tool_input: Union[str, Dict]) -> Tuple[Tuple, Dict]:
76 # For backwards compatibility, if run_input is a string,

Callers 1

runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected