mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-10 11:55:11 +03:00
3.7 KiB
3.7 KiB
In [ ]:
# Set API key
embaas_api_key = "YOUR_API_KEY"
# or set environment variable
os.environ["EMBAAS_API_KEY"] = "YOUR_API_KEY"In [ ]:
from langchain.embeddings import EmbaasEmbeddingsIn [ ]:
embeddings = EmbaasEmbeddings()In [ ]:
# Create embeddings for a single document
doc_text = "This is a test document."
doc_text_embedding = embeddings.embed_query(doc_text)In [ ]:
# Print created embedding
print(doc_text_embedding)In [9]:
# Create embeddings for multiple documents
doc_texts = ["This is a test document.", "This is another test document."]
doc_texts_embeddings = embeddings.embed_documents(doc_texts)In [ ]:
# Print created embeddings
for i, doc_text_embedding in enumerate(doc_texts_embeddings):
print(f"Embedding for document {i + 1}: {doc_text_embedding}")In [11]:
# Using a different model and/or custom instruction
embeddings = EmbaasEmbeddings(
model="instructor-large",
instruction="Represent the Wikipedia document for retrieval",
)