mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
b2a11ce686
### Prem SDK integration in LangChain This PR adds the integration with [PremAI's](https://www.premai.io/) prem-sdk with langchain. User can now access to deployed models (llms/embeddings) and use it with langchain's ecosystem. This PR adds the following: ### This PR adds the following: - [x] Add chat support - [X] Adding embedding support - [X] writing integration tests - [X] writing tests for chat - [X] writing tests for embedding - [X] writing unit tests - [X] writing tests for chat - [X] writing tests for embedding - [X] Adding documentation - [X] writing documentation for chat - [X] writing documentation for embedding - [X] run `make test` - [X] run `make lint`, `make lint_diff` - [X] Final checks (spell check, lint, format and overall testing) --------- Co-authored-by: Anindyadeep Sannigrahi <anindyadeepsannigrahi@Anindyadeeps-MacBook-Pro.local> Co-authored-by: Bagatur <baskaryan@gmail.com> Co-authored-by: Erick Friis <erick@langchain.dev> Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""Test PremAIEmbeddings from PremAI API wrapper.
|
|
|
|
Note: This test must be run with the PREMAI_API_KEY environment variable set to a valid
|
|
API key and a valid project_id. This needs to setup a project in PremAI's platform.
|
|
You can check it out here: https://app.premai.io
|
|
"""
|
|
|
|
import pytest
|
|
|
|
from langchain_community.embeddings.premai import PremAIEmbeddings
|
|
|
|
|
|
@pytest.fixture
|
|
def embedder() -> PremAIEmbeddings:
|
|
return PremAIEmbeddings(project_id=8, model="text-embedding-3-small")
|
|
|
|
|
|
def test_prem_embedding_documents(embedder: PremAIEmbeddings) -> None:
|
|
"""Test Prem embeddings."""
|
|
documents = ["foo bar"]
|
|
output = embedder.embed_documents(documents)
|
|
assert len(output) == 1
|
|
assert len(output[0]) == 1536
|
|
|
|
|
|
def test_prem_embedding_documents_multiple(embedder: PremAIEmbeddings) -> None:
|
|
"""Test prem embeddings for multiple queries or documents."""
|
|
documents = ["foo bar", "bar foo", "foo"]
|
|
output = embedder.embed_documents(documents)
|
|
assert len(output) == 3
|
|
assert len(output[0]) == 1536
|
|
assert len(output[1]) == 1536
|
|
assert len(output[2]) == 1536
|
|
|
|
|
|
def test_prem_embedding_query(embedder: PremAIEmbeddings) -> None:
|
|
"""Test Prem embeddings for single query"""
|
|
document = "foo bar"
|
|
output = embedder.embed_query(document)
|
|
assert len(output) == 1536
|