packages feed

openai-1.0.1 / src / OpenAI / V1 / Tool.hs

-- | The `Tool` typemodule OpenAI.V1.Tool    ( -- * Types      Tool(..)    , RankingOptions(..)    , FileSearch(..)    , Function(..)    , ToolChoice(..)    ) whereimport OpenAI.Prelude-- | The ranking options for the file searchdata RankingOptions = RankingOptions    { ranker :: Maybe Text    , score_threshold :: Double    } deriving stock (Generic, Show)      deriving anyclass (FromJSON, ToJSON)-- | Overrides for the file search tooldata FileSearch = FileSearch    { max_num_results :: Maybe Natural    , ranking_options :: Maybe RankingOptions    } deriving stock (Generic, Show)      deriving anyclass (FromJSON, ToJSON)-- | The Function tooldata Function = Function    { description :: Maybe Text    , name :: Text    , parameters :: Maybe Value    , strict :: Maybe Bool    } deriving stock (Generic, Show)      deriving anyclass (FromJSON, ToJSON)-- | A tool enabled on the assistantdata Tool    = Tool_Code_Interpreter    | Tool_File_Search{ file_search :: FileSearch }    | Tool_Function{ function :: Function }    deriving stock (Generic, Show)toolOptions :: OptionstoolOptions = aesonOptions    { sumEncoding =        TaggedObject{ tagFieldName = "type", contentsFieldName = "" }    , tagSingleConstructors = True    , constructorTagModifier = stripPrefix "Tool_"    }instance FromJSON Tool where    parseJSON = genericParseJSON toolOptionsinstance ToJSON Tool where    toJSON = genericToJSON toolOptions-- | Controls which (if any) tool is called by the modeldata ToolChoice    = ToolChoiceNone    | ToolChoiceAuto    | ToolChoiceRequired    | ToolChoiceTool Tool    deriving stock (Generic, Show)instance FromJSON ToolChoice where    parseJSON "none" = pure ToolChoiceNone    parseJSON "auto" = pure ToolChoiceAuto    parseJSON "required" = pure ToolChoiceRequired    parseJSON other = fmap ToolChoiceTool (parseJSON other)instance ToJSON ToolChoice where    toJSON ToolChoiceNone = "none"    toJSON ToolChoiceAuto = "auto"    toJSON ToolChoiceRequired = "required"    toJSON (ToolChoiceTool tool) = toJSON tool