6大核心模块(Modules)
示例
OpenAI

LangChain

OpenAI#

让我们加载OpenAI嵌入类。

from langchain.embeddings import OpenAIEmbeddings
 
embeddings = OpenAIEmbeddings()
 
text = "This is a test document."
 
query_result = embeddings.embed_query(text)
 
doc_result = embeddings.embed_documents([text])
 

让我们加载带有第一代模型(例如“text-search-ada-doc-001 / text-search-ada-query-001”)的OpenAI嵌入类。注意:这些不是推荐的模型-请参见此处 (opens in a new tab)

from langchain.embeddings.openai import OpenAIEmbeddings
 
embeddings = OpenAIEmbeddings()
 
text = "This is a test document."
 
query_result = embeddings.embed_query(text)
 
doc_result = embeddings.embed_documents([text])