openai-servant-gen-0.1.0.1: Auto-generated API bindings for openai
Safe HaskellSafe-Inferred
LanguageHaskell2010

OpenAI.API

Synopsis

Client and Server

data Config Source #

Server or client configuration, specifying the host and port to query or serve on.

Constructors

Config 

Fields

Instances

Instances details
Read Config Source # 
Instance details

Defined in OpenAI.API

Show Config Source # 
Instance details

Defined in OpenAI.API

Eq Config Source # 
Instance details

Defined in OpenAI.API

Methods

(==) :: Config -> Config -> Bool #

(/=) :: Config -> Config -> Bool #

Ord Config Source # 
Instance details

Defined in OpenAI.API

data OpenAIBackend a m Source #

Configuration, specifying the full url of the service.

Backend for OpenAI. The backend can be used both for the client and the server. The client generated from the OpenAI OpenAPI spec is a backend that executes actions by sending HTTP requests (see createOpenAIClient). Alternatively, provided a backend, the API can be served using runOpenAIMiddlewareServer.

Constructors

OpenAIBackend 

Fields

runOpenAIServer :: (MonadIO m, MonadThrow m) => Config -> OpenAIAuth -> OpenAIBackend AuthServer (ExceptT ServerError IO) -> m () Source #

Run the OpenAI server at the provided host and port.

runOpenAIMiddlewareServer :: (MonadIO m, MonadThrow m) => Config -> Middleware -> OpenAIAuth -> OpenAIBackend AuthServer (ExceptT ServerError IO) -> m () Source #

Run the OpenAI server at the provided host and port.

runOpenAIClient :: Config -> OpenAIClient a -> ExceptT ClientError IO a Source #

Run requests in the OpenAIClient monad.

runOpenAIClientWithManager :: Manager -> Config -> OpenAIClient a -> ExceptT ClientError IO a Source #

Run requests in the OpenAIClient monad using a custom manager.

callOpenAI :: (MonadIO m, MonadThrow m) => ClientEnv -> OpenAIClient a -> m a Source #

Like runClient, but returns the response or throws a OpenAIClientError

data OpenAIClient a Source #

Instances

Instances details
MonadIO OpenAIClient Source # 
Instance details

Defined in OpenAI.API

Methods

liftIO :: IO a -> OpenAIClient a #

Applicative OpenAIClient Source # 
Instance details

Defined in OpenAI.API

Functor OpenAIClient Source # 
Instance details

Defined in OpenAI.API

Methods

fmap :: (a -> b) -> OpenAIClient a -> OpenAIClient b #

(<$) :: a -> OpenAIClient b -> OpenAIClient a #

Monad OpenAIClient Source # 
Instance details

Defined in OpenAI.API

Servant

type OpenAIAPI = (Protected :> ("threads" :> (Capture "thread_id" Text :> ("runs" :> (Capture "run_id" Text :> ("cancel" :> Verb 'POST 200 '[JSON] RunObject)))))) :<|> ((Protected :> ("assistants" :> (ReqBody '[JSON] CreateAssistantRequest :> Verb 'POST 200 '[JSON] AssistantObject))) :<|> ((Protected :> ("assistants" :> (Capture "assistant_id" Text :> ("files" :> (ReqBody '[JSON] CreateAssistantFileRequest :> Verb 'POST 200 '[JSON] AssistantFileObject))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("messages" :> (ReqBody '[JSON] CreateMessageRequest :> Verb 'POST 200 '[JSON] MessageObject))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("runs" :> (ReqBody '[JSON] CreateRunRequest :> Verb 'POST 200 '[JSON] RunObject))))) :<|> ((Protected :> ("threads" :> (ReqBody '[JSON] CreateThreadRequest :> Verb 'POST 200 '[JSON] ThreadObject))) :<|> ((Protected :> ("threads" :> ("runs" :> (ReqBody '[JSON] CreateThreadAndRunRequest :> Verb 'POST 200 '[JSON] RunObject)))) :<|> ((Protected :> ("assistants" :> (Capture "assistant_id" Text :> Verb 'DELETE 200 '[JSON] DeleteAssistantResponse))) :<|> ((Protected :> ("assistants" :> (Capture "assistant_id" Text :> ("files" :> (Capture "file_id" Text :> Verb 'DELETE 200 '[JSON] DeleteAssistantFileResponse))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> Verb 'DELETE 200 '[JSON] DeleteThreadResponse))) :<|> ((Protected :> ("assistants" :> (Capture "assistant_id" Text :> Verb 'GET 200 '[JSON] AssistantObject))) :<|> ((Protected :> ("assistants" :> (Capture "assistant_id" Text :> ("files" :> (Capture "file_id" Text :> Verb 'GET 200 '[JSON] AssistantFileObject))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("messages" :> (Capture "message_id" Text :> Verb 'GET 200 '[JSON] MessageObject))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("messages" :> (Capture "message_id" Text :> ("files" :> (Capture "file_id" Text :> Verb 'GET 200 '[JSON] MessageFileObject))))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("runs" :> (Capture "run_id" Text :> Verb 'GET 200 '[JSON] RunObject))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("runs" :> (Capture "run_id" Text :> ("steps" :> (Capture "step_id" Text :> Verb 'GET 200 '[JSON] RunStepObject))))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> Verb 'GET 200 '[JSON] ThreadObject))) :<|> ((Protected :> ("assistants" :> (Capture "assistant_id" Text :> ("files" :> (QueryParam "limit" Int :> (QueryParam "order" Text :> (QueryParam "after" Text :> (QueryParam "before" Text :> Verb 'GET 200 '[JSON] ListAssistantFilesResponse)))))))) :<|> ((Protected :> ("assistants" :> (QueryParam "limit" Int :> (QueryParam "order" Text :> (QueryParam "after" Text :> (QueryParam "before" Text :> Verb 'GET 200 '[JSON] ListAssistantsResponse)))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("messages" :> (Capture "message_id" Text :> ("files" :> (QueryParam "limit" Int :> (QueryParam "order" Text :> (QueryParam "after" Text :> (QueryParam "before" Text :> Verb 'GET 200 '[JSON] ListMessageFilesResponse)))))))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("messages" :> (QueryParam "limit" Int :> (QueryParam "order" Text :> (QueryParam "after" Text :> (QueryParam "before" Text :> Verb 'GET 200 '[JSON] ListMessagesResponse)))))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("runs" :> (Capture "run_id" Text :> ("steps" :> (QueryParam "limit" Int :> (QueryParam "order" Text :> (QueryParam "after" Text :> (QueryParam "before" Text :> Verb 'GET 200 '[JSON] ListRunStepsResponse)))))))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("runs" :> (QueryParam "limit" Int :> (QueryParam "order" Text :> (QueryParam "after" Text :> (QueryParam "before" Text :> Verb 'GET 200 '[JSON] ListRunsResponse)))))))) :<|> ((Protected :> ("assistants" :> (Capture "assistant_id" Text :> (ReqBody '[JSON] ModifyAssistantRequest :> Verb 'POST 200 '[JSON] AssistantObject)))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("messages" :> (Capture "message_id" Text :> (ReqBody '[JSON] ModifyMessageRequest :> Verb 'POST 200 '[JSON] MessageObject)))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("runs" :> (Capture "run_id" Text :> (ReqBody '[JSON] ModifyRunRequest :> Verb 'POST 200 '[JSON] RunObject)))))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> (ReqBody '[JSON] ModifyThreadRequest :> Verb 'POST 200 '[JSON] ThreadObject)))) :<|> ((Protected :> ("threads" :> (Capture "thread_id" Text :> ("runs" :> (Capture "run_id" Text :> ("submit_tool_outputs" :> (ReqBody '[JSON] SubmitToolOutputsRunRequest :> Verb 'POST 200 '[JSON] RunObject))))))) :<|> ((Protected :> ("audio" :> ("speech" :> (ReqBody '[JSON] CreateSpeechRequest :> Verb 'POST 200 '[AudioMpeg] ByteString)))) :<|> ((Protected :> ("audio" :> ("transcriptions" :> (ReqBody '[FormUrlEncoded] FormCreateTranscription :> Verb 'POST 200 '[JSON] CreateTranscription200Response)))) :<|> ((Protected :> ("audio" :> ("translations" :> (ReqBody '[FormUrlEncoded] FormCreateTranslation :> Verb 'POST 200 '[JSON] CreateTranslation200Response)))) :<|> ((Protected :> ("chat" :> ("completions" :> (ReqBody '[JSON] CreateChatCompletionRequest :> Verb 'POST 200 '[JSON] CreateChatCompletionResponse)))) :<|> ((Protected :> ("completions" :> (ReqBody '[JSON] CreateCompletionRequest :> Verb 'POST 200 '[JSON] CreateCompletionResponse))) :<|> ((Protected :> ("embeddings" :> (ReqBody '[JSON] CreateEmbeddingRequest :> Verb 'POST 200 '[JSON] CreateEmbeddingResponse))) :<|> ((Protected :> ("files" :> (ReqBody '[FormUrlEncoded] FormCreateFile :> Verb 'POST 200 '[JSON] OpenAIFile))) :<|> ((Protected :> ("files" :> (Capture "file_id" Text :> Verb 'DELETE 200 '[JSON] DeleteFileResponse))) :<|> ((Protected :> ("files" :> (Capture "file_id" Text :> ("content" :> Verb 'GET 200 '[JSON] Text)))) :<|> ((Protected :> ("files" :> (QueryParam "purpose" Text :> Verb 'GET 200 '[JSON] ListFilesResponse))) :<|> ((Protected :> ("files" :> (Capture "file_id" Text :> Verb 'GET 200 '[JSON] OpenAIFile))) :<|> ((Protected :> ("fine_tuning" :> ("jobs" :> (Capture "fine_tuning_job_id" Text :> ("cancel" :> Verb 'POST 200 '[JSON] FineTuningJob))))) :<|> ((Protected :> ("fine_tuning" :> ("jobs" :> (ReqBody '[JSON] CreateFineTuningJobRequest :> Verb 'POST 200 '[JSON] FineTuningJob)))) :<|> ((Protected :> ("fine_tuning" :> ("jobs" :> (Capture "fine_tuning_job_id" Text :> ("events" :> (QueryParam "after" Text :> (QueryParam "limit" Int :> Verb 'GET 200 '[JSON] ListFineTuningJobEventsResponse))))))) :<|> ((Protected :> ("fine_tuning" :> ("jobs" :> (QueryParam "after" Text :> (QueryParam "limit" Int :> Verb 'GET 200 '[JSON] ListPaginatedFineTuningJobsResponse))))) :<|> ((Protected :> ("fine_tuning" :> ("jobs" :> (Capture "fine_tuning_job_id" Text :> Verb 'GET 200 '[JSON] FineTuningJob)))) :<|> ((Protected :> ("images" :> ("generations" :> (ReqBody '[JSON] CreateImageRequest :> Verb 'POST 200 '[JSON] ImagesResponse)))) :<|> ((Protected :> ("images" :> ("edits" :> (ReqBody '[FormUrlEncoded] FormCreateImageEdit :> Verb 'POST 200 '[JSON] ImagesResponse)))) :<|> ((Protected :> ("images" :> ("variations" :> (ReqBody '[FormUrlEncoded] FormCreateImageVariation :> Verb 'POST 200 '[JSON] ImagesResponse)))) :<|> ((Protected :> ("models" :> (Capture "model" Text :> Verb 'DELETE 200 '[JSON] DeleteModelResponse))) :<|> ((Protected :> ("models" :> Verb 'GET 200 '[JSON] ListModelsResponse)) :<|> ((Protected :> ("models" :> (Capture "model" Text :> Verb 'GET 200 '[JSON] Model))) :<|> ((Protected :> ("moderations" :> (ReqBody '[JSON] CreateModerationRequest :> Verb 'POST 200 '[JSON] CreateModerationResponse))) :<|> Raw)))))))))))))))))))))))))))))))))))))))))))))))))) Source #

Servant type-level API, generated from the OpenAPI spec for OpenAI.

Plain WAI Application

serverWaiApplicationOpenAI :: OpenAIAuth -> OpenAIBackend AuthServer (ExceptT ServerError IO) -> Application Source #

Plain Network.Wai Application for the OpenAI server.

Can be used to implement e.g. tests that call the API without a full webserver.

Authentication

data OpenAIAuth Source #

Authentication settings for OpenAI. lookupUser is used to retrieve a user given a header value. The data type can be specified by providing an type instance for AuthServerData. authError is a function that given a request returns a custom error that is returned when the header is not found.

Constructors

OpenAIAuth 

Fields

clientAuth :: Text -> AuthClient Source #

type Protected = AuthProtect "bearer" Source #