Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type ApiKey = Text
- data OpenAIClient
- makeOpenAIClient :: ApiKey -> Manager -> Int -> OpenAIClient
- data ClientError
- newtype TimeStamp = TimeStamp {}
- newtype OpenAIList a = OpenAIList {}
- newtype EngineId = EngineId {
- unEngineId :: Text
- data Engine = Engine {}
- listEngines :: OpenAIClient -> IO (Either ClientError (OpenAIList Engine))
- getEngine :: OpenAIClient -> EngineId -> IO (Either ClientError Engine)
- newtype TextCompletionId = TextCompletionId {}
- data TextCompletionChoice = TextCompletionChoice {
- tccText :: Text
- tccIndex :: Int
- tccLogProps :: Maybe Int
- tccFinishReason :: Text
- data TextCompletion = TextCompletion {}
- data TextCompletionCreate = TextCompletionCreate {}
- defaultTextCompletionCreate :: Text -> TextCompletionCreate
- completeText :: OpenAIClient -> EngineId -> TextCompletionCreate -> IO (Either ClientError TextCompletion)
- data EmbeddingCreate = EmbeddingCreate {}
- data Embedding = Embedding {
- eEmbedding :: Vector Double
- eIndex :: Int
- createEmbedding :: OpenAIClient -> EngineId -> EmbeddingCreate -> IO (Either ClientError (OpenAIList Embedding))
- newtype FineTuneId = FineTuneId {
- unFineTuneId :: Text
- data FineTuneCreate = FineTuneCreate {
- ftcTrainingFile :: FileId
- ftcValidationFile :: Maybe FileId
- ftcModel :: Maybe Text
- ftcBatchSize :: Maybe Int
- ftcNEpochs :: Maybe Text
- ftcLearningRateMultiplier :: Maybe Double
- ftcPromptLossWeight :: Maybe Double
- ftcComputeClassificationMetrics :: Maybe Bool
- ftcClassificationNClasses :: Maybe Int
- ftcClassificationPositiveClass :: Maybe Text
- defaultFineTuneCreate :: FileId -> FineTuneCreate
- data FineTune = FineTune {
- ftId :: FineTuneId
- ftModel :: Text
- ftCreatedAt :: Int
- ftEvents :: Vector FineTuneEvent
- ftTunedModel :: Maybe Text
- ftStatus :: Text
- data FineTuneEvent = FineTuneEvent {
- fteCreatedAt :: Int
- fteLevel :: Text
- fteMessage :: Text
- createFineTune :: OpenAIClient -> FineTuneCreate -> IO (Either ClientError FineTune)
- listFineTunes :: OpenAIClient -> IO (Either ClientError (OpenAIList FineTune))
- getFineTune :: OpenAIClient -> FineTuneId -> IO (Either ClientError FineTune)
- cancelFineTune :: OpenAIClient -> FineTuneId -> IO (Either ClientError FineTune)
- listFineTuneEvents :: OpenAIClient -> FineTuneId -> IO (Either ClientError (OpenAIList FineTuneEvent))
- data SearchResult = SearchResult {
- srDocument :: Int
- srScore :: Double
- srMetadata :: Maybe Text
- data SearchResultCreate = SearchResultCreate {}
- searchDocuments :: OpenAIClient -> EngineId -> SearchResultCreate -> IO (Either ClientError (OpenAIList SearchResult))
- data FileCreate = FileCreate {
- fcPurpose :: Text
- fcDocuments :: [FileHunk]
- data File = File {}
- newtype FileId = FileId {}
- data FileHunk
- data SearchHunk = SearchHunk {
- shText :: Text
- shMetadata :: Maybe Text
- data ClassificationHunk = ClassificationHunk {}
- data FineTuneHunk = FineTuneHunk {
- fthPrompt :: Text
- fthCompletion :: Text
- data FileDeleteConfirmation = FileDeleteConfirmation {}
- createFile :: OpenAIClient -> FileCreate -> IO (Either ClientError File)
- deleteFile :: OpenAIClient -> FileId -> IO (Either ClientError FileDeleteConfirmation)
- getAnswer :: OpenAIClient -> AnswerReq -> IO (Either ClientError AnswerResp)
- data AnswerReq = AnswerReq {
- arFile :: Maybe FileId
- arDocuments :: Maybe (Vector Text)
- arQuestion :: Text
- arSearchModel :: EngineId
- arModel :: EngineId
- arExamplesContext :: Text
- arExamples :: [[Text]]
- arReturnMetadata :: Bool
- data AnswerResp = AnswerResp {
- arsAnswers :: [Text]
Basics
Your OpenAI API key. Can be obtained from the OpenAI dashboard. Format: sk-redacted
data OpenAIClient Source #
Holds a Manager
and your API key.
:: ApiKey | |
-> Manager | |
-> Int | Number of automatic retries the library should attempt. |
-> OpenAIClient |
Construct a OpenAIClient
. Note that the passed Manager
must support https (e.g. via http-client-tls
)
data ClientError #
A type representing possible errors in a request
Note that this type substantially changed in 0.12.
FailureResponse (RequestF () (BaseUrl, ByteString)) Response | The server returned an error response including the
failing request. |
DecodeFailure Text Response | The body could not be decoded at the expected type |
UnsupportedContentType MediaType Response | The content-type of the response is not supported |
InvalidContentTypeHeader Response | The content-type header is invalid |
ConnectionError SomeException | There was a connection error, and no response was received |
Instances
Helper types
A UTCTime
wrapper that has unix timestamp JSON representation
Instances
Eq TimeStamp | |
Show TimeStamp | |
ToJSON TimeStamp | |
Defined in OpenAI.Resources | |
FromJSON TimeStamp | |
ToHttpApiData TimeStamp | |
Defined in OpenAI.Resources toUrlPiece :: TimeStamp -> Text # toEncodedUrlPiece :: TimeStamp -> Builder # toHeader :: TimeStamp -> ByteString # toQueryParam :: TimeStamp -> Text # |
newtype OpenAIList a #
A Vector
wrapper.
Instances
Engine
Instances
Eq EngineId | |
Show EngineId | |
ToJSON EngineId | |
Defined in OpenAI.Resources | |
FromJSON EngineId | |
ToHttpApiData EngineId | |
Defined in OpenAI.Resources toUrlPiece :: EngineId -> Text # toEncodedUrlPiece :: EngineId -> Builder # toHeader :: EngineId -> ByteString # toQueryParam :: EngineId -> Text # |
listEngines :: OpenAIClient -> IO (Either ClientError (OpenAIList Engine)) Source #
getEngine :: OpenAIClient -> EngineId -> IO (Either ClientError Engine) Source #
Text completion
newtype TextCompletionId #
Instances
Eq TextCompletionId | |
Defined in OpenAI.Resources (==) :: TextCompletionId -> TextCompletionId -> Bool # (/=) :: TextCompletionId -> TextCompletionId -> Bool # | |
Show TextCompletionId | |
Defined in OpenAI.Resources showsPrec :: Int -> TextCompletionId -> ShowS # show :: TextCompletionId -> String # showList :: [TextCompletionId] -> ShowS # | |
ToJSON TextCompletionId | |
Defined in OpenAI.Resources toJSON :: TextCompletionId -> Value # toEncoding :: TextCompletionId -> Encoding # toJSONList :: [TextCompletionId] -> Value # toEncodingList :: [TextCompletionId] -> Encoding # | |
FromJSON TextCompletionId | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser TextCompletionId # parseJSONList :: Value -> Parser [TextCompletionId] # | |
ToHttpApiData TextCompletionId | |
Defined in OpenAI.Resources toUrlPiece :: TextCompletionId -> Text # toEncodedUrlPiece :: TextCompletionId -> Builder # toHeader :: TextCompletionId -> ByteString # toQueryParam :: TextCompletionId -> Text # |
data TextCompletionChoice #
TextCompletionChoice | |
|
Instances
Eq TextCompletionChoice | |
Defined in OpenAI.Resources (==) :: TextCompletionChoice -> TextCompletionChoice -> Bool # (/=) :: TextCompletionChoice -> TextCompletionChoice -> Bool # | |
Show TextCompletionChoice | |
Defined in OpenAI.Resources showsPrec :: Int -> TextCompletionChoice -> ShowS # show :: TextCompletionChoice -> String # showList :: [TextCompletionChoice] -> ShowS # | |
ToJSON TextCompletionChoice | |
Defined in OpenAI.Resources toJSON :: TextCompletionChoice -> Value # toEncoding :: TextCompletionChoice -> Encoding # toJSONList :: [TextCompletionChoice] -> Value # toEncodingList :: [TextCompletionChoice] -> Encoding # | |
FromJSON TextCompletionChoice | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser TextCompletionChoice # parseJSONList :: Value -> Parser [TextCompletionChoice] # |
data TextCompletion #
Instances
Eq TextCompletion | |
Defined in OpenAI.Resources (==) :: TextCompletion -> TextCompletion -> Bool # (/=) :: TextCompletion -> TextCompletion -> Bool # | |
Show TextCompletion | |
Defined in OpenAI.Resources showsPrec :: Int -> TextCompletion -> ShowS # show :: TextCompletion -> String # showList :: [TextCompletion] -> ShowS # | |
ToJSON TextCompletion | |
Defined in OpenAI.Resources toJSON :: TextCompletion -> Value # toEncoding :: TextCompletion -> Encoding # toJSONList :: [TextCompletion] -> Value # toEncodingList :: [TextCompletion] -> Encoding # | |
FromJSON TextCompletion | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser TextCompletion # parseJSONList :: Value -> Parser [TextCompletion] # |
data TextCompletionCreate #
TextCompletionCreate | |
|
Instances
Eq TextCompletionCreate | |
Defined in OpenAI.Resources (==) :: TextCompletionCreate -> TextCompletionCreate -> Bool # (/=) :: TextCompletionCreate -> TextCompletionCreate -> Bool # | |
Show TextCompletionCreate | |
Defined in OpenAI.Resources showsPrec :: Int -> TextCompletionCreate -> ShowS # show :: TextCompletionCreate -> String # showList :: [TextCompletionCreate] -> ShowS # | |
ToJSON TextCompletionCreate | |
Defined in OpenAI.Resources toJSON :: TextCompletionCreate -> Value # toEncoding :: TextCompletionCreate -> Encoding # toJSONList :: [TextCompletionCreate] -> Value # toEncodingList :: [TextCompletionCreate] -> Encoding # | |
FromJSON TextCompletionCreate | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser TextCompletionCreate # parseJSONList :: Value -> Parser [TextCompletionCreate] # |
defaultTextCompletionCreate :: Text -> TextCompletionCreate #
Applies API defaults, only passing a prompt.
completeText :: OpenAIClient -> EngineId -> TextCompletionCreate -> IO (Either ClientError TextCompletion) Source #
Embeddings
data EmbeddingCreate #
Instances
Eq EmbeddingCreate | |
Defined in OpenAI.Resources (==) :: EmbeddingCreate -> EmbeddingCreate -> Bool # (/=) :: EmbeddingCreate -> EmbeddingCreate -> Bool # | |
Show EmbeddingCreate | |
Defined in OpenAI.Resources showsPrec :: Int -> EmbeddingCreate -> ShowS # show :: EmbeddingCreate -> String # showList :: [EmbeddingCreate] -> ShowS # | |
ToJSON EmbeddingCreate | |
Defined in OpenAI.Resources toJSON :: EmbeddingCreate -> Value # toEncoding :: EmbeddingCreate -> Encoding # toJSONList :: [EmbeddingCreate] -> Value # toEncodingList :: [EmbeddingCreate] -> Encoding # | |
FromJSON EmbeddingCreate | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser EmbeddingCreate # parseJSONList :: Value -> Parser [EmbeddingCreate] # |
createEmbedding :: OpenAIClient -> EngineId -> EmbeddingCreate -> IO (Either ClientError (OpenAIList Embedding)) Source #
Fine tunes
newtype FineTuneId #
Instances
Eq FineTuneId | |
Defined in OpenAI.Resources (==) :: FineTuneId -> FineTuneId -> Bool # (/=) :: FineTuneId -> FineTuneId -> Bool # | |
Show FineTuneId | |
Defined in OpenAI.Resources showsPrec :: Int -> FineTuneId -> ShowS # show :: FineTuneId -> String # showList :: [FineTuneId] -> ShowS # | |
ToJSON FineTuneId | |
Defined in OpenAI.Resources toJSON :: FineTuneId -> Value # toEncoding :: FineTuneId -> Encoding # toJSONList :: [FineTuneId] -> Value # toEncodingList :: [FineTuneId] -> Encoding # | |
FromJSON FineTuneId | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser FineTuneId # parseJSONList :: Value -> Parser [FineTuneId] # | |
ToHttpApiData FineTuneId | |
Defined in OpenAI.Resources toUrlPiece :: FineTuneId -> Text # toEncodedUrlPiece :: FineTuneId -> Builder # toHeader :: FineTuneId -> ByteString # toQueryParam :: FineTuneId -> Text # |
data FineTuneCreate #
Instances
Eq FineTuneCreate | |
Defined in OpenAI.Resources (==) :: FineTuneCreate -> FineTuneCreate -> Bool # (/=) :: FineTuneCreate -> FineTuneCreate -> Bool # | |
Show FineTuneCreate | |
Defined in OpenAI.Resources showsPrec :: Int -> FineTuneCreate -> ShowS # show :: FineTuneCreate -> String # showList :: [FineTuneCreate] -> ShowS # | |
ToJSON FineTuneCreate | |
Defined in OpenAI.Resources toJSON :: FineTuneCreate -> Value # toEncoding :: FineTuneCreate -> Encoding # toJSONList :: [FineTuneCreate] -> Value # toEncodingList :: [FineTuneCreate] -> Encoding # | |
FromJSON FineTuneCreate | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser FineTuneCreate # parseJSONList :: Value -> Parser [FineTuneCreate] # |
FineTune | |
|
data FineTuneEvent #
FineTuneEvent | |
|
Instances
Eq FineTuneEvent | |
Defined in OpenAI.Resources (==) :: FineTuneEvent -> FineTuneEvent -> Bool # (/=) :: FineTuneEvent -> FineTuneEvent -> Bool # | |
Show FineTuneEvent | |
Defined in OpenAI.Resources showsPrec :: Int -> FineTuneEvent -> ShowS # show :: FineTuneEvent -> String # showList :: [FineTuneEvent] -> ShowS # | |
ToJSON FineTuneEvent | |
Defined in OpenAI.Resources toJSON :: FineTuneEvent -> Value # toEncoding :: FineTuneEvent -> Encoding # toJSONList :: [FineTuneEvent] -> Value # toEncodingList :: [FineTuneEvent] -> Encoding # | |
FromJSON FineTuneEvent | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser FineTuneEvent # parseJSONList :: Value -> Parser [FineTuneEvent] # |
createFineTune :: OpenAIClient -> FineTuneCreate -> IO (Either ClientError FineTune) Source #
listFineTunes :: OpenAIClient -> IO (Either ClientError (OpenAIList FineTune)) Source #
getFineTune :: OpenAIClient -> FineTuneId -> IO (Either ClientError FineTune) Source #
cancelFineTune :: OpenAIClient -> FineTuneId -> IO (Either ClientError FineTune) Source #
listFineTuneEvents :: OpenAIClient -> FineTuneId -> IO (Either ClientError (OpenAIList FineTuneEvent)) Source #
Searching
data SearchResult #
SearchResult | |
|
Instances
Eq SearchResult | |
Defined in OpenAI.Resources (==) :: SearchResult -> SearchResult -> Bool # (/=) :: SearchResult -> SearchResult -> Bool # | |
Show SearchResult | |
Defined in OpenAI.Resources showsPrec :: Int -> SearchResult -> ShowS # show :: SearchResult -> String # showList :: [SearchResult] -> ShowS # | |
ToJSON SearchResult | |
Defined in OpenAI.Resources toJSON :: SearchResult -> Value # toEncoding :: SearchResult -> Encoding # toJSONList :: [SearchResult] -> Value # toEncodingList :: [SearchResult] -> Encoding # | |
FromJSON SearchResult | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser SearchResult # parseJSONList :: Value -> Parser [SearchResult] # |
data SearchResultCreate #
Instances
Eq SearchResultCreate | |
Defined in OpenAI.Resources (==) :: SearchResultCreate -> SearchResultCreate -> Bool # (/=) :: SearchResultCreate -> SearchResultCreate -> Bool # | |
Show SearchResultCreate | |
Defined in OpenAI.Resources showsPrec :: Int -> SearchResultCreate -> ShowS # show :: SearchResultCreate -> String # showList :: [SearchResultCreate] -> ShowS # | |
ToJSON SearchResultCreate | |
Defined in OpenAI.Resources toJSON :: SearchResultCreate -> Value # toEncoding :: SearchResultCreate -> Encoding # toJSONList :: [SearchResultCreate] -> Value # toEncodingList :: [SearchResultCreate] -> Encoding # | |
FromJSON SearchResultCreate | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser SearchResultCreate # parseJSONList :: Value -> Parser [SearchResultCreate] # |
searchDocuments :: OpenAIClient -> EngineId -> SearchResultCreate -> IO (Either ClientError (OpenAIList SearchResult)) Source #
File API
data FileCreate #
FileCreate | |
|
Instances
Eq FileCreate | |
Defined in OpenAI.Resources (==) :: FileCreate -> FileCreate -> Bool # (/=) :: FileCreate -> FileCreate -> Bool # | |
Show FileCreate | |
Defined in OpenAI.Resources showsPrec :: Int -> FileCreate -> ShowS # show :: FileCreate -> String # showList :: [FileCreate] -> ShowS # | |
ToMultipart Mem FileCreate | |
Defined in OpenAI.Resources toMultipart :: FileCreate -> MultipartData Mem # |
Instances
Eq FileId | |
Show FileId | |
ToJSON FileId | |
Defined in OpenAI.Resources | |
FromJSON FileId | |
ToHttpApiData FileId | |
Defined in OpenAI.Resources toUrlPiece :: FileId -> Text # toEncodedUrlPiece :: FileId -> Builder # toHeader :: FileId -> ByteString # toQueryParam :: FileId -> Text # |
data SearchHunk #
SearchHunk | |
|
Instances
Eq SearchHunk | |
Defined in OpenAI.Resources (==) :: SearchHunk -> SearchHunk -> Bool # (/=) :: SearchHunk -> SearchHunk -> Bool # | |
Show SearchHunk | |
Defined in OpenAI.Resources showsPrec :: Int -> SearchHunk -> ShowS # show :: SearchHunk -> String # showList :: [SearchHunk] -> ShowS # | |
ToJSON SearchHunk | |
Defined in OpenAI.Resources toJSON :: SearchHunk -> Value # toEncoding :: SearchHunk -> Encoding # toJSONList :: [SearchHunk] -> Value # toEncodingList :: [SearchHunk] -> Encoding # | |
FromJSON SearchHunk | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser SearchHunk # parseJSONList :: Value -> Parser [SearchHunk] # |
data ClassificationHunk #
Instances
Eq ClassificationHunk | |
Defined in OpenAI.Resources (==) :: ClassificationHunk -> ClassificationHunk -> Bool # (/=) :: ClassificationHunk -> ClassificationHunk -> Bool # | |
Show ClassificationHunk | |
Defined in OpenAI.Resources showsPrec :: Int -> ClassificationHunk -> ShowS # show :: ClassificationHunk -> String # showList :: [ClassificationHunk] -> ShowS # | |
ToJSON ClassificationHunk | |
Defined in OpenAI.Resources toJSON :: ClassificationHunk -> Value # toEncoding :: ClassificationHunk -> Encoding # toJSONList :: [ClassificationHunk] -> Value # toEncodingList :: [ClassificationHunk] -> Encoding # | |
FromJSON ClassificationHunk | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser ClassificationHunk # parseJSONList :: Value -> Parser [ClassificationHunk] # |
data FineTuneHunk #
Instances
Eq FineTuneHunk | |
Defined in OpenAI.Resources (==) :: FineTuneHunk -> FineTuneHunk -> Bool # (/=) :: FineTuneHunk -> FineTuneHunk -> Bool # | |
Show FineTuneHunk | |
Defined in OpenAI.Resources showsPrec :: Int -> FineTuneHunk -> ShowS # show :: FineTuneHunk -> String # showList :: [FineTuneHunk] -> ShowS # | |
ToJSON FineTuneHunk | |
Defined in OpenAI.Resources toJSON :: FineTuneHunk -> Value # toEncoding :: FineTuneHunk -> Encoding # toJSONList :: [FineTuneHunk] -> Value # toEncodingList :: [FineTuneHunk] -> Encoding # | |
FromJSON FineTuneHunk | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser FineTuneHunk # parseJSONList :: Value -> Parser [FineTuneHunk] # |
data FileDeleteConfirmation #
Instances
Eq FileDeleteConfirmation | |
Defined in OpenAI.Resources | |
Show FileDeleteConfirmation | |
Defined in OpenAI.Resources showsPrec :: Int -> FileDeleteConfirmation -> ShowS # show :: FileDeleteConfirmation -> String # showList :: [FileDeleteConfirmation] -> ShowS # | |
ToJSON FileDeleteConfirmation | |
Defined in OpenAI.Resources toJSON :: FileDeleteConfirmation -> Value # toEncoding :: FileDeleteConfirmation -> Encoding # toJSONList :: [FileDeleteConfirmation] -> Value # | |
FromJSON FileDeleteConfirmation | |
Defined in OpenAI.Resources |
createFile :: OpenAIClient -> FileCreate -> IO (Either ClientError File) Source #
deleteFile :: OpenAIClient -> FileId -> IO (Either ClientError FileDeleteConfirmation) Source #
Answer API
getAnswer :: OpenAIClient -> AnswerReq -> IO (Either ClientError AnswerResp) Source #
AnswerReq | |
|
data AnswerResp #
AnswerResp | |
|
Instances
Eq AnswerResp | |
Defined in OpenAI.Resources (==) :: AnswerResp -> AnswerResp -> Bool # (/=) :: AnswerResp -> AnswerResp -> Bool # | |
Show AnswerResp | |
Defined in OpenAI.Resources showsPrec :: Int -> AnswerResp -> ShowS # show :: AnswerResp -> String # showList :: [AnswerResp] -> ShowS # | |
ToJSON AnswerResp | |
Defined in OpenAI.Resources toJSON :: AnswerResp -> Value # toEncoding :: AnswerResp -> Encoding # toJSONList :: [AnswerResp] -> Value # toEncodingList :: [AnswerResp] -> Encoding # | |
FromJSON AnswerResp | |
Defined in OpenAI.Resources parseJSON :: Value -> Parser AnswerResp # parseJSONList :: Value -> Parser [AnswerResp] # |