Skip to content

Commit

Permalink
Merge pull request #46 from wkok/no-matching-content-type
Browse files Browse the repository at this point in the history
Fixed warning for no matching content type
  • Loading branch information
wkok committed Nov 24, 2023
2 parents c0457b4 + ca7b981 commit badf935
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/wkok/openai_clojure/interceptors.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns wkok.openai-clojure.interceptors)

(def set-request-options
{:name ::method
{:name ::set-request-options
:enter (fn [{{{request :request} :wkok.openai-clojure.core/options} :params
:as ctx}]
(update ctx :request merge request))})
48 changes: 35 additions & 13 deletions src/wkok/openai_clojure/openai.clj
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,41 @@
"Bootstrap the martian from a local copy of the openai swagger spec"
[]
(let [definition (yaml/yaml->edn (slurp (io/resource "openapi.yaml")))
base-url (openapi/base-url nil nil definition)
encoders (assoc (encoders/default-encoders)
"multipart/form-data" nil)
opts (update martian-http/default-opts
:interceptors (fn [interceptors]
(-> (remove #(#{:martian.hato/perform-request} (:name %))
interceptors)
(concat [add-headers
openai-interceptors/set-request-options
(override-api-endpoint base-url)
(interceptors/encode-body encoders)
multipart-form-data
sse/perform-sse-capable-request]))))]
base-url (openapi/base-url nil nil definition)
encoders (assoc (encoders/default-encoders)
"multipart/form-data" nil
"application/octet-stream" nil)
opts (update martian-http/default-opts
:interceptors (fn [interceptors]
(-> interceptors
(interceptors/inject
add-headers
:after
:martian.interceptors/header-params)
(interceptors/inject
multipart-form-data
:after
::add-headers)
(interceptors/inject
openai-interceptors/set-request-options
:before
:martian.hato/perform-request)
(interceptors/inject
(override-api-endpoint base-url)
:before
:martian.hato/perform-request)
(interceptors/inject
sse/perform-sse-capable-request
:replace
:martian.hato/perform-request)
(interceptors/inject
(interceptors/encode-body encoders)
:replace
:martian.interceptors/encode-body)
(interceptors/inject
(interceptors/coerce-response encoders)
:replace
:martian.interceptors/coerce-response))))]
(-> (martian/bootstrap-openapi base-url definition opts)
update-file-schemas)))

Expand Down

0 comments on commit badf935

Please sign in to comment.