Skip to content

feat: add OpenAI's async batch API support for vectorizer #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alejandrodnm
Copy link
Contributor

@alejandrodnm alejandrodnm commented Mar 14, 2025

Adds support for OpenAI's async batch API to process large amounts of embeddings at a lower cost, and higher rate limits.

Key features:

  • New AsyncBatchEmbedder interface for handling async batch operations
  • Support for OpenAI's batch API implementation
  • New database tables for tracking batch status and chunks
  • Configurable polling interval for batch status checks
  • Automatic retry mechanism for failed batches

Database changes:

  • New async_batch_queue_table for tracking batch status
  • New async_batch_chunks_table for storing chunks pending processing
  • Added async_batch_polling_interval column to vectorizer table
  • New SQL functions for managing async batch operations

API changes:

  • New async_batch_enabled parameter in ai.embedding_openai()
  • New ai.vectorizer_enable_async_batches() and ai.vectorizer_disable_async_batches() functions
  • Extended vectorizer configuration to support async batch operations

The async batch workflow:

  1. Chunks are collected and submitted as a batch to OpenAI
  2. Batch status is monitored through polling
  3. When ready, embeddings are retrieved and stored
  4. Batch resources are cleaned up after successful processing

https://www.loom.com/share/09ff363c52204bf6851a797d4c4c4d50?sid=79e95d06-017d-4de5-a740-aa5af916b971

@alejandrodnm alejandrodnm temporarily deployed to internal-contributors March 14, 2025 15:05 — with GitHub Actions Inactive
@alejandrodnm alejandrodnm force-pushed the adn/batch-api-follow branch from 0edcb8e to 846322f Compare March 14, 2025 15:53
@alejandrodnm alejandrodnm temporarily deployed to internal-contributors March 14, 2025 15:53 — with GitHub Actions Inactive
Adds support for OpenAI's async batch API to process large amounts of
embeddings at a lower cost, and higher rate limits.

Key features:
- New AsyncBatchEmbedder interface for handling async batch operations
- Support for OpenAI's batch API implementation
- New database tables for tracking batch status and chunks
- Configurable polling interval for batch status checks
- Automatic retry mechanism for failed batches

Database changes:
- New async_batch_queue_table for tracking batch status
- New async_batch_chunks_table for storing chunks pending processing
- Added async_batch_polling_interval column to vectorizer table
- New SQL functions for managing async batch operations

API changes:
- New async_batch_enabled parameter in ai.embedding_openai()
- New ai.vectorizer_enable_async_batches() and
  ai.vectorizer_disable_async_batches() functions
- Extended vectorizer configuration to support async batch operations

The async batch workflow:
1. Chunks are collected and submitted as a batch to OpenAI
2. Batch status is monitored through polling
3. When ready, embeddings are retrieved and stored
4. Batch resources are cleaned up after successful processing
@alejandrodnm alejandrodnm force-pushed the adn/batch-api-follow branch from 846322f to f26b879 Compare March 14, 2025 15:57
@alejandrodnm alejandrodnm temporarily deployed to internal-contributors March 14, 2025 15:57 — with GitHub Actions Inactive
@alejandrodnm
Copy link
Contributor Author

@kolaente this is a first draft of the PR we have some pending changes to our interfaces and we need to see how it'll affect this work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants