Convert tool input to pydantic model.
(
self,
tool_input: Union[str, Dict],
)
| 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, |