diff --git a/ihp-openai/IHP/OpenAI.hs b/ihp-openai/IHP/OpenAI.hs index f5ba2daf1..5652a44db 100644 --- a/ihp-openai/IHP/OpenAI.hs +++ b/ihp-openai/IHP/OpenAI.hs @@ -19,7 +19,7 @@ import Control.Applicative ((<|>)) data CompletionRequest = CompletionRequest { messages :: ![Message] - , prompt :: !Text + , prompt :: !Text -- ^ Deprecated, use 'messages' instead , maxTokens :: !Int , temperature :: !Double , presencePenalty :: !Double @@ -39,7 +39,7 @@ instance ToJSON CompletionRequest where toJSON CompletionRequest { model, prompt, messages, maxTokens, temperature, presencePenalty, frequencePenalty, stream } = object [ "model" .= model - , "messages" .= (messages <> [userMessage prompt]) + , "messages" .= (messages <> (if not (Text.null prompt) then [userMessage prompt] else [])) , "max_tokens" .= maxTokens , "stream" .= stream , "temperature" .= temperature