[Misc] Lint code and fix code smells (#1871)

This commit is contained in:
Deshraj Yadav
2024-09-16 17:39:54 -07:00
committed by GitHub
parent 0a78cb9f7a
commit 55c54beeab
57 changed files with 1178 additions and 1357 deletions

View File

@@ -37,9 +37,7 @@ def test_embed_custom_model(mock_sentence_transformer):
def test_embed_with_model_kwargs(mock_sentence_transformer):
config = BaseEmbedderConfig(
model="all-MiniLM-L6-v2", model_kwargs={"device": "cuda"}
)
config = BaseEmbedderConfig(model="all-MiniLM-L6-v2", model_kwargs={"device": "cuda"})
embedder = HuggingFaceEmbedding(config)
mock_sentence_transformer.encode.return_value = [0.7, 0.8, 0.9]

View File

@@ -23,9 +23,7 @@ def test_embed_text(mock_ollama_client):
text = "Sample text to embed."
embedding = embedder.embed(text)
mock_ollama_client.embeddings.assert_called_once_with(
model="nomic-embed-text", prompt=text
)
mock_ollama_client.embeddings.assert_called_once_with(model="nomic-embed-text", prompt=text)
assert embedding == [0.1, 0.2, 0.3, 0.4, 0.5]

View File

@@ -21,9 +21,7 @@ def test_embed_default_model(mock_openai_client):
result = embedder.embed("Hello world")
mock_openai_client.embeddings.create.assert_called_once_with(
input=["Hello world"], model="text-embedding-3-small"
)
mock_openai_client.embeddings.create.assert_called_once_with(input=["Hello world"], model="text-embedding-3-small")
assert result == [0.1, 0.2, 0.3]
@@ -51,9 +49,7 @@ def test_embed_removes_newlines(mock_openai_client):
result = embedder.embed("Hello\nworld")
mock_openai_client.embeddings.create.assert_called_once_with(
input=["Hello world"], model="text-embedding-3-small"
)
mock_openai_client.embeddings.create.assert_called_once_with(input=["Hello world"], model="text-embedding-3-small")
assert result == [0.7, 0.8, 0.9]