{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
module Data.Ollama.Show
(
showModel
, showModelM
, showModelOps
, showModelOpsM
, ShowModelResponse (..)
, ShowModelInfo (..)
, CT.ModelDetails (..)
) where
import Control.Monad.IO.Class (MonadIO (liftIO))
import Data.Aeson
import Data.Ollama.Common.Config (OllamaConfig)
import Data.Ollama.Common.Error (OllamaError)
import Data.Ollama.Common.Types qualified as CT
import Data.Ollama.Common.Utils (commonNonStreamingHandler, withOllamaRequest)
import Data.Text (Text)
import GHC.Generics
import GHC.Int (Int64)
data ShowModelOps = ShowModelOps
{ ShowModelOps -> Text
name :: !Text
, ShowModelOps -> Maybe Bool
verbose :: !(Maybe Bool)
}
deriving (Int -> ShowModelOps -> ShowS
[ShowModelOps] -> ShowS
ShowModelOps -> String
(Int -> ShowModelOps -> ShowS)
-> (ShowModelOps -> String)
-> ([ShowModelOps] -> ShowS)
-> Show ShowModelOps
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ShowModelOps -> ShowS
showsPrec :: Int -> ShowModelOps -> ShowS
$cshow :: ShowModelOps -> String
show :: ShowModelOps -> String
$cshowList :: [ShowModelOps] -> ShowS
showList :: [ShowModelOps] -> ShowS
Show, ShowModelOps -> ShowModelOps -> Bool
(ShowModelOps -> ShowModelOps -> Bool)
-> (ShowModelOps -> ShowModelOps -> Bool) -> Eq ShowModelOps
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ShowModelOps -> ShowModelOps -> Bool
== :: ShowModelOps -> ShowModelOps -> Bool
$c/= :: ShowModelOps -> ShowModelOps -> Bool
/= :: ShowModelOps -> ShowModelOps -> Bool
Eq, (forall x. ShowModelOps -> Rep ShowModelOps x)
-> (forall x. Rep ShowModelOps x -> ShowModelOps)
-> Generic ShowModelOps
forall x. Rep ShowModelOps x -> ShowModelOps
forall x. ShowModelOps -> Rep ShowModelOps x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ShowModelOps -> Rep ShowModelOps x
from :: forall x. ShowModelOps -> Rep ShowModelOps x
$cto :: forall x. Rep ShowModelOps x -> ShowModelOps
to :: forall x. Rep ShowModelOps x -> ShowModelOps
Generic, [ShowModelOps] -> Value
[ShowModelOps] -> Encoding
ShowModelOps -> Bool
ShowModelOps -> Value
ShowModelOps -> Encoding
(ShowModelOps -> Value)
-> (ShowModelOps -> Encoding)
-> ([ShowModelOps] -> Value)
-> ([ShowModelOps] -> Encoding)
-> (ShowModelOps -> Bool)
-> ToJSON ShowModelOps
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: ShowModelOps -> Value
toJSON :: ShowModelOps -> Value
$ctoEncoding :: ShowModelOps -> Encoding
toEncoding :: ShowModelOps -> Encoding
$ctoJSONList :: [ShowModelOps] -> Value
toJSONList :: [ShowModelOps] -> Value
$ctoEncodingList :: [ShowModelOps] -> Encoding
toEncodingList :: [ShowModelOps] -> Encoding
$comitField :: ShowModelOps -> Bool
omitField :: ShowModelOps -> Bool
ToJSON)
data ShowModelResponse = ShowModelResponse
{ ShowModelResponse -> Text
modelFile :: !Text
, ShowModelResponse -> Maybe Text
parameters :: !(Maybe Text)
, ShowModelResponse -> Maybe Text
template :: !(Maybe Text)
, ShowModelResponse -> ModelDetails
details :: !CT.ModelDetails
, ShowModelResponse -> ShowModelInfo
modelInfo :: !ShowModelInfo
, ShowModelResponse -> Maybe Text
license :: !(Maybe Text)
, ShowModelResponse -> Maybe [Text]
capabilities :: Maybe [Text]
}
deriving (Int -> ShowModelResponse -> ShowS
[ShowModelResponse] -> ShowS
ShowModelResponse -> String
(Int -> ShowModelResponse -> ShowS)
-> (ShowModelResponse -> String)
-> ([ShowModelResponse] -> ShowS)
-> Show ShowModelResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ShowModelResponse -> ShowS
showsPrec :: Int -> ShowModelResponse -> ShowS
$cshow :: ShowModelResponse -> String
show :: ShowModelResponse -> String
$cshowList :: [ShowModelResponse] -> ShowS
showList :: [ShowModelResponse] -> ShowS
Show, ShowModelResponse -> ShowModelResponse -> Bool
(ShowModelResponse -> ShowModelResponse -> Bool)
-> (ShowModelResponse -> ShowModelResponse -> Bool)
-> Eq ShowModelResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ShowModelResponse -> ShowModelResponse -> Bool
== :: ShowModelResponse -> ShowModelResponse -> Bool
$c/= :: ShowModelResponse -> ShowModelResponse -> Bool
/= :: ShowModelResponse -> ShowModelResponse -> Bool
Eq)
data ShowModelInfo = ShowModelInfo
{ ShowModelInfo -> Maybe Text
generalArchitecture :: !(Maybe Text)
, ShowModelInfo -> Maybe Int
generalFileType :: !(Maybe Int)
, ShowModelInfo -> Maybe Int64
generalParameterCount :: !(Maybe Int64)
, ShowModelInfo -> Maybe Int
generalQuantizationVersion :: !(Maybe Int)
, ShowModelInfo -> Maybe Int
llamaAttentionHeadCount :: !(Maybe Int)
, ShowModelInfo -> Maybe Int
llamaAttentionHeadCountKV :: !(Maybe Int)
, ShowModelInfo -> Maybe Float
llamaAttentionLayerNormRMSEpsilon :: !(Maybe Float)
, ShowModelInfo -> Maybe Int
llamaBlockCount :: !(Maybe Int)
, ShowModelInfo -> Maybe Int
llamaContextLength :: !(Maybe Int)
, ShowModelInfo -> Maybe Int
llamaEmbeddingLength :: !(Maybe Int)
, ShowModelInfo -> Maybe Int
llamaFeedForwardLength :: !(Maybe Int)
, ShowModelInfo -> Maybe Int
llamaRopeDimensionCount :: !(Maybe Int)
, ShowModelInfo -> Maybe Int64
llamaRopeFreqBase :: !(Maybe Int64)
, ShowModelInfo -> Maybe Int64
llamaVocabSize :: !(Maybe Int64)
, ShowModelInfo -> Maybe Int
tokenizerGgmlBosToken_id :: !(Maybe Int)
, ShowModelInfo -> Maybe Int
tokenizerGgmlEosToken_id :: !(Maybe Int)
, ShowModelInfo -> Maybe [Text]
tokenizerGgmlMerges :: !(Maybe [Text])
, ShowModelInfo -> Maybe Text
tokenizerGgmlMode :: !(Maybe Text)
, ShowModelInfo -> Maybe Text
tokenizerGgmlPre :: !(Maybe Text)
, ShowModelInfo -> Maybe [Text]
tokenizerGgmlTokenType :: !(Maybe [Text])
, ShowModelInfo -> Maybe [Text]
tokenizerGgmlTokens :: !(Maybe [Text])
}
deriving (Int -> ShowModelInfo -> ShowS
[ShowModelInfo] -> ShowS
ShowModelInfo -> String
(Int -> ShowModelInfo -> ShowS)
-> (ShowModelInfo -> String)
-> ([ShowModelInfo] -> ShowS)
-> Show ShowModelInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ShowModelInfo -> ShowS
showsPrec :: Int -> ShowModelInfo -> ShowS
$cshow :: ShowModelInfo -> String
show :: ShowModelInfo -> String
$cshowList :: [ShowModelInfo] -> ShowS
showList :: [ShowModelInfo] -> ShowS
Show, ShowModelInfo -> ShowModelInfo -> Bool
(ShowModelInfo -> ShowModelInfo -> Bool)
-> (ShowModelInfo -> ShowModelInfo -> Bool) -> Eq ShowModelInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ShowModelInfo -> ShowModelInfo -> Bool
== :: ShowModelInfo -> ShowModelInfo -> Bool
$c/= :: ShowModelInfo -> ShowModelInfo -> Bool
/= :: ShowModelInfo -> ShowModelInfo -> Bool
Eq)
instance FromJSON ShowModelResponse where
parseJSON :: Value -> Parser ShowModelResponse
parseJSON = String
-> (Object -> Parser ShowModelResponse)
-> Value
-> Parser ShowModelResponse
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ShowModelResponse" ((Object -> Parser ShowModelResponse)
-> Value -> Parser ShowModelResponse)
-> (Object -> Parser ShowModelResponse)
-> Value
-> Parser ShowModelResponse
forall a b. (a -> b) -> a -> b
$ \Object
v ->
Text
-> Maybe Text
-> Maybe Text
-> ModelDetails
-> ShowModelInfo
-> Maybe Text
-> Maybe [Text]
-> ShowModelResponse
ShowModelResponse
(Text
-> Maybe Text
-> Maybe Text
-> ModelDetails
-> ShowModelInfo
-> Maybe Text
-> Maybe [Text]
-> ShowModelResponse)
-> Parser Text
-> Parser
(Maybe Text
-> Maybe Text
-> ModelDetails
-> ShowModelInfo
-> Maybe Text
-> Maybe [Text]
-> ShowModelResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"modelfile"
Parser
(Maybe Text
-> Maybe Text
-> ModelDetails
-> ShowModelInfo
-> Maybe Text
-> Maybe [Text]
-> ShowModelResponse)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> ModelDetails
-> ShowModelInfo
-> Maybe Text
-> Maybe [Text]
-> ShowModelResponse)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"parameters"
Parser
(Maybe Text
-> ModelDetails
-> ShowModelInfo
-> Maybe Text
-> Maybe [Text]
-> ShowModelResponse)
-> Parser (Maybe Text)
-> Parser
(ModelDetails
-> ShowModelInfo
-> Maybe Text
-> Maybe [Text]
-> ShowModelResponse)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"template"
Parser
(ModelDetails
-> ShowModelInfo
-> Maybe Text
-> Maybe [Text]
-> ShowModelResponse)
-> Parser ModelDetails
-> Parser
(ShowModelInfo -> Maybe Text -> Maybe [Text] -> ShowModelResponse)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser ModelDetails
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"details"
Parser
(ShowModelInfo -> Maybe Text -> Maybe [Text] -> ShowModelResponse)
-> Parser ShowModelInfo
-> Parser (Maybe Text -> Maybe [Text] -> ShowModelResponse)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser ShowModelInfo
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"model_info"
Parser (Maybe Text -> Maybe [Text] -> ShowModelResponse)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> ShowModelResponse)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"license"
Parser (Maybe [Text] -> ShowModelResponse)
-> Parser (Maybe [Text]) -> Parser ShowModelResponse
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"capabilities"
instance FromJSON ShowModelInfo where
parseJSON :: Value -> Parser ShowModelInfo
parseJSON = String
-> (Object -> Parser ShowModelInfo)
-> Value
-> Parser ShowModelInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ModelInfo" ((Object -> Parser ShowModelInfo) -> Value -> Parser ShowModelInfo)
-> (Object -> Parser ShowModelInfo)
-> Value
-> Parser ShowModelInfo
forall a b. (a -> b) -> a -> b
$ \Object
v ->
Maybe Text
-> Maybe Int
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo
ShowModelInfo
(Maybe Text
-> Maybe Int
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Text)
-> Parser
(Maybe Int
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"general.architecture"
Parser
(Maybe Int
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int)
-> Parser
(Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"general.file_type"
Parser
(Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int64)
-> Parser
(Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int64)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"general.parameter_count"
Parser
(Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int)
-> Parser
(Maybe Int
-> Maybe Int
-> Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"general.quantization_version"
Parser
(Maybe Int
-> Maybe Int
-> Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int)
-> Parser
(Maybe Int
-> Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"llama.attention.head_count"
Parser
(Maybe Int
-> Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int)
-> Parser
(Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"llama.attention.head_count_kv"
Parser
(Maybe Float
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Float)
-> Parser
(Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Float)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"llama.attention.layer_norm_rms_epsilon"
Parser
(Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int)
-> Parser
(Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"llama.block_count"
Parser
(Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int)
-> Parser
(Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"llama.context_length"
Parser
(Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int)
-> Parser
(Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"llama.embedding_length"
Parser
(Maybe Int
-> Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int)
-> Parser
(Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"llama.feed_forward_length"
Parser
(Maybe Int
-> Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int)
-> Parser
(Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"llama.rope.dimension_count"
Parser
(Maybe Int64
-> Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int64)
-> Parser
(Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int64)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"llama.rope.freq_base"
Parser
(Maybe Int64
-> Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int64)
-> Parser
(Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int64)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"llama.vocab_size"
Parser
(Maybe Int
-> Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int)
-> Parser
(Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"tokenizer.ggml.bos_token_id"
Parser
(Maybe Int
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe Int)
-> Parser
(Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"tokenizer.ggml.eos_token_id"
Parser
(Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> ShowModelInfo)
-> Parser (Maybe [Text])
-> Parser
(Maybe Text
-> Maybe Text -> Maybe [Text] -> Maybe [Text] -> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"tokenizer.ggml.merges"
Parser
(Maybe Text
-> Maybe Text -> Maybe [Text] -> Maybe [Text] -> ShowModelInfo)
-> Parser (Maybe Text)
-> Parser
(Maybe Text -> Maybe [Text] -> Maybe [Text] -> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"tokenizer.ggml.model"
Parser
(Maybe Text -> Maybe [Text] -> Maybe [Text] -> ShowModelInfo)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> Maybe [Text] -> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"tokenizer.ggml.pre"
Parser (Maybe [Text] -> Maybe [Text] -> ShowModelInfo)
-> Parser (Maybe [Text]) -> Parser (Maybe [Text] -> ShowModelInfo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"tokenizer.ggml.token_type"
Parser (Maybe [Text] -> ShowModelInfo)
-> Parser (Maybe [Text]) -> Parser ShowModelInfo
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"tokenizer.ggml.tokens"
showModelOps ::
Text ->
Maybe Bool ->
Maybe OllamaConfig ->
IO (Either OllamaError ShowModelResponse)
showModelOps :: Text
-> Maybe Bool
-> Maybe OllamaConfig
-> IO (Either OllamaError ShowModelResponse)
showModelOps Text
modelName Maybe Bool
verbose_ Maybe OllamaConfig
mbConfig = do
Text
-> ByteString
-> Maybe ShowModelOps
-> Maybe OllamaConfig
-> (Response BodyReader
-> IO (Either OllamaError ShowModelResponse))
-> IO (Either OllamaError ShowModelResponse)
forall payload response.
ToJSON payload =>
Text
-> ByteString
-> Maybe payload
-> Maybe OllamaConfig
-> (Response BodyReader -> IO (Either OllamaError response))
-> IO (Either OllamaError response)
withOllamaRequest
Text
"/api//show"
ByteString
"POST"
( ShowModelOps -> Maybe ShowModelOps
forall a. a -> Maybe a
Just (ShowModelOps -> Maybe ShowModelOps)
-> ShowModelOps -> Maybe ShowModelOps
forall a b. (a -> b) -> a -> b
$
ShowModelOps
{ name :: Text
name = Text
modelName
, verbose :: Maybe Bool
verbose = Maybe Bool
verbose_
}
)
Maybe OllamaConfig
mbConfig
Response BodyReader -> IO (Either OllamaError ShowModelResponse)
forall a.
FromJSON a =>
Response BodyReader -> IO (Either OllamaError a)
commonNonStreamingHandler
showModel ::
Text ->
IO (Either OllamaError ShowModelResponse)
showModel :: Text -> IO (Either OllamaError ShowModelResponse)
showModel Text
modelName =
Text
-> Maybe Bool
-> Maybe OllamaConfig
-> IO (Either OllamaError ShowModelResponse)
showModelOps Text
modelName Maybe Bool
forall a. Maybe a
Nothing Maybe OllamaConfig
forall a. Maybe a
Nothing
showModelM :: MonadIO m => Text -> m (Either OllamaError ShowModelResponse)
showModelM :: forall (m :: * -> *).
MonadIO m =>
Text -> m (Either OllamaError ShowModelResponse)
showModelM Text
t = IO (Either OllamaError ShowModelResponse)
-> m (Either OllamaError ShowModelResponse)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Either OllamaError ShowModelResponse)
-> m (Either OllamaError ShowModelResponse))
-> IO (Either OllamaError ShowModelResponse)
-> m (Either OllamaError ShowModelResponse)
forall a b. (a -> b) -> a -> b
$ Text -> IO (Either OllamaError ShowModelResponse)
showModel Text
t
showModelOpsM ::
MonadIO m =>
Text ->
Maybe Bool ->
Maybe OllamaConfig ->
m (Either OllamaError ShowModelResponse)
showModelOpsM :: forall (m :: * -> *).
MonadIO m =>
Text
-> Maybe Bool
-> Maybe OllamaConfig
-> m (Either OllamaError ShowModelResponse)
showModelOpsM Text
t Maybe Bool
v Maybe OllamaConfig
mbCfg = IO (Either OllamaError ShowModelResponse)
-> m (Either OllamaError ShowModelResponse)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Either OllamaError ShowModelResponse)
-> m (Either OllamaError ShowModelResponse))
-> IO (Either OllamaError ShowModelResponse)
-> m (Either OllamaError ShowModelResponse)
forall a b. (a -> b) -> a -> b
$ Text
-> Maybe Bool
-> Maybe OllamaConfig
-> IO (Either OllamaError ShowModelResponse)
showModelOps Text
t Maybe Bool
v Maybe OllamaConfig
mbCfg