A number of types that are `Codable` don't encode correctly
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
Direzione di ricerca
Start with Sources/OpenAI/Public/Models/ChatQuery.swift, especially ChatQuery.ChatCompletionMessageParam, and identify other typed enums with the same encoding or decoding concern. Add round-trip tests for the affected types and verify that encoding then decoding returns the initial value.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
A number of types that are Codable don't encode correctly. This seems to impact a number of the typed enums that are typically received from an OpenAI compatible server and that are not persisted by a client (unless the client would persist its requests)
For instance ChatQuery.ChatCompletionMessageParam would need a decoding such as
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let role = try container.decode(Role.self, forKey: .role)
switch role {
case .system:
self = try .system(.init(from: decoder))
case .developer:
self = try .developer(.init(from: decoder))
case .user:
self = try .user(.init(from: decoder))
case .assistant:
self = try .assistant(.init(from: decoder))
case .tool:
self = try .tool(.init(from: decoder))
}
}
I mostly look at the types in ChatQuery but typically you need to hand write the encoding / decoding for each typed enum as the generated conformances are not correct and only you know about the key used to determine which nested type is right.
As a side note, it could be helpful to have tests that validate that the encoding and decoding of those types gives back the initial value.
Lmk if you want a PR.
- 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 48/100
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
-
Add Batch API supportAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di MacPaw/OpenAI
Issue simili
-
fyi-ecosystem platform-ios team-ios
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
flutter/flutter#194348 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
freestylefly/WeChatBridge#44 ·
I maintainer di solito rispondono entro 1 giorno
-
Doesn't compile on WindowsAperta
Difficoltà 2/5 Mezza giornata Idoneità per principianti 62/100
swiftwasm/JavaScriptKit#818 ·
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 62/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
capawesome-team/capacitor-plugins#1134 ·
I maintainer di solito rispondono entro 1 giorno