forked from Marker-Inc-Korea/AutoRAG
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Um Changyong
committed
Dec 26, 2024
1 parent
b24d95f
commit bd7a60b
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
from autorag.embedding.base import EmbeddingModel | ||
|
||
|
||
def test_load_embedding_model(): | ||
# Test loading a supported embedding model | ||
embedding = EmbeddingModel.load("mock") | ||
assert embedding is not None | ||
|
||
# Test loading an unsupported embedding model | ||
with pytest.raises( | ||
ValueError, match="Embedding model 'unsupported_model' is not supported" | ||
): | ||
EmbeddingModel.load("unsupported_model") | ||
|
||
|
||
def test_load_embedding_model_from_dict(): | ||
# Test loading with missing keys | ||
with pytest.raises( | ||
ValueError, match="Both 'type' and 'model_name' must be provided" | ||
): | ||
EmbeddingModel.load_from_dict([{"type": "openai"}]) | ||
|
||
# Test loading with unsupported type | ||
with pytest.raises( | ||
ValueError, match="Embedding model type 'unsupported_type' is not supported" | ||
): | ||
EmbeddingModel.load_from_dict( | ||
[{"type": "unsupported_type", "model_name": "some-model"}] | ||
) | ||
|
||
# Test loading with multiple items | ||
with pytest.raises(ValueError, match="Only one embedding model is supported"): | ||
EmbeddingModel.load_from_dict( | ||
[ | ||
{"type": "openai", "model_name": "text-embedding-ada-002"}, | ||
{"type": "huggingface", "model_name": "BAAI/bge-small-en-v1.5"}, | ||
] | ||
) |