Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some extra fields for the reasoning models #5

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion openai-api-servant/src/OpenAI/Resources.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module OpenAI.Resources
SystemFingerprint(..),
ResponseFormat(..),
ResponseFormatSchema(..),
ReasoningEffort(..),
defaultChatCompletionRequest,

-- * Chat streaming
Expand Down Expand Up @@ -467,9 +468,20 @@ newtype Seed = Seed { unSeed :: Int }
deriving newtype (ToJSON, FromJSON, ToHttpApiData)
deriving anyclass NFData

data ReasoningEffort =
RE_low
| RE_medium
| RE_high
deriving stock (Show, Eq, Generic)
deriving anyclass NFData

$(deriveJSON (jsonOpts 3) ''ReasoningEffort)

data ChatCompletionRequest = ChatCompletionRequest
{ chcrModel :: ModelId,
chcrMessages :: [ChatMessage],
chcrStore :: Maybe Bool,
chcrReasoningEffort :: Maybe ReasoningEffort,
-- | A list of functions the model may generate JSON inputs for.
-- /Deprecated/ by OpenAI in favour of \"tools\".
chcrFunctions :: Maybe [ChatFunction],
Expand All @@ -483,11 +495,14 @@ data ChatCompletionRequest = ChatCompletionRequest
chcrSeed :: Maybe Seed,
chcrStream :: Maybe Bool,
chcrStop :: Maybe (V.Vector T.Text),
-- | DEPRECATED: Please use chcrMaxCompletionTokens
chcrMaxTokens :: Maybe Int,
chcrMaxCompletionTokens :: Maybe Int,
chcrPresencePenalty :: Maybe Double,
chcrResponseFormat :: Maybe ResponseFormat,
chcrFrequencyPenalty :: Maybe Double,
chcrLogitBias :: Maybe (V.Vector Double),
chcrParallelToolCalls :: Maybe Bool,
chcrUser :: Maybe String
}
deriving (Show, Eq)
Expand Down Expand Up @@ -539,6 +554,8 @@ defaultChatCompletionRequest model messages =
ChatCompletionRequest
{ chcrModel = model,
chcrMessages = messages,
chcrStore = Nothing,
chcrReasoningEffort = Nothing,
chcrFunctions = Nothing,
chcrFunctionCall = Nothing,
chcrToolChoice = Nothing,
Expand All @@ -550,11 +567,13 @@ defaultChatCompletionRequest model messages =
chcrStream = Nothing,
chcrStop = Nothing,
chcrMaxTokens = Nothing,
chcrMaxCompletionTokens = Nothing,
chcrPresencePenalty = Nothing,
chcrResponseFormat = Nothing,
chcrFrequencyPenalty = Nothing,
chcrLogitBias = Nothing,
chcrUser = Nothing
chcrUser = Nothing,
chcrParallelToolCalls = Nothing
}

data ChatChoice = ChatChoice
Expand Down
1 change: 1 addition & 0 deletions openai-api/src/OpenAI/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module OpenAI.Client
SystemFingerprint(..),
ResponseFormat(..),
ResponseFormatSchema(..),
ReasoningEffort(..),
defaultChatCompletionRequest,
completeChat,
completeChatStreaming,
Expand Down