Prepare chain inputs, including adding inputs from memory. Args: inputs: Dictionary of raw inputs, or single input if chain expects only one param. Should contain all inputs specified in `Chain.input_keys` except for inputs that will be set by the
(self, inputs: Union[Dict[str, Any], Any])
| 490 | return {**inputs, **outputs} |
| 491 | |
| 492 | def prep_inputs(self, inputs: Union[Dict[str, Any], Any]) -> Dict[str, str]: |
| 493 | """Prepare chain inputs, including adding inputs from memory. |
| 494 | |
| 495 | Args: |
| 496 | inputs: Dictionary of raw inputs, or single input if chain expects |
| 497 | only one param. Should contain all inputs specified in |
| 498 | `Chain.input_keys` except for inputs that will be set by the chain's |
| 499 | memory. |
| 500 | |
| 501 | Returns: |
| 502 | A dictionary of all inputs, including those added by the chain's memory. |
| 503 | """ |
| 504 | if not isinstance(inputs, dict): |
| 505 | _input_keys = set(self.input_keys) |
| 506 | if self.memory is not None: |
| 507 | # If there are multiple input keys, but some get set by memory so that |
| 508 | # only one is not set, we can still figure out which key it is. |
| 509 | _input_keys = _input_keys.difference(self.memory.memory_variables) |
| 510 | inputs = {list(_input_keys)[0]: inputs} |
| 511 | if self.memory is not None: |
| 512 | external_context = self.memory.load_memory_variables(inputs) |
| 513 | inputs = dict(inputs, **external_context) |
| 514 | return inputs |
| 515 | |
| 516 | async def aprep_inputs(self, inputs: Union[Dict[str, Any], Any]) -> Dict[str, str]: |
| 517 | """Prepare chain inputs, including adding inputs from memory. |
no test coverage detected