add embeddings integration tests (#25508)

This commit is contained in:
Isaac Francisco
2024-08-16 13:20:37 -07:00
committed by GitHub
parent a06818a654
commit a2e90a5a43
5 changed files with 95 additions and 15 deletions

View File

@@ -1,20 +1,17 @@
"""Test Ollama embeddings."""
from typing import Type
from langchain_standard_tests.integration_tests import EmbeddingsIntegrationTests
from langchain_ollama.embeddings import OllamaEmbeddings
def test_langchain_ollama_embedding_documents() -> None:
"""Test cohere embeddings."""
documents = ["foo bar"]
embedding = OllamaEmbeddings(model="llama3")
output = embedding.embed_documents(documents)
assert len(output) == 1
assert len(output[0]) > 0
class TestOllamaEmbeddings(EmbeddingsIntegrationTests):
@property
def embeddings_class(self) -> Type[OllamaEmbeddings]:
return OllamaEmbeddings
def test_langchain_ollama_embedding_query() -> None:
"""Test cohere embeddings."""
document = "foo bar"
embedding = OllamaEmbeddings(model="llama3")
output = embedding.embed_query(document)
assert len(output) > 0
@property
def embedding_model_params(self) -> dict:
return {"model": "llama3:latest"}