File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
openai-servant/src/OpenAI Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1+ {-# LANGUAGE DataKinds #-}
12-- | The API
23module OpenAI.Api where
34
@@ -6,9 +7,19 @@ import Servant.API
67import Servant.Auth
78import Servant.Auth.Client
89import Servant.Multipart.API
10+ import Data.List.NonEmpty (NonEmpty ((:|) ))
11+ import Data.ByteString.Lazy (ByteString )
912
1013type OpenAIAuth = Auth '[Bearer ] ()
1114
15+ data Audio
16+
17+ instance Accept Audio where
18+ contentTypes _ = " audio/mpeg" :| []
19+
20+ instance MimeUnrender Audio ByteString where
21+ mimeUnrender _ bs = Right bs
22+
1223type OpenAIApi =
1324 " v1" :> OpenAIApiInternal
1425
@@ -46,7 +57,7 @@ type EmbeddingsApi =
4657 OpenAIAuth :> ReqBody '[JSON ] EmbeddingCreate :> Post '[JSON ] EmbeddingResponse
4758
4859type AudioApi =
49- OpenAIAuth :> " speech" :> ReqBody '[JSON ] TextToSpeechRequest :> Post '[OctetStream ] TextToSpeechResponse
60+ OpenAIAuth :> " speech" :> ReqBody '[JSON ] TextToSpeechRequest :> Post '[Audio ] TextToSpeechResponse
5061 :<|> OpenAIAuth :> " transcriptions" :> MultipartForm Tmp AudioTranscriptionRequest :> Post '[JSON ] AudioResponseData
5162 :<|> OpenAIAuth :> " translations" :> MultipartForm Tmp AudioTranslationRequest :> Post '[JSON ] AudioResponseData
5263
You can’t perform that action at this time.
0 commit comments