Class OpenAIEmbeddings
java.lang.Object
com.hw.langchain.embeddings.openai.OpenAIEmbeddings
- All Implemented Interfaces:
Embeddings
Wrapper around OpenAI embedding models.
To use, you should have the environment variable OPENAI_API_KEY set with your API key or pass it as a named parameter to the constructor.
- Author:
- HamaWhite
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected long
Timeout for requests to OpenAI completion API. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionembeddingFunc
(String text) Call out to OpenAI's embedding endpoint.embedDocuments
(List<String> texts) Call out to OpenAI's embedding endpoint for embedding search docs.embedQuery
(String text) Call out to OpenAI's embedding endpoint for embedding query text.embedWithRetry
(List<?> input) init()
Validate parameters and init client
-
Field Details
-
openaiOrganization
-
requestTimeout
protected long requestTimeoutTimeout for requests to OpenAI completion API. Default is 16 seconds.
-
-
Constructor Details
-
OpenAIEmbeddings
public OpenAIEmbeddings()
-
-
Method Details
-
init
Validate parameters and init client -
embeddingFunc
Call out to OpenAI's embedding endpoint. -
embedDocuments
Call out to OpenAI's embedding endpoint for embedding search docs.- Specified by:
embedDocuments
in interfaceEmbeddings
- Parameters:
texts
- The list of texts to embed.- Returns:
- List of embeddings, one for each text.
-
embedQuery
Call out to OpenAI's embedding endpoint for embedding query text.- Specified by:
embedQuery
in interfaceEmbeddings
- Parameters:
text
- The text to embed.- Returns:
- Embedding for the text.
-
embedWithRetry
-