Skip to content

Commit

Permalink
Added support for OpenAI Vector Stores(#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdenno authored Nov 5, 2024
1 parent ebbc57b commit ca621cf
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 1 deletion.
81 changes: 81 additions & 0 deletions src/wkok/openai_clojure/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -865,3 +865,84 @@
([params options]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :create-thread-and-run params opts))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Vector stores (beta)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn create-vector-store
"Create a vector store.
Example:
```
(create-vector-store {:name \"Support FAQ\" :file-ids [\"file-id-123\"]})
```
Also see the [OpenAI documentation](https://platform.openai.com/docs/api-reference/vector-stores/create)
"
([params]
(create-vector-store params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :create-vector-store params opts))))

(defn list-vector-stores
"Returns a list of vector stores.
Example:
```
(list-vector-stores {:limit 1})
```
Also see the [OpenAI documentation](https://platform.openai.com/docs/api-reference/vector-stores/list)
"
([params]
(list-vector-stores params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :list-vector-stores params opts))))

(defn retrieve-vector-store
"Retrieves a vector store.
Example:
```
(retrieve-vector-store {:vector_store_id \"vs_abc123\"})
```
Also see the [OpenAI documentation](https://platform.openai.com/docs/api-reference/vector-stores/retrieve)
"
([params]
(retrieve-vector-store params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :get-vector-store params opts))))

(defn modify-vector-store
"Modifies a vector store.
Example:
```
(modify-vector-store {:vector_store_id \"vs_abc123\" :name \"Support FAQ\"})
```
Also see the [OpenAI documentation](https://platform.openai.com/docs/api-reference/vector-stores/modify)
"
([params]
(modify-vector-store params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :modify-vector-store params opts))))

(defn delete-vector-store
"Deletes a vector store.
Example:
```
(delete-vector-store {:vector_store_id \"vs_abc123\"})
```
Also see the [OpenAI documentation](https://platform.openai.com/docs/api-reference/vector-stores/delete)
"
([params]
(delete-vector-store params nil))
([params options]
(let [opts (assoc-in options [:openai-beta] ASSISTANTS_HTTP_HEADER_STR)]
(core/response-for :delete-vector-store params opts))))
20 changes: 19 additions & 1 deletion test/wkok/openai_clojure/api_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,25 @@
:step_id "----id----"})))

(is (= :success
(api/create-thread-and-run {:assistant_id "----id----"}))))))
(api/create-thread-and-run {:assistant_id "----id----"})))

(is (= :success
(api/create-vector-store {:name "Support FAQ" :file-ids ["----id----"]})))

(is (= :success
(api/list-vector-stores {:limit 1})))

(is (= :success
(api/retrieve-vector-store {:vector_store_id "----id----"})))

(is (= :success
(api/retrieve-vector-store {:vector_store_id "----id----"})))

(is (= :success
(api/modify-vector-store {:vector_store_id "----id----" :name "Support FAQ v2"})))

(is (= :success
(api/delete-vector-store {:vector_store_id "----id----"}))))))

(deftest create-chat-completion-tools

Expand Down

0 comments on commit ca621cf

Please sign in to comment.