Copyright | (c) 2025 Tushar Adhatrao |
---|---|
License | MIT |
Maintainer | Tushar Adhatrao <[email protected]> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Data.Ollama.Common.Types
Description
📋 Overview
This module defines common types for working with Ollama's API, including:
- Chat messages and roles
- Text generation responses
- Structured function/tool calling
- Model metadata
- Streaming handling
- Custom model parameters
These types are consumed and returned by higher-level modules
like Chat
, Generate
, and others.
Includes
- Chat message structure and roles
- Generate and chat response records
- ModelOptions and advanced config
- Structured function/tool call interfaces
- JSON format hints and schema wrapping
- Helper class
HasDone
for streaming termination
Most types implement ToJSON
/FromJSON
for direct API interaction.
Synopsis
- data ModelDetails = ModelDetails {
- parentModel :: !(Maybe Text)
- format :: !Text
- family :: !Text
- families :: ![Text]
- parameterSize :: !Text
- quantizationLevel :: Text
- data Format
- data GenerateResponse = GenerateResponse {
- model :: !Text
- createdAt :: !UTCTime
- genResponse :: !Text
- done :: !Bool
- totalDuration :: !(Maybe Int64)
- loadDuration :: !(Maybe Int64)
- promptEvalCount :: !(Maybe Int64)
- promptEvalDuration :: !(Maybe Int64)
- evalCount :: !(Maybe Int64)
- evalDuration :: !(Maybe Int64)
- thinking :: !(Maybe Text)
- data Message = Message {}
- data Role
- data ChatResponse = ChatResponse {}
- class HasDone a where
- data ModelOptions = ModelOptions {
- numKeep :: Maybe Int
- seed :: Maybe Int
- numPredict :: Maybe Int
- topK :: Maybe Int
- topP :: Maybe Double
- minP :: Maybe Double
- typicalP :: Maybe Double
- repeatLastN :: Maybe Int
- temperature :: Maybe Double
- repeatPenalty :: Maybe Double
- presencePenalty :: Maybe Double
- frequencyPenalty :: Maybe Double
- penalizeNewline :: Maybe Bool
- stop :: Maybe [Text]
- numa :: Maybe Bool
- numCtx :: Maybe Int
- numBatch :: Maybe Int
- numGpu :: Maybe Int
- mainGpu :: Maybe Int
- useMmap :: Maybe Bool
- numThread :: Maybe Int
- data InputTool = InputTool {
- toolType :: Text
- function :: FunctionDef
- data FunctionDef = FunctionDef {}
- data FunctionParameters = FunctionParameters {}
- newtype ToolCall = ToolCall {}
- data OutputFunction = OutputFunction {}
- newtype Version = Version Text
Documentation
data ModelDetails Source #
Metadata describing a specific model's identity and configuration.
Constructors
ModelDetails | |
Fields
|
Instances
FromJSON ModelDetails Source # | |
Defined in Data.Ollama.Common.Types | |
Show ModelDetails Source # | |
Defined in Data.Ollama.Common.Types Methods showsPrec :: Int -> ModelDetails -> ShowS # show :: ModelDetails -> String # showList :: [ModelDetails] -> ShowS # | |
Eq ModelDetails Source # | |
Defined in Data.Ollama.Common.Types |
Format specification for the chat output.
Since: 0.1.3.0
Constructors
JsonFormat | |
SchemaFormat Schema |
data GenerateResponse Source #
Result type for generate
function containing the model's response and meta-information.
Constructors
GenerateResponse | |
Fields
|
Instances
FromJSON GenerateResponse Source # | |
Defined in Data.Ollama.Common.Types Methods parseJSON :: Value -> Parser GenerateResponse # parseJSONList :: Value -> Parser [GenerateResponse] # | |
Show GenerateResponse Source # | |
Defined in Data.Ollama.Common.Types Methods showsPrec :: Int -> GenerateResponse -> ShowS # show :: GenerateResponse -> String # showList :: [GenerateResponse] -> ShowS # | |
Eq GenerateResponse Source # | |
Defined in Data.Ollama.Common.Types Methods (==) :: GenerateResponse -> GenerateResponse -> Bool # (/=) :: GenerateResponse -> GenerateResponse -> Bool # | |
HasDone GenerateResponse Source # | |
Defined in Data.Ollama.Common.Types Methods getDone :: GenerateResponse -> Bool Source # |
Represents a message within a chat, including its role and content.
Constructors
Message | |
Fields |
Instances
Enumerated roles that can participate in a chat.
data ChatResponse Source #
Constructors
ChatResponse | |
Fields
|
Instances
FromJSON ChatResponse Source # | |
Defined in Data.Ollama.Common.Types | |
Show ChatResponse Source # | |
Defined in Data.Ollama.Common.Types Methods showsPrec :: Int -> ChatResponse -> ShowS # show :: ChatResponse -> String # showList :: [ChatResponse] -> ShowS # | |
Eq ChatResponse Source # | |
Defined in Data.Ollama.Common.Types | |
HasDone ChatResponse Source # | |
Defined in Data.Ollama.Common.Types Methods getDone :: ChatResponse -> Bool Source # |
class HasDone a where Source #
A workaround to use done field within commonStreamHandler
Instances
HasDone ChatResponse Source # | |
Defined in Data.Ollama.Common.Types Methods getDone :: ChatResponse -> Bool Source # | |
HasDone GenerateResponse Source # | |
Defined in Data.Ollama.Common.Types Methods getDone :: GenerateResponse -> Bool Source # |
data ModelOptions Source #
Optional model tuning parameters that influence generation behavior.
Since: 0.2.0.0
Constructors
ModelOptions | |
Fields
|
Instances
ToJSON ModelOptions Source # | Custom ToJSON instance for Options |
Defined in Data.Ollama.Common.Types Methods toJSON :: ModelOptions -> Value # toEncoding :: ModelOptions -> Encoding # toJSONList :: [ModelOptions] -> Value # toEncodingList :: [ModelOptions] -> Encoding # omitField :: ModelOptions -> Bool # | |
Show ModelOptions Source # | |
Defined in Data.Ollama.Common.Types Methods showsPrec :: Int -> ModelOptions -> ShowS # show :: ModelOptions -> String # showList :: [ModelOptions] -> ShowS # | |
Eq ModelOptions Source # | |
Defined in Data.Ollama.Common.Types |
Represents a tool that can be used in the conversation.
Since: 0.2.0.0
Constructors
InputTool | |
Fields
|
Instances
FromJSON InputTool Source # | |||||
Defined in Data.Ollama.Common.Types | |||||
ToJSON InputTool Source # | |||||
Generic InputTool Source # | |||||
Defined in Data.Ollama.Common.Types Associated Types
| |||||
Show InputTool Source # | |||||
Eq InputTool Source # | |||||
type Rep InputTool Source # | |||||
Defined in Data.Ollama.Common.Types type Rep InputTool = D1 ('MetaData "InputTool" "Data.Ollama.Common.Types" "ollama-haskell-0.2.0.0-FoTQnIMi8UeBjcOZ65CLdd" 'False) (C1 ('MetaCons "InputTool" 'PrefixI 'True) (S1 ('MetaSel ('Just "toolType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "function") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FunctionDef))) |
data FunctionDef Source #
Represents a function that can be called by the model.
Since: 0.2.0.0
Constructors
FunctionDef | |
Fields
|
Instances
FromJSON FunctionDef Source # | |||||
Defined in Data.Ollama.Common.Types | |||||
ToJSON FunctionDef Source # | |||||
Defined in Data.Ollama.Common.Types Methods toJSON :: FunctionDef -> Value # toEncoding :: FunctionDef -> Encoding # toJSONList :: [FunctionDef] -> Value # toEncodingList :: [FunctionDef] -> Encoding # omitField :: FunctionDef -> Bool # | |||||
Generic FunctionDef Source # | |||||
Defined in Data.Ollama.Common.Types Associated Types
| |||||
Show FunctionDef Source # | |||||
Defined in Data.Ollama.Common.Types Methods showsPrec :: Int -> FunctionDef -> ShowS # show :: FunctionDef -> String # showList :: [FunctionDef] -> ShowS # | |||||
Eq FunctionDef Source # | |||||
Defined in Data.Ollama.Common.Types | |||||
type Rep FunctionDef Source # | |||||
Defined in Data.Ollama.Common.Types type Rep FunctionDef = D1 ('MetaData "FunctionDef" "Data.Ollama.Common.Types" "ollama-haskell-0.2.0.0-FoTQnIMi8UeBjcOZ65CLdd" 'False) (C1 ('MetaCons "FunctionDef" 'PrefixI 'True) ((S1 ('MetaSel ('Just "functionName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "functionDescription") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text))) :*: (S1 ('MetaSel ('Just "functionParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe FunctionParameters)) :*: S1 ('MetaSel ('Just "functionStrict") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Bool))))) |
data FunctionParameters Source #
Parameters definition for a function call used in structured output or tool calls.
Since: 0.2.0.0
Constructors
FunctionParameters | |
Fields
|
Instances
FromJSON FunctionParameters Source # | |
Defined in Data.Ollama.Common.Types Methods parseJSON :: Value -> Parser FunctionParameters # parseJSONList :: Value -> Parser [FunctionParameters] # | |
ToJSON FunctionParameters Source # | |
Defined in Data.Ollama.Common.Types Methods toJSON :: FunctionParameters -> Value # toEncoding :: FunctionParameters -> Encoding # toJSONList :: [FunctionParameters] -> Value # toEncodingList :: [FunctionParameters] -> Encoding # omitField :: FunctionParameters -> Bool # | |
Show FunctionParameters Source # | |
Defined in Data.Ollama.Common.Types Methods showsPrec :: Int -> FunctionParameters -> ShowS # show :: FunctionParameters -> String # showList :: [FunctionParameters] -> ShowS # | |
Eq FunctionParameters Source # | |
Defined in Data.Ollama.Common.Types Methods (==) :: FunctionParameters -> FunctionParameters -> Bool # (/=) :: FunctionParameters -> FunctionParameters -> Bool # |
A single tool call returned from the model, containing the function to be invoked.
Since: 0.2.0.0
Constructors
ToolCall | |
Fields
|
data OutputFunction Source #
Output representation of a function to be called, including its name and arguments.
Since: 0.2.0.0
Constructors
OutputFunction | |
Instances
FromJSON OutputFunction Source # | |
Defined in Data.Ollama.Common.Types Methods parseJSON :: Value -> Parser OutputFunction # parseJSONList :: Value -> Parser [OutputFunction] # | |
ToJSON OutputFunction Source # | |
Defined in Data.Ollama.Common.Types Methods toJSON :: OutputFunction -> Value # toEncoding :: OutputFunction -> Encoding # toJSONList :: [OutputFunction] -> Value # toEncodingList :: [OutputFunction] -> Encoding # omitField :: OutputFunction -> Bool # | |
Show OutputFunction Source # | |
Defined in Data.Ollama.Common.Types Methods showsPrec :: Int -> OutputFunction -> ShowS # show :: OutputFunction -> String # showList :: [OutputFunction] -> ShowS # | |
Eq OutputFunction Source # | |
Defined in Data.Ollama.Common.Types Methods (==) :: OutputFunction -> OutputFunction -> Bool # (/=) :: OutputFunction -> OutputFunction -> Bool # |