Skip to content

v2.0.0

Choose a tag to compare

@piroyoung piroyoung released this 08 Apr 23:55
· 45 commits to main since this release
996589c

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_udf register 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 BaseModel response formats return native DuckDB
    STRUCT types with direct field access in SQL (SELECT udf(text).sentiment). Supports nested
    models, Enum, and Literal.
  • Persistent Cache β€” DuckDBCacheBackend stores 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 to CREATE 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_series uses DuckDB's C++ to_json() instead of
    Python json.dumps (5-10x faster on large DataFrames).
  • Batched Token Counting β€” count_tokens uses tiktoken.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

  • CacheBackend Protocol β€” Runtime-checkable protocol for pluggable cache backends.
    InMemoryCacheBackend (default) and DuckDBCacheBackend both satisfy it.
  • Unified Configuration β€” set_client, get_client, set_responses_model, etc. defined in
    _provider.py and exported from openaivec.*. 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 dependency
  • pyarrow>=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: @dataclass for all classes, typed fields, DI via fields, of()
    factories