langchain/libs/experimental/tests/unit_tests/rl_chain/test_utils.py

16 lines
447 B
Python
Raw Normal View History

2023-09-04 11:10:44 +00:00
from typing import Any, List
class MockEncoder:
2023-08-28 10:58:33 +00:00
def encode(self, to_encode: str) -> str:
return "[encoded]" + to_encode
2023-09-04 11:10:44 +00:00
class MockEncoderReturnsList:
def encode(self, to_encode: Any) -> List:
if isinstance(to_encode, str):
return [1.0, 2.0]
elif isinstance(to_encode, List):
return [[1.0, 2.0] for _ in range(len(to_encode))]
raise ValueError("Invalid input type for unit test")