packages feed

baikai-openai 0.3.0.2 → 0.4.0.0

raw patch · 3 files changed

+41/−7 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Baikai.Provider.OpenAI.Cli: codexCliCommand :: CodexCliConfig -> Model -> Context -> (FilePath, [String])
+ Baikai.Provider.OpenAI.Cli: codexCliCommand :: CodexCliConfig -> Model -> Context -> Options -> (FilePath, [String])

Files

baikai-openai.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.4 name:          baikai-openai-version:       0.3.0.2+version:       0.4.0.0 synopsis:      OpenAI providers for the baikai abstraction description:   Wraps the openai Haskell package as a Baikai Provider for OpenAI's Chat Completions API.
src/Baikai/Provider/OpenAI/Cli.hs view
@@ -39,6 +39,7 @@ import Baikai.Response qualified as Resp import Baikai.StopReason (StopReason (..)) import Baikai.Stream (liftCompleteToStream)+import Baikai.ThinkingLevel (renderThinkingLevel) import Baikai.Usage (zeroUsage) import Control.Concurrent (forkIO) import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar)@@ -145,21 +146,30 @@ -- | Render the executable and arguments for a @codex exec --json@ -- batch call. The prompt is preceded by @--@ so dash-leading prompts -- cannot be parsed as options.-codexCliCommand :: CodexCliConfig -> Model -> Context -> (FilePath, [String])-codexCliCommand cfg m ctx =+codexCliCommand :: CodexCliConfig -> Model -> Context -> Options -> (FilePath, [String])+codexCliCommand cfg m ctx opts =   ( cfg ^. #executable,     ["exec"]       <> modelArgs m       <> ["--json"]       <> ["--skip-git-repo-check" | cfg ^. #skipGitRepoCheck]       <> ["--ephemeral" | cfg ^. #ephemeral]+      <> effortArgs opts       <> fmap Text.unpack (cfg ^. #extraArgs)       <> ["--", Text.unpack (codexCliPrompt ctx)]   ) +-- | Render Codex's reasoning-effort config override from+-- 'Options.thinking'. Codex accepts all six Baikai levels verbatim;+-- when 'thinking' is unset, no override is emitted.+effortArgs :: Options -> [String]+effortArgs opts = case opts ^. #thinking of+  Nothing -> []+  Just lvl -> ["-c", "model_reasoning_effort=" <> Text.unpack (renderThinkingLevel lvl)]+ runCodexCli :: CodexCliConfig -> Model -> Context -> Options -> IO Resp.Response-runCodexCli cfg m ctx _opts = do-  let (exe, args) = codexCliCommand cfg m ctx+runCodexCli cfg m ctx opts = do+  let (exe, args) = codexCliCommand cfg m ctx opts       procSpec =         (P.proc exe args)           { P.std_in = P.NoStream,
test/Main.hs view
@@ -46,6 +46,7 @@       [ commandRenderingTest,         effortRenderingTests,         batchCommandRenderingTest,+        batchEffortRenderingTest,         batchSystemPromptTest,         stderrFloodTest,         usageMappingTests,@@ -280,7 +281,7 @@             & #api .~ OpenAICompletionsCli             & #provider .~ "openai"         ctx = emptyContext & #messages .~ Vector.singleton (user "-begin with a dash")-    CodexCli.codexCliCommand CodexCli.defaultCodexCliConfig model ctx+    CodexCli.codexCliCommand CodexCli.defaultCodexCliConfig model ctx emptyOptions       @?= ( "codex",             [ "exec",               "--json",@@ -291,6 +292,29 @@             ]           ) +batchEffortRenderingTest :: TestTree+batchEffortRenderingTest =+  testCase "codex exec argv renders reasoning effort before the prompt terminator" $ do+    let model =+          emptyModel+            & #modelId .~ ""+            & #api .~ OpenAICompletionsCli+            & #provider .~ "openai"+        ctx = emptyContext & #messages .~ Vector.singleton (user "ping")+        opts = emptyOptions & #thinking .~ Just ThinkingXHigh+    CodexCli.codexCliCommand CodexCli.defaultCodexCliConfig model ctx opts+      @?= ( "codex",+            [ "exec",+              "--json",+              "--skip-git-repo-check",+              "--ephemeral",+              "-c",+              "model_reasoning_effort=xhigh",+              "--",+              "ping"+            ]+          )+ batchSystemPromptTest :: TestTree batchSystemPromptTest =   testCase "codex exec argv carries system prompt in the prompt text" $ do@@ -303,7 +327,7 @@           emptyContext             & #systemPrompt .~ Just "Be terse."             & #messages .~ Vector.singleton (user "ping")-    CodexCli.codexCliCommand CodexCli.defaultCodexCliConfig model ctx+    CodexCli.codexCliCommand CodexCli.defaultCodexCliConfig model ctx emptyOptions       @?= ( "codex",             [ "exec",               "--json",