v2.0.0
openaivec v2.0.0 Release Notes
π Highlights
openaivec 2.0 introduces DuckDB as a first-class integration, bringing persistent caching,
SQL-native AI functions, and Arrow-optimized data pipelines. This is a major release with breaking
changes to class names and configuration APIs.
π DuckDB Integration (openaivec.duckdb_ext)
- Arrow Vectorized UDFs β
register_responses_udf,register_embeddings_udf,
register_task_udfregister AI-powered functions directly in DuckDB. Rows are processed in batches
with async concurrency and automatic deduplication β all transparent to SQL. - Structured Output as STRUCT β Pydantic
BaseModelresponse formats return native DuckDB
STRUCTtypes with direct field access in SQL (SELECT udf(text).sentiment). Supports nested
models, Enum, and Literal. - Persistent Cache β
DuckDBCacheBackendstores API results in a DuckDB table with LRU
eviction. Eliminates redundant API calls across sessions. - Vector Similarity β
similarity_search()performs top-k cosine similarity queries via
list_cosine_similarity. - Schema β DDL β
pydantic_to_duckdb_ddl()converts Pydantic models toCREATE TABLE
statements.
β‘ Performance Improvements
- Arrow-backed Embeddings β Embedding results are now stored as
pa.FixedSizeListArray<float32>
in pandas, enabling zero-copy transfer to DuckDB/Parquet and 2-3x memory reduction. - Zero-copy Similarity β
DataFrame.ai.similarity()extracts numpy matrices directly from Arrow
buffers. - DuckDB JSON Serialization β
_df_rows_to_json_seriesuses DuckDB's C++to_json()instead of
Pythonjson.dumps(5-10x faster on large DataFrames). - Batched Token Counting β
count_tokensusestiktoken.encode_batch()for 2-3x speedup.
π Breaking Changes
| Before (v1.x) | After (v2.0) |
|---|---|
BatchingMapProxy |
BatchCache |
AsyncBatchingMapProxy |
AsyncBatchCache |
ProxyBase |
BatchCacheBase |
proxy._cache (private field) |
proxy.cache (public field) |
pandas_ext.set_client() |
openaivec.set_client() |
pandas_ext.set_responses_model() |
openaivec.set_responses_model() |
Migration: pandas_ext.set_* / get_* still work but emit DeprecationWarning. Use
openaivec.set_* / openaivec.get_* instead.
π Architecture Changes
CacheBackendProtocol β Runtime-checkable protocol for pluggable cache backends.
InMemoryCacheBackend(default) andDuckDBCacheBackendboth satisfy it.- Unified Configuration β
set_client,get_client,set_responses_model, etc. defined in
_provider.pyand exported fromopenaivec.*. Shared across pandas, DuckDB, and Spark. - Notebook-safe Async β
_run_async()helper runs coroutines from any context (including
Jupyter) via a background thread.
π¦ New Dependencies
duckdb>=1.0.0β core dependencypyarrow>=19.0.0β core dependency
π Documentation
- New API reference page:
duckdb_ext - New example notebook: DuckDB customer survey sentiment analysis
- README: "Using with DuckDB" section with structured output and embedding examples
- Updated coding conventions:
@dataclassfor all classes, typed fields, DI via fields,of()
factories