diff --git a/src/wkok/openai_clojure/openai.clj b/src/wkok/openai_clojure/openai.clj index 7507b34..441f1e2 100644 --- a/src/wkok/openai_clojure/openai.clj +++ b/src/wkok/openai_clojure/openai.clj @@ -51,12 +51,13 @@ (def multipart-form-data {:name ::multipart-form-data :enter (fn [{:keys [handler params] :as ctx}] - (if (multipart-form-data? handler) - (-> (assoc-in ctx [:request :multipart] - (map param->multipart-entry params)) - (update-in [:request :headers] dissoc "Content-Type") - (update :request dissoc :body)) - ctx))}) + (let [params' (dissoc params :wkok.openai-clojure.core/options)] + (if (multipart-form-data? handler) + (-> (assoc-in ctx [:request :multipart] + (map param->multipart-entry params')) + (update-in [:request :headers] dissoc "Content-Type") + (update :request dissoc :body)) + ctx)))}) (defn update-file-schema [m operation-id field-name] diff --git a/test/wkok/openai_clojure/openai_test.clj b/test/wkok/openai_clojure/openai_test.clj index 4a7102c..9af3614 100644 --- a/test/wkok/openai_clojure/openai_test.clj +++ b/test/wkok/openai_clojure/openai_test.clj @@ -18,7 +18,8 @@ :mask (io/file "path/to/mask.png") :prompt "A cute baby sea otter wearing a beret" :n 2 - :size "1024x1024"})] + :size "1024x1024" + :wkok.openai-clojure.core/options {:api-key "123"}})] (testing "contains Authorization header" (is (contains? (:headers request) "Authorization"))) @@ -30,7 +31,10 @@ (testing "multipart prompt set correctly" (let [prompt (find-multipart request "prompt")] (is (= "A cute baby sea otter wearing a beret" - (:content prompt)))))))) + (:content prompt))))) + + (testing "options not set in multipart fields" + (is (nil? (find-multipart request "options"))))))) (deftest add-headers-init (let [add-headers-fn (-> openai/add-headers :enter)]