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 SearchResult = SearchResult {
- srDocument :: Int
- srScore :: Double
- data SearchResultCreate = SearchResultCreate {
- sccrDocuments :: Vector Text
- sccrQuery :: Text
- searchDocuments :: OpenAIClient -> EngineId -> SearchResultCreate -> IO (Either ClientError (OpenAIList SearchResult))
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 #
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 #