Add Batch API support
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start by reviewing the Batch API design and prior work listed in the issue, especially PR #401 and commits 7d33a55, 1f40dc4, and d88dfc8. Then inspect openapi-generator-config.yaml and the existing Files and Responses endpoint patterns. Done means implementing the specified Batch endpoints, JSONL helpers, tests, README and CHANGELOG updates, and building the Demo app.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Add the Batch API. #401 started as a Batch API PR and is being turned into a Files API PR, so Batch builds on the openAI.files namespace introduced there. In particular, files.content(id:) is how batch output and error files are downloaded.
Depends on #401.
Design decided while reviewing #401
Namespace
openAI.batches: BatchesEndpointProtocolwithcreate(query:),retrieve(id:),list(query: ListBatchesQuery)plus alist()overload, andcancel(id:).- Each method comes in completion-handler (
@discardableResult), async and Combine flavours, in the same four-protocol layout asResponsesEndpoint. - Names follow the official Java and Python SDKs (
client.batches.create/retrieve/list/cancel).
Types
- Use the generated
Components.Schemas.Batch,CreateBatchRequestandListBatchesResponsedirectly, with no top-level typealiases. Adding a typealias later is additive; removing one would be a break. - Generate them by adding
/batches,/batches/{batch_id}and/batches/{batch_id}/canceltoopenapi-generator-config.yaml. - The closed generated enums, such as
Batch.StatusPayload, are accepted for now; #464 tracks reconsidering that. - Add public static aliases on the generated enums so callers don't have to write
._sol_v1ChatCompletionsor._24h:.chatCompletions,.responses, and so on for all 8 endpoints, plus.twentyFourHours.
JSONL line types
The spec has no schema for these, so they're hand-written.
- Request line: generic over an
Encodablebody, so it isn't tied toChatQuery. - Response line: exposes the body as JSON with a typed
decodeBody(as:)helper, so embeddings, Responses and the other endpoints work without new types. - Decoding: use the project's response decoder with
configuration.parsingOptions, not a bareJSONDecoder, so.relaxedkeeps working.
Convenience helpers
Add submit (JSONL encode, upload, create) and wait (poll, then download) in an extension with a default implementation, not as protocol requirements. Decide where submit lives, since it needs both files and batches.
Problems in the original implementation to fix:
waitmust also downloaderror_file_id, because failed requests aren't in the output file.- Don't discard partial output from cancelled or expired batches.
- Name the client-side polling error so it doesn't clash in meaning with the spec's per-request
BatchError. - The timeout check shouldn't overshoot by a whole polling interval.
Tests
Integration tests (skipped without OPENAI_API_KEY) must not silently pass on timeout.
Prior work
The PR branch's history has a full implementation of the above, removed again when the branch was narrowed to Files:
7d33a55: generator config and generated Batch schemas1f40dc4: thebatchesendpoint, protocols,ListBatchesQueryand unit testsd88dfc8: the original author's JSONL types, convenience methods, README text and integration tests
Finishing
- The API breakage check should report one break:
var OpenAIProtocol.batches has been added as a protocol requirement. Add it to the allowlist and describe it in the CHANGELOG. - Add a README section and build the Demo app.
- Lingua principale
- Swift
- Stelle
- 2.9k
- Fork
- 519
- Merge medio
- 4g 9h
- PR unite (30g)
- 13
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MacPaw/OpenAI
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 3 giorni
-
Enable batch promptsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
MacPaw/OpenAI#73 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di MacPaw/OpenAI
Issue simili
-
P2 package platform-ios team-ios
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
altic-dev/FluidVoice#1117 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
omacom/try-omarchy#343 ·
I maintainer di solito rispondono entro 1 giorno
-
install.ps1: Windows PowerShell 5.1 aborts after a successful cosign verification (NativeCommandError on 'Verified OK')Forse già presa @sly321-pixel l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
OneBusAway/onebusaway-ios#1518 ·
I maintainer di solito rispondono entro 2 giorni