fix: OSS Python SDK hygiene batch, 9 small bug fixes (#6770)

This commit is contained in:
Kartik
2026-08-03 20:36:28 +05:30
committed by GitHub
parent 5f77d86caf
commit 8ca9a0f2c0
17 changed files with 201 additions and 86 deletions
@@ -94,7 +94,7 @@ def test_embed_with_huggingface_base_url():
embedder = HuggingFaceEmbedding(config)
result = embedder.embed("Hello from custom endpoint")
mock_openai.assert_called_once_with(base_url="http://localhost:8080")
mock_openai.assert_called_once_with(base_url="http://localhost:8080", api_key=None)
mock_client.embeddings.create.assert_called_once_with(
input="Hello from custom endpoint",
model="my-custom-model",
@@ -103,6 +103,18 @@ def test_embed_with_huggingface_base_url():
assert result == [0.1, 0.2, 0.3]
def test_embed_with_huggingface_base_url_forwards_api_key():
config = BaseEmbedderConfig(
huggingface_base_url="http://localhost:8080",
model="my-custom-model",
api_key="tei-token",
)
with patch("mem0.embeddings.huggingface.OpenAI") as mock_openai:
HuggingFaceEmbedding(config)
mock_openai.assert_called_once_with(base_url="http://localhost:8080", api_key="tei-token")
def test_embed_batch_sentence_transformer(mock_sentence_transformer):
config = BaseEmbedderConfig()
embedder = HuggingFaceEmbedding(config)