Skip to content

Commit

Permalink
Merge pull request #61 from jianghoy/update-http-header
Browse files Browse the repository at this point in the history
Update assistants HTTP header
  • Loading branch information
wkok authored May 19, 2024
2 parents b6a0a28 + 03663d8 commit f109b0a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
60 changes: 32 additions & 28 deletions src/wkok/openai_clojure/api.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
(ns wkok.openai-clojure.api
(:require [wkok.openai-clojure.core :as core]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:private ASSISTANTS_HTTP_HEADER_STR "assistants=v2")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Models
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -426,7 +430,7 @@
([params]
(list-assistants params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :list-assistants params opts))))


Expand All @@ -448,7 +452,7 @@
([params]
(create-assistant params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v2")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :create-assistant params opts))))


Expand All @@ -467,7 +471,7 @@
([params]
(retrieve-assistant params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :get-assistant params opts))))


Expand All @@ -487,7 +491,7 @@
([params]
(modify-assistant params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :modify-assistant params opts))))


Expand All @@ -504,7 +508,7 @@
([params]
(delete-assistant params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :delete-assistant params opts))))


Expand All @@ -523,7 +527,7 @@
([params]
(list-assistant-files params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :list-assistant-files params opts))))


Expand All @@ -542,7 +546,7 @@
([params]
(create-assistant-file params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :create-assistant-file params opts))))


Expand All @@ -561,7 +565,7 @@
([params]
(retrieve-assistant-file params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :get-assistant-file params opts))))


Expand All @@ -579,7 +583,7 @@
([params]
(delete-assistant-file params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :delete-assistant-file params opts))))


Expand Down Expand Up @@ -611,7 +615,7 @@
([params]
(create-thread params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :create-thread params opts))))


Expand All @@ -629,7 +633,7 @@
([params]
(retrieve-thread params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :get-thread params opts))))


Expand All @@ -648,7 +652,7 @@
([params]
(modify-thread params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :modify-thread params opts))))


Expand All @@ -665,7 +669,7 @@
([params]
(delete-thread params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :delete-thread params opts))))


Expand All @@ -691,7 +695,7 @@
([params]
(create-message params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :create-message params opts))))


Expand All @@ -709,7 +713,7 @@
([params]
(list-messages params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :list-messages params opts))))


Expand All @@ -727,7 +731,7 @@
([params]
(retrieve-message params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :get-message params opts))))


Expand All @@ -745,7 +749,7 @@
([params]
(modify-message params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :modify-message params opts))))


Expand All @@ -764,7 +768,7 @@
([params]
(list-message-files params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :list-message-files params opts))))


Expand All @@ -784,7 +788,7 @@
([params]
(retrieve-message-file params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :get-message-file params opts))))


Expand All @@ -809,7 +813,7 @@
([params]
(list-runs params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :list-runs params opts))))


Expand All @@ -828,7 +832,7 @@
([params]
(create-run params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :create-run params opts))))


Expand All @@ -847,7 +851,7 @@
([params]
(retrieve-run params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :get-run params opts))))


Expand All @@ -866,7 +870,7 @@
([params]
(modify-run params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :modify-run params opts))))


Expand All @@ -890,7 +894,7 @@
([params]
(submit-tool-outputs-to-run params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :submit-tool-ouputs-to-run params opts))))

(defn list-run-steps
Expand All @@ -908,7 +912,7 @@
([params]
(list-run-steps params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :list-run-steps params opts))))


Expand All @@ -929,7 +933,7 @@
([params]
(cancel-run params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :cancel-run params opts))))


Expand All @@ -951,7 +955,7 @@
([params]
(retrieve-run-step params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :get-run-step params opts))))


Expand All @@ -971,5 +975,5 @@
([params]
(create-thread-and-run params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] "assistants=v1")]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :create-thread-and-run params opts))))
4 changes: 2 additions & 2 deletions test/wkok/openai_clojure/openai_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@

(is (= {"Authorization" "Bearer my-secret-key",
"OpenAI-Organization" "my-company"
"OpenAI-Beta" "assistants=v1"}
"OpenAI-Beta" "assistants=v2"}
(-> (add-headers-fn {:params {:wkok.openai-clojure.core/options {:api-key "my-secret-key"
:organization "my-company"
:openai-beta "assistants=v1"}}})
:openai-beta "assistants=v2"}}})
:request
:headers))))))

Expand Down

0 comments on commit f109b0a

Please sign in to comment.