packages feed

openai-servant 0.3.0.0 → 0.3.0.1

raw patch · 2 files changed

+18/−2 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

openai-servant.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           openai-servant-version:        0.3.0.0+version:        0.3.0.1 synopsis:       Unofficial OpenAI servant types description:    Unofficial description of the OpenAI API using servant types category:       Web
src/OpenAI/Resources.hs view
@@ -257,6 +257,23 @@   }   deriving (Show, Eq) +instance A.FromJSON ChatMessage where+  parseJSON = A.withObject "ChatMessage" $ \obj ->+    ChatMessage <$> obj A..:? "content"+                <*> obj A..: "role"+                <*> obj A..:? "function_call"+                <*> obj A..:? "name"++instance A.ToJSON ChatMessage where+  toJSON (ChatMessage {chmContent = content, chmRole = role, chmFunctionCall = functionCall, chmName = name}) =+    A.object $ +      [ "content" A..= content,+        "role" A..= role+      ] ++ catMaybes+      [ ("function_call" A..=) <$> functionCall, +        ("name" A..=) <$> name+      ]+       data ChatFunction = ChatFunction   { chfName :: T.Text,     chfDescription :: T.Text,@@ -314,7 +331,6 @@     chrUsage :: Usage   } -$(deriveJSON (jsonOpts 3) ''ChatMessage) $(deriveJSON (jsonOpts 3) ''ChatFunction) $(deriveJSON (jsonOpts 4) ''ChatCompletionRequest) $(deriveJSON (jsonOpts 4) ''ChatChoice)