Skip to content

Add abstraction for batch jobs #1290

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Add abstraction for batch jobs #1290

wants to merge 6 commits into from

Conversation

ahuang11
Copy link
Contributor

@ahuang11 ahuang11 commented Jun 18, 2025

I've noticed that we've been embedding a lot more text in recent times (soon Vega-Lite docs), and the previous method of looping could be costly, so here I introduce batch processing for chunk situating. This could also be useful for batch generating multiple reports, or performing evals, in the future

This PR adds multi-provider batch support (OpenAI, Anthropic, Mistral) that processes chunks in parallel rather than sequentially, and has capability to auto-resume the existing batches.

Falls back to sequential processing if batch APIs aren't supported or batch_situate_threshold (default: 1000 chunks, set to 0 to disable).

OpenAI batch docs: https://platform.openai.com/docs/guides/batch
Mistral: https://docs.mistral.ai/capabilities/batch/
Anthropic: https://docs.anthropic.com/en/docs/build-with-claude/batch-processing

@ahuang11 ahuang11 requested review from philippjfr and amaloney June 18, 2025 01:28
@ahuang11 ahuang11 marked this pull request as draft June 18, 2025 01:28
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

Attention: Patch coverage is 24.44444% with 408 lines in your changes missing coverage. Please review.

Project coverage is 57.18%. Comparing base (9107130) to head (71e9a18).

Files with missing lines Patch % Lines
lumen/ai/batch_providers.py 25.25% 219 Missing ⚠️
lumen/ai/batch_situate.py 11.81% 97 Missing ⚠️
lumen/ai/vector_store.py 43.00% 57 Missing ⚠️
lumen/ai/llm.py 10.00% 18 Missing ⚠️
lumen/ai/embeddings.py 0.00% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1290      +/-   ##
==========================================
- Coverage   58.20%   57.18%   -1.02%     
==========================================
  Files         114      116       +2     
  Lines       18318    18818     +500     
==========================================
+ Hits        10662    10762     +100     
- Misses       7656     8056     +400     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ahuang11 ahuang11 mentioned this pull request Jun 23, 2025
@ahuang11 ahuang11 marked this pull request as ready for review June 25, 2025 04:02
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.

1 participant