Class OpenAITextEmbedding.Builder
java.lang.Object
io.agentscope.core.embedding.openai.OpenAITextEmbedding.Builder
- Enclosing class:
- OpenAITextEmbedding
Builder for OpenAITextEmbedding.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the API key for OpenAI authentication.Sets a custom base URL for OpenAI API.build()Builds the OpenAITextEmbedding instance.dimensions(int dimensions) Sets the dimension of embedding vectors.executionConfig(io.agentscope.core.model.ExecutionConfig config) Sets the default execution configuration.Sets the model name to use.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
apiKey
Sets the API key for OpenAI authentication.- Parameters:
apiKey- the API key- Returns:
- this builder instance
-
modelName
Sets the model name to use.- Parameters:
modelName- the model name (e.g., "text-embedding-3-small")- Returns:
- this builder instance
-
dimensions
Sets the dimension of embedding vectors.- Parameters:
dimensions- the dimension- Returns:
- this builder instance
-
executionConfig
Sets the default execution configuration.- Parameters:
config- the execution config (null for defaults)- Returns:
- this builder instance
-
baseUrl
Sets a custom base URL for OpenAI API.- Parameters:
baseUrl- the base URL (null for default)- Returns:
- this builder instance
-
build
Builds the OpenAITextEmbedding instance.This method validates required parameters and ensures that the defaultExecutionConfig always has proper defaults applied using EmbeddingUtils.ensureDefaultExecutionConfig().
- Returns:
- configured OpenAITextEmbedding instance
- Throws:
IllegalStateException- if required parameters are missing or invalid
-