Skip to content

Commit

Permalink
Merge pull request #28 from agrafix/nhs-remove-edits
Browse files Browse the repository at this point in the history
Remove deprecated edits API
  • Loading branch information
nickhs authored Jul 13, 2024
2 parents 7048304 + aaacff0 commit e02e5d8
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 73 deletions.
10 changes: 0 additions & 10 deletions openai-hs/src/OpenAI/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ module OpenAI.Client
defaultChatCompletionRequest,
completeChat,

-- * Edits
EditCreate (..),
EditChoice (..),
EditResponse (..),
createTextEdit,
defaultEditCreate,

-- * Images
ImageResponse (..),
ImageResponseData (..),
Expand Down Expand Up @@ -184,8 +177,6 @@ EP1 (completeText, CompletionCreate, CompletionResponse)

EP1 (completeChat, ChatCompletionRequest, ChatResponse)

EP1 (createTextEdit, EditCreate, EditResponse)

EP1 (generateImage, ImageCreate, ImageResponse)
EP1 (createImageEdit, ImageEditRequest, ImageResponse)
EP1 (createImageVariation, ImageVariationRequest, ImageResponse)
Expand Down Expand Up @@ -232,7 +223,6 @@ EP2 (engineCreateEmbedding, EngineId, EngineEmbeddingCreate, (OpenAIList EngineE
)
:<|> (completeText')
:<|> (completeChat')
:<|> (createTextEdit')
:<|> ( generateImage'
:<|> createImageEdit'
:<|> createImageVariation'
Expand Down
10 changes: 0 additions & 10 deletions openai-hs/test/ApiSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,6 @@ apiTests2023 =
res <- forceSuccess $ completeChat cli completion
chrChoices res `shouldNotBe` []

describe "edits api" $ do
it "create edit" $ \cli -> do
let edit =
(defaultEditCreate (ModelId "text-davinci-edit-001") "Fox" "Pluralize the word")
{ edcrN = Just 1
}
res <- forceSuccess $ createTextEdit cli edit
edrChoices res `shouldNotBe` []
edchText (head $ edrChoices res) `shouldBe` "Foxes\n"

-- TODO (2023.03.22): Create tests for images, audio APIs

describe "embeddings api" $ do
Expand Down
4 changes: 0 additions & 4 deletions openai-servant/src/OpenAI/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type OpenAIApiInternal =
"models" :> ModelsApi
:<|> "completions" :> CompletionsApi
:<|> "chat" :> ChatApi
:<|> "edits" :> EditsApi
:<|> "images" :> ImagesApi
:<|> "embeddings" :> EmbeddingsApi
:<|> "audio" :> AudioApi
Expand All @@ -34,9 +33,6 @@ type CompletionsApi =
type ChatApi =
OpenAIAuth :> "completions" :> ReqBody '[JSON] ChatCompletionRequest :> Post '[JSON] ChatResponse

type EditsApi =
OpenAIAuth :> ReqBody '[JSON] EditCreate :> Post '[JSON] EditResponse

type ImagesApi =
OpenAIAuth :> "generations" :> ReqBody '[JSON] ImageCreate :> Post '[JSON] ImageResponse
:<|> OpenAIAuth :> "edits" :> ReqBody '[JSON] ImageEditRequest :> Post '[JSON] ImageResponse
Expand Down
49 changes: 0 additions & 49 deletions openai-servant/src/OpenAI/Resources.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ module OpenAI.Resources
ChatResponseFormat(..),
defaultChatCompletionRequest,

-- * Edits
EditCreate (..),
EditChoice (..),
EditResponse (..),
defaultEditCreate,

-- * Images
ImageResponse (..),
ImageResponseData (..),
Expand Down Expand Up @@ -377,49 +371,6 @@ $(deriveJSON (jsonOpts 4) ''ChatCompletionRequest)
$(deriveJSON (jsonOpts 4) ''ChatChoice)
$(deriveJSON (jsonOpts 3) ''ChatResponse)

------------------------
------ Edits API
------------------------

data EditCreate = EditCreate
{ edcrModel :: ModelId,
edcrInput :: Maybe T.Text,
edcrInstruction :: T.Text,
edcrN :: Maybe Int,
edcrTemperature :: Maybe Double,
edcrTopP :: Maybe Double
}
deriving (Show, Eq)

defaultEditCreate :: ModelId -> T.Text -> T.Text -> EditCreate
defaultEditCreate model input instruction =
EditCreate
{ edcrModel = model,
edcrInput = Just input,
edcrInstruction = instruction,
edcrN = Nothing,
edcrTemperature = Nothing,
edcrTopP = Nothing
}

data EditChoice = EditChoice
{ edchText :: T.Text,
edchIndex :: Int
}
deriving (Show, Eq)

data EditResponse = EditResponse
{ edrObject :: T.Text,
edrCreated :: Int,
edrChoices :: [EditChoice],
edrUsage :: Usage
}
deriving (Show, Eq)

$(deriveJSON (jsonOpts 4) ''EditCreate)
$(deriveJSON (jsonOpts 4) ''EditChoice)
$(deriveJSON (jsonOpts 3) ''EditResponse)

------------------------
------ Images API
------------------------
Expand Down

0 comments on commit e02e5d8

Please sign in to comment.