Add Groq batch processing and structured output support#927
Open
xmarquez wants to merge 3 commits intotidyverse:mainfrom
Open
Add Groq batch processing and structured output support#927xmarquez wants to merge 3 commits intotidyverse:mainfrom
xmarquez wants to merge 3 commits intotidyverse:mainfrom
Conversation
- Add 6 batch methods on ProviderGroq (has_batch_support, batch_submit, batch_poll, batch_status, batch_retrieve, batch_result_turn) - Add groq_upload_file, groq_download_file, groq_json_fallback helpers - Update as_json(TypeObject) to add additionalProperties: false recursively - Add as_json(TypeArray) with recursive additionalProperties: false - Add add_additional_properties_false() helper for schema recursion - Handle empty output_file_id in batch_retrieve (Groq quirk) - Require .jsonl file extension for Groq batch uploads - Remove "no structured data extraction" limitation from docs - Add pre-recorded fixture file for deterministic testing - 30 tests: unit, schema, batch status, fixture-based, integration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
as_json(ProviderGroq, Turn) assumed non-tool assistant content was always ContentText, accessing @text directly. Structured output creates ContentJson which lacks @text, causing serialization failures on follow-up turns. Now checks content type and extracts string appropriately. Also enables the structured data extraction test that was blocked by this bug, and adds unit tests for ContentJson/ContentText serialization. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chat_groq()via the Groq Batch API (50% cost discount, 24h completion window)additionalProperties: falserecursively to JSON schemas (required by Groq's strict mode)as_json(ProviderGroq, Turn)to handleContentJsonin assistant turns (previously assumedContentTextonly, causing serialization failure on structured output follow-up turns)ProviderGroq, 3 helper functions, andadd_additional_properties_false()schema helperCloses #914 (Groq portion — Gemini batch is PR #926)
Key implementation details
custom_id,method,url,body) but uses/v1/chat/completionsendpoint.jsonlfile extension on uploads (API infers purpose from extension)batch_retrieve()handles emptyoutput_file_idgracefully (Groq may put all results in error file)json_schema(e.g.,openai/gpt-oss-20b)as_json(ProviderGroq, Turn)now checks content type: extracts@stringor serializes@dataforContentJson, falls back to@textforContentTextTest plan
test_data_extractionwithopenai/gpt-oss-20b)devtools::test(filter = "batch-chat")— no regressionsdevtools::check()— 779 PASS, 102 SKIP, 1 pre-existing FAIL (flaky Groq tool calling test)batch_chat_structured()with 5 song lyric prompts completed in ~7 seconds🤖 Generated with Claude Code