subtract.py
1 # SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai> 2 # 3 # SPDX-License-Identifier: Apache-2.0 4 5 from haystack.core.component import component 6 7 8 @component 9 class Subtract: 10 """ 11 Compute the difference between two values. 12 """ 13 14 @component.output_types(difference=int) 15 def run(self, first_value: int, second_value: int): 16 """ 17 Run the component. 18 19 :param first_value: name of the connection carrying the value to subtract from. 20 :param second_value: name of the connection carrying the value to subtract. 21 """ 22 return {"difference": first_value - second_value}