OpenAITextEmbedding
public class OpenAITextEmbedding implements EmbeddingModel
io/agentscope/core/embedding/openai/OpenAITextEmbedding.java:46–324OpenAI 文本向量化,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.core.embedding.openai 包,实现 EmbeddingModel。核心成员包括 builder、embed、getModelName、getDimensions、OpenAITextEmbedding。
OpenAI Text Embedding Model implementation.
This implementation provides access to OpenAI's text embedding API, supporting both single text embedding and batch embedding operations.
Supports only TextBlock content blocks. Other content block types will result in
an EmbeddingException.
Supports timeout and retry configuration through ExecutionConfig.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | OpenAITextEmbedding的构建器。 Builder for OpenAITextEmbedding. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public OpenAITextEmbedding(String apiKey, String modelName, int dimensions, ExecutionConfig defaultExecutionConfig, String baseUrl) | 创建新的OpenAI 文本向量化模型实例。 Creates a new OpenAI text embedding model instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static Builder builder()static | 创建新的构建器用于 OpenAITextEmbedding。 Creates a new builder for OpenAITextEmbedding. |
public Mono<double[]> embed(ContentBlock block) | 设置该参数。 Performs the embed operation. |
public String getModelName() | 获取模型名称。 Returns the model name. |
public int getDimensions() | 获取维度。 Returns the dimensions. |
构造器详情Constructor Detail
OpenAITextEmbedding
public OpenAITextEmbedding(String apiKey, String modelName, int dimensions, ExecutionConfig defaultExecutionConfig, String baseUrl)
创建新的OpenAI 文本向量化模型实例。
Creates a new OpenAI text embedding model instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
apiKey | String | API 键(类型 `String`)。the API key for OpenAI authentication |
modelName | String | 模型名称(类型 `String`)。the model name (e.g., "text-embedding-3-small") |
dimensions | int | 向量化向量的维度。the dimension of embedding vectors |
defaultExecutionConfig | ExecutionConfig | 用于超时和重试的默认执行配置。default execution configuration for timeout and retry |
baseUrl | String | 基类 URL(类型 `String`)。custom base URL for OpenAI API (null for default) |
io/agentscope/core/embedding/openai/OpenAITextEmbedding.java:66–78方法详情Method Detail
builder
public static Builder builder()
创建新的构建器用于 OpenAITextEmbedding。
Creates a new builder for OpenAITextEmbedding.
Builderio/agentscope/core/embedding/openai/OpenAITextEmbedding.java:85–87embed
public Mono<double[]> embed(ContentBlock block)
设置该参数。
Performs the embed operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
block | ContentBlock | 内容块(类型 `ContentBlock`)。The block. |
Mono<double[]>io/agentscope/core/embedding/openai/OpenAITextEmbedding.java:89–219getModelName
public String getModelName()
获取模型名称。
Returns the model name.
Stringio/agentscope/core/embedding/openai/OpenAITextEmbedding.java:221–224getDimensions
public int getDimensions()
获取维度。
Returns the dimensions.
intio/agentscope/core/embedding/openai/OpenAITextEmbedding.java:226–229嵌套类详情Nested Class Detail
Builder
public static class BuilderOpenAITextEmbedding的构建器。位于 io.agentscope.core.embedding.openai 包。核心成员包括 apiKey、modelName、dimensions、executionConfig、baseUrl、build。
Builder for OpenAITextEmbedding.