def prep_output(
        self,
        inputs: Dict[str, str],
        output: AgentFinish,
        return_only_outputs: bool = False,
    ) -> Dict[str, Any]:
        """Save conversation into memory and prep outputs."""
        output_dict = output.format_output()
        if self.memory is not None:
            self.memory.save_conversation(
                message=output.message, message_type=MessageType.AIMessage
            )
            self.memory.save_memory(
                key=constants.INTERMEDIATE_STEPS, value=output.intermediate_steps
            )

        if return_only_outputs:
            return output_dict
        else:
            return {**inputs, **output_dict}
Save conversation into memory and prep outputs.
autochain/chain/base_chain.py