community[patch]: update OctoAIEmbeddings to subclass OpenAIEmbeddings (#21805)

This commit is contained in:
Sevin F. Varoglu
2024-05-21 21:29:41 +03:00
committed by GitHub
parent ded53297e0
commit 1bc0ea5496
2 changed files with 74 additions and 100 deletions

View File

@@ -8,27 +8,15 @@ from langchain_community.embeddings.octoai_embeddings import (
def test_octoai_embedding_documents() -> None:
"""Test octoai embeddings."""
documents = ["foo bar"]
embedding = OctoAIEmbeddings(
endpoint_url="<endpoint_url>",
octoai_api_token="<octoai_api_token>",
embed_instruction="Represent this input: ",
query_instruction="Represent this input: ",
model_kwargs=None,
)
embedding = OctoAIEmbeddings()
output = embedding.embed_documents(documents)
assert len(output) == 1
assert len(output[0]) == 768
assert len(output[0]) == 1024
def test_octoai_embedding_query() -> None:
"""Test octoai embeddings."""
document = "foo bar"
embedding = OctoAIEmbeddings(
endpoint_url="<endpoint_url>",
octoai_api_token="<octoai_api_token>",
embed_instruction="Represent this input: ",
query_instruction="Represent this input: ",
model_kwargs=None,
)
embedding = OctoAIEmbeddings()
output = embedding.embed_query(document)
assert len(output) == 768
assert len(output) == 1024