Package org.apache.tika.inference
Class OpenAIEmbeddingFilter
java.lang.Object
org.apache.tika.metadata.filter.MetadataFilter
org.apache.tika.inference.AbstractEmbeddingFilter
org.apache.tika.inference.OpenAIEmbeddingFilter
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable,SelfConfiguring
- Direct Known Subclasses:
JinaEmbeddingFilter
Deprecated.
Metadata filter that calls an OpenAI-compatible
/v1/embeddings
endpoint to produce vectors for each text chunk.
Works with OpenAI, vLLM, Ollama, sentence-transformers servers, and any endpoint that implements the OpenAI Embeddings API.
Configuration key: "openai-embedding-filter"
- Since:
- Apache Tika 4.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Deprecated.Releases any resources held by this filter (e.g.protected voidembed(List<Chunk> chunks, InferenceConfig config, ParseContext parseContext) Deprecated.Call the embeddings endpoint to fill in vectors on each chunk.Deprecated.Deprecated.protected StringDeprecated.The@TikaComponentname this filter's per-request JSON config is keyed by in parse-context (e.g.Deprecated.voidsetApiKeyHeaderName(String apiKeyHeaderName) Deprecated.Set the HTTP header name for API key authentication.voidsetApiKeyPrefix(String apiKeyPrefix) Deprecated.Set the prefix prepended to the API key in the auth header.voidsetEmbeddingsPath(String embeddingsPath) Deprecated.Set the URL path for embeddings requests.Methods inherited from class org.apache.tika.inference.AbstractEmbeddingFilter
doFilter, getApiKey, getBaseUrl, getContentField, getDefaultConfig, getMaxBatchSize, getMaxChunkChars, getMaxChunks, getModel, getOutputField, getOverlapChars, getTimeoutMillis, isClearContentAfterChunking, isSkipEmbedding, setApiKey, setBaseUrl, setClearContentAfterChunking, setContentField, setMaxBatchSize, setMaxChunkChars, setMaxChunks, setModel, setOutputField, setOverlapChars, setSkipEmbedding, setTimeoutMillisMethods inherited from class org.apache.tika.metadata.filter.MetadataFilter
filter, filter
-
Constructor Details
-
OpenAIEmbeddingFilter
public OpenAIEmbeddingFilter()Deprecated. -
OpenAIEmbeddingFilter
Deprecated.
-
-
Method Details
-
getComponentName
Deprecated.Description copied from class:AbstractEmbeddingFilterThe@TikaComponentname this filter's per-request JSON config is keyed by in parse-context (e.g.{"openai-embedding-filter": {...}}).- Specified by:
getComponentNamein classAbstractEmbeddingFilter
-
close
Deprecated.Description copied from class:MetadataFilterReleases any resources held by this filter (e.g. HTTP connection pools, thread pools). The default implementation is a no-op; filters that hold long-lived resources should override this.Callers that control the filter lifecycle (e.g.
PipesServer, try-with-resources blocks) should call this when the filter is no longer needed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classMetadataFilter- Throws:
IOException
-
embed
protected void embed(List<Chunk> chunks, InferenceConfig config, ParseContext parseContext) throws IOException, TikaException Deprecated.Description copied from class:AbstractEmbeddingFilterCall the embeddings endpoint to fill in vectors on each chunk. Implementations should setChunk.setVector(float[])on each chunk in the list.- Specified by:
embedin classAbstractEmbeddingFilter- Parameters:
chunks- the text chunks to embedconfig- the resolved config for this callparseContext- the task's ParseContext -- pass toTikaHttpClientcalls to bound the request by the task's remaining budget and checkpoint while waiting- Throws:
IOException- on HTTP errorsTikaException- on API-level errors
-
getEmbeddingsPath
Deprecated. -
setEmbeddingsPath
Deprecated.Set the URL path for embeddings requests. Default is/v1/embeddings. For Azure OpenAI, use/openai/deployments/{deployment}/embeddings?api-version=2024-02-01. -
getApiKeyHeaderName
Deprecated. -
setApiKeyHeaderName
Deprecated.Set the HTTP header name for API key authentication. Default isAuthorization. For Azure OpenAI, set toapi-key. -
getApiKeyPrefix
Deprecated. -
setApiKeyPrefix
Deprecated.Set the prefix prepended to the API key in the auth header. Default is"Bearer "(with trailing space). For Azure OpenAI, set to""(empty string).
-
AbstractEmbeddingFilter.