From d81abfd4dd3f75ff0b787e8e04e7e311c95a6a7a Mon Sep 17 00:00:00 2001 From: Kimbsy Date: Fri, 20 Jun 2025 10:05:40 +0100 Subject: [PATCH 1/2] Update deps The only breaking change was martian moving from `martian.interceptors/encode-body` to `martian.interceptors/encode-request`. --- .github/workflows/main.yml | 8 ++++---- deps.edn | 12 ++++++------ pom.xml | 2 +- src/wkok/openai_clojure/azure.clj | 4 ++-- src/wkok/openai_clojure/openai.clj | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4bb424f..15262e2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,10 +18,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4.2.2 - name: Cache - uses: actions/cache@v2 + uses: actions/cache@v4.2.3 with: path: | .cpcache @@ -29,9 +29,9 @@ jobs: key: ${{ runner.os }}-deps-${{ hashFiles('**/deps.edn') }} - name: Setup Clojure - uses: DeLaGuardo/setup-clojure@3.0 + uses: DeLaGuardo/setup-clojure@13.4 with: - tools-deps: '1.11.1.1208' + tools-deps: '1.12.1.1550' - name: Test run: clojure -T:build test diff --git a/deps.edn b/deps.edn index 40aee01..df9d964 100644 --- a/deps.edn +++ b/deps.edn @@ -1,16 +1,16 @@ {:paths ["src" "resources"] - :deps {org.clojure/clojure {:mvn/version "1.11.1"} - com.github.oliyh/martian {:mvn/version "0.1.26"} - com.github.oliyh/martian-hato {:mvn/version "0.1.26"} - org.clojure/core.async {:mvn/version "1.6.681"}} + :deps {org.clojure/clojure {:mvn/version "1.12.1"} + com.github.oliyh/martian {:mvn/version "0.1.32"} + com.github.oliyh/martian-hato {:mvn/version "0.1.32"} + org.clojure/core.async {:mvn/version "1.8.741"}} :aliases {:build {:deps {io.github.seancorfield/build-clj - {:git/tag "v0.6.4" :git/sha "c21cfde"}} + {:git/tag "v0.9.2" :git/sha "9c9f078"}} :ns-default build} :test {:extra-paths ["test"] :extra-deps {org.clojure/test.check {:mvn/version "1.1.1"} io.github.cognitect-labs/test-runner - {:git/tag "v0.5.0" :git/sha "48c3c67"}} + {:git/tag "v0.5.1" :git/sha "dfb30dd"}} ;; Commented out PR 48 as it causes tests not to run ;; https://github.com/wkok/openai-clojure/pull/48/files diff --git a/pom.xml b/pom.xml index 21bc192..5163033 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ org.clojure clojure - 1.10.3 + 1.12.1 diff --git a/src/wkok/openai_clojure/azure.clj b/src/wkok/openai_clojure/azure.clj index 7a0d406..a89c597 100644 --- a/src/wkok/openai_clojure/azure.clj +++ b/src/wkok/openai_clojure/azure.clj @@ -115,9 +115,9 @@ :replace :martian.hato/perform-request) (interceptors/inject - (interceptors/encode-body encoders) + (interceptors/encode-request encoders) :replace - :martian.interceptors/encode-body) + :martian.interceptors/encode-request) (interceptors/inject (interceptors/coerce-response encoders) :replace diff --git a/src/wkok/openai_clojure/openai.clj b/src/wkok/openai_clojure/openai.clj index 33e2702..1f765ce 100644 --- a/src/wkok/openai_clojure/openai.clj +++ b/src/wkok/openai_clojure/openai.clj @@ -107,9 +107,9 @@ :replace :martian.hato/perform-request) (interceptors/inject - (interceptors/encode-body encoders) + (interceptors/encode-request encoders) :replace - :martian.interceptors/encode-body) + :martian.interceptors/encode-request) (interceptors/inject (interceptors/coerce-response encoders) :replace From 5786b6907ebcea23f210d9dd0d4903f13c305436 Mon Sep 17 00:00:00 2001 From: Kimbsy Date: Mon, 21 Jul 2025 14:44:53 +0100 Subject: [PATCH 2/2] Optionally return the full response The OpenAI response contains useful information in the headers (notably this is where the [rate limiting info](https://platform.openai.com/docs/guides/rate-limits#rate-limits-in-headers) is returned). This change allows the user to specify that they want the whole response returned instead of just the body, by setting the `:full-response?` option. This change should be backwards compatible and so shouldn't break existing code. --- src/wkok/openai_clojure/core.clj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/wkok/openai_clojure/core.clj b/src/wkok/openai_clojure/core.clj index d0097d9..9922d03 100644 --- a/src/wkok/openai_clojure/core.clj +++ b/src/wkok/openai_clojure/core.clj @@ -15,8 +15,9 @@ (defn response-for [operation params - {:keys [impl request] - :or {impl :openai} + {:keys [impl request full-response?] + :or {impl :openai + full-response? false} :as options}] (if-let [{:keys [p o]} (transform-deprecated-args? params options)] @@ -37,4 +38,6 @@ (if (:async? request) response - (:body response))))) + (if full-response? + response + (:body response))))))