mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-18 09:01:03 +00:00
Signed-off-by: ChengZi <chen.zhang@zilliz.com> Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com> Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com> Co-authored-by: Dan O'Donovan <dan.odonovan@gmail.com> Co-authored-by: Tom Daniel Grande <tomdgrande@gmail.com> Co-authored-by: Grande <Tom.Daniel.Grande@statsbygg.no> Co-authored-by: Bagatur <baskaryan@gmail.com> Co-authored-by: ccurme <chester.curme@gmail.com> Co-authored-by: Harrison Chase <hw.chase.17@gmail.com> Co-authored-by: Tomaz Bratanic <bratanic.tomaz@gmail.com> Co-authored-by: ZhangShenao <15201440436@163.com> Co-authored-by: Friso H. Kingma <fhkingma@gmail.com> Co-authored-by: ChengZi <chen.zhang@zilliz.com> Co-authored-by: Nuno Campos <nuno@langchain.dev> Co-authored-by: Morgante Pell <morgantep@google.com>
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
"""Test embedding model integration."""
|
|
|
|
from langchain_core.embeddings import Embeddings
|
|
|
|
from langchain_voyageai import VoyageAIEmbeddings
|
|
|
|
MODEL = "voyage-2"
|
|
|
|
|
|
def test_initialization_voyage_2() -> None:
|
|
"""Test embedding model initialization."""
|
|
emb = VoyageAIEmbeddings(api_key="NOT_A_VALID_KEY", model=MODEL) # type: ignore
|
|
assert isinstance(emb, Embeddings)
|
|
assert emb.batch_size == 72
|
|
assert emb.model == MODEL
|
|
assert emb._client is not None
|
|
|
|
|
|
def test_initialization_voyage_2_with_full_api_key_name() -> None:
|
|
"""Test embedding model initialization."""
|
|
# Testing that we can initialize the model using `voyage_api_key`
|
|
# instead of `api_key`
|
|
emb = VoyageAIEmbeddings(voyage_api_key="NOT_A_VALID_KEY", model=MODEL) # type: ignore
|
|
assert isinstance(emb, Embeddings)
|
|
assert emb.batch_size == 72
|
|
assert emb.model == MODEL
|
|
assert emb._client is not None
|
|
|
|
|
|
def test_initialization_voyage_1() -> None:
|
|
"""Test embedding model initialization."""
|
|
emb = VoyageAIEmbeddings(api_key="NOT_A_VALID_KEY", model="voyage-01") # type: ignore
|
|
assert isinstance(emb, Embeddings)
|
|
assert emb.batch_size == 7
|
|
assert emb.model == "voyage-01"
|
|
assert emb._client is not None
|
|
|
|
|
|
def test_initialization_voyage_1_batch_size() -> None:
|
|
"""Test embedding model initialization."""
|
|
emb = VoyageAIEmbeddings(
|
|
api_key="NOT_A_VALID_KEY", # type: ignore
|
|
model="voyage-01",
|
|
batch_size=15,
|
|
)
|
|
assert isinstance(emb, Embeddings)
|
|
assert emb.batch_size == 15
|
|
assert emb.model == "voyage-01"
|
|
assert emb._client is not None
|