Update simplemind/chains/reverse_text.py

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
2024-10-28 09:12:51 -04:00
committed by GitHub
parent 2fc24bc949
commit 60e52d15b3
+20 -1
View File
@@ -2,5 +2,24 @@ from .base import BaseChain
class ReverseTextChain(BaseChain):
def run(self, input_data):
"""Chain that reverses input text.
This chain takes a text input and returns it reversed. For example,
"hello" becomes "olleh".
"""
def run(self, input_data: str) -> str:
"""Reverse the input text.
Args:
input_data: The text to reverse.
Returns:
The reversed text.
Raises:
TypeError: If input_data is not a string.
"""
if not isinstance(input_data, str):
raise TypeError("Input must be a string")
return input_data[::-1]