2022-12-13 14:46:01 +00:00
|
|
|
"""Utils for LLM Tests."""
|
|
|
|
|
2022-12-18 21:22:42 +00:00
|
|
|
from langchain.llms.base import BaseLLM
|
2022-12-13 14:46:01 +00:00
|
|
|
|
|
|
|
|
2022-12-18 21:22:42 +00:00
|
|
|
def assert_llm_equality(llm: BaseLLM, loaded_llm: BaseLLM) -> None:
|
2022-12-13 14:46:01 +00:00
|
|
|
"""Assert LLM Equality for tests."""
|
|
|
|
# Check that they are the same type.
|
|
|
|
assert type(llm) == type(loaded_llm)
|
|
|
|
# Client field can be session based, so hash is different despite
|
|
|
|
# all other values being the same, so just assess all other fields
|
|
|
|
for field in llm.__fields__.keys():
|
2022-12-17 15:00:04 +00:00
|
|
|
if field != "client" and field != "pipeline":
|
2022-12-13 14:46:01 +00:00
|
|
|
val = getattr(llm, field)
|
|
|
|
new_val = getattr(loaded_llm, field)
|
|
|
|
assert new_val == val
|