packages feed

llama-cpp-haskell 0.3.0.2 → 0.3.1

raw patch · 2 files changed

+30/−4 lines, 2 filesdep +deriving-aesonPVP ok

version bump matches the API change (PVP)

Dependencies added: deriving-aeson

API changes (from Hackage documentation)

+ Llama: LlamaModelInfo :: Text -> [Text] -> [Text] -> Text -> Text -> Word -> LlamaModelInfo
+ Llama: LlamaModelsResponse :: [LlamaModelInfo] -> LlamaModelsResponse
+ Llama: [lmiAliases] :: LlamaModelInfo -> [Text]
+ Llama: [lmiCreated] :: LlamaModelInfo -> Word
+ Llama: [lmiId] :: LlamaModelInfo -> Text
+ Llama: [lmiObject] :: LlamaModelInfo -> Text
+ Llama: [lmiOwnedBy] :: LlamaModelInfo -> Text
+ Llama: [lmiTags] :: LlamaModelInfo -> [Text]
+ Llama: [lmrData] :: LlamaModelsResponse -> [LlamaModelInfo]
+ Llama: data LlamaModelInfo
+ Llama: instance Data.Aeson.Types.FromJSON.FromJSON Llama.LlamaModelInfo
+ Llama: instance Data.Aeson.Types.FromJSON.FromJSON Llama.LlamaModelsResponse
+ Llama: instance GHC.Generics.Generic Llama.LlamaModelInfo
+ Llama: instance GHC.Generics.Generic Llama.LlamaModelsResponse
+ Llama: instance GHC.Show.Show Llama.LlamaModelInfo
+ Llama: instance GHC.Show.Show Llama.LlamaModelsResponse
+ Llama: models :: URL -> IO (Maybe [LlamaModelInfo])
+ Llama: newtype LlamaModelsResponse

Files

Llama.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings, DeriveGeneric, DuplicateRecordFields #-}+{-# LANGUAGE OverloadedStrings, DeriveGeneric, DuplicateRecordFields, DataKinds, DerivingVia #-}  module Llama where @@ -8,7 +8,7 @@ import Data.Default import Data.Text (Text) import Data.Word-import GHC.Generics+import Deriving.Aeson import Network.HTTP.Conduit import Network.HTTP.Simple hiding (httpLbs) import Network.HTTP.Types.Status@@ -61,6 +61,23 @@   } deriving (Show, Generic) instance FromJSON LlamaDetokenizeResponse +-- |One model entry of the `/models` response+data LlamaModelInfo = LlamaModelInfo+  { lmiId :: Text+  , lmiAliases :: [Text]+  , lmiTags :: [Text]+  , lmiObject :: Text+  , lmiOwnedBy :: Text+  , lmiCreated :: Word+  } deriving (Show, Generic)+  deriving (FromJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "lmi", CamelToSnake]] LlamaModelInfo++-- |The whole `/models` response+newtype LlamaModelsResponse = LlamaModelsResponse+  { lmrData :: [LlamaModelInfo]+  } deriving (Show, Generic)+  deriving (FromJSON) via CustomJSON '[FieldLabelModifier '[StripPrefix "lmr", CamelToSnake]] LlamaModelsResponse+ data Health = HealthOk | HealthNok deriving (Show)  -- llama.cpp rejects requests with null options since https://github.com/ggml-org/llama.cpp/pull/24150@@ -230,3 +247,11 @@   pure $ if responseStatus response == ok200        then HealthOk        else HealthNok++-- |Returns the models served by the llama-server+models :: URL -> IO (Maybe [LlamaModelInfo])+models url = do+  let request = parseRequest_ $ url ++ "/models"+  response <- httpLBS request+  decoded <- llamaDecode (responseBody response)+  return $ decoded >>= (\(LlamaModelsResponse result) -> Just result)
llama-cpp-haskell.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.2 name:               llama-cpp-haskell-version:            0.3.0.2+version:            0.3.1 synopsis:           Haskell bindings for the llama.cpp llama-server and a simple CLI description:        This is the interface that allows one to interface with llama-server RPC API using Haskell concepts. It also includes a `llamacall` binary to do it from your favorite command line shell and use it in scripting. license:            AGPL-3.0-only@@ -20,7 +20,7 @@ Source-repository this   type:              git   location:          https://github.com/l29ah/llama-cpp-haskell.git-  tag:               0.3.0.2+  tag:               0.3.1  common stuff     ghc-options: -Wall@@ -36,6 +36,7 @@                     , http-types ^>= 0.12                     , bytestring ^>= 0.12.2.0                     , attoparsec ^>= 0.14.4+                    , deriving-aeson ^>= 0.2.9                     , data-default >= 0.7 && < 0.9  library