use json.dump

move test to integration tests (since it requires huggingface_hub)
harrison/logging_to_file
Harrison Chase 2 years ago committed by GitHub
parent ae72cf84b8
commit b94244eb12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -94,7 +94,7 @@ class BasePromptTemplate(BaseModel, ABC):
if save_path.suffix == ".json":
with open(file_path, "w") as f:
f.write(json.dumps(prompt_dict, indent=4))
json.dump(prompt_dict, f, indent=4)
elif save_path.suffix == ".yaml":
with open(file_path, "w") as f:
yaml.dump(prompt_dict, f, default_flow_style=False)

@ -1,4 +1,6 @@
"""Test HuggingFaceHub embeddings."""
import pytest
from langchain.embeddings import HuggingFaceHubEmbeddings
@ -17,3 +19,10 @@ def test_huggingfacehub_embedding_query() -> None:
embedding = HuggingFaceHubEmbeddings()
output = embedding.embed_query(document)
assert len(output) == 768
def test_huggingfacehub_embedding_invalid_repo() -> None:
"""Test huggingfacehub embedding repo id validation."""
# Only sentence-transformers models are currently supported.
with pytest.raises(ValueError):
HuggingFaceHubEmbeddings(repo_id="allenai/specter")

@ -1 +0,0 @@
"""All unit tests for Embeddings objects."""

@ -1,11 +0,0 @@
"""Test HuggingFaceHub embeddings."""
import pytest
from langchain.embeddings import HuggingFaceHubEmbeddings
def test_huggingfacehub_embedding_invalid_repo() -> None:
"""Test huggingfacehub embedding repo id validation."""
# Only sentence-transformers models are currently supported.
with pytest.raises(ValueError):
HuggingFaceHubEmbeddings(repo_id="allenai/specter")
Loading…
Cancel
Save