mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-09 11:25:21 +03:00
In second section it looks like a copy/paste from the first section and doesn't include the specific embedding model mentioned in the example so I added it for clarity. --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
5.3 KiB
5.3 KiB
In [6]:
from langchain.embeddings import OpenAIEmbeddingsIn [29]:
embeddings = OpenAIEmbeddings()In [30]:
text = "This is a test document."In [31]:
query_result = embeddings.embed_query(text)In [32]:
query_result[:5]Out [32]:
[-0.003186025367556387, 0.011071979803637493, -0.004020420763285827, -0.011658221276953042, -0.0010534035786864363]
In [33]:
doc_result = embeddings.embed_documents([text])In [34]:
doc_result[0][:5]Out [34]:
[-0.003186025367556387, 0.011071979803637493, -0.004020420763285827, -0.011658221276953042, -0.0010534035786864363]
In [1]:
from langchain.embeddings.openai import OpenAIEmbeddingsIn [23]:
embeddings = OpenAIEmbeddings(model="text-search-ada-doc-001")In [24]:
text = "This is a test document."In [25]:
query_result = embeddings.embed_query(text)In [26]:
query_result[:5]Out [26]:
[0.004452846988523035, 0.034550655976098514, -0.015029939040690051, 0.03827273883655212, 0.005785414075152477]
In [27]:
doc_result = embeddings.embed_documents([text])In [28]:
doc_result[0][:5]Out [28]:
[0.004452846988523035, 0.034550655976098514, -0.015029939040690051, 0.03827273883655212, 0.005785414075152477]
In [ ]:
# if you are behind an explicit proxy, you can use the OPENAI_PROXY environment variable to pass through
os.environ["OPENAI_PROXY"] = "http://proxy.yourcompany.com:8080"