Skip to content

Commit

Permalink
Switch to :text-davinci-002 model
Browse files Browse the repository at this point in the history
  • Loading branch information
motform committed Apr 27, 2022
1 parent dd1feda commit db6280e
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 24 deletions.
3 changes: 0 additions & 3 deletions resources/public/svg/archive.svg

This file was deleted.

4 changes: 0 additions & 4 deletions resources/public/svg/bookmarks.svg

This file was deleted.

3 changes: 0 additions & 3 deletions resources/public/svg/collection.svg

This file was deleted.

4 changes: 0 additions & 4 deletions resources/public/svg/plus-square.svg

This file was deleted.

2 changes: 0 additions & 2 deletions src/org/motform/multiverse/components/library.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
anchor (doto (js/document.createElement "a")
(-> .-href (set! edn-url))
(-> .-download (set! file-name)))]
(.appendChild (.-body js/document) anchor)
(.click anchor)
(.removeChild (.body js/document) anchor)
(js/URL.revokeObjectURL edn-url)))

(defn library-toggles []
Expand Down
8 changes: 4 additions & 4 deletions src/org/motform/multiverse/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
:open-ai/completions
(fn [{:keys [db]} [_ parent-id prompt]]
(let [{:keys [story-id api-key]} (util/completion-data db)
{:keys [uri params]} (open-ai/completion-with #_:ada :text-davinci-001
{:keys [uri params]} (open-ai/completion-with #_:ada :text-davinci-002
{:prompt prompt})]
{:db (assoc-in db [:db/state :open-ai/pending-request?] true)
:http-xhrio {:method :post
Expand All @@ -250,7 +250,7 @@
(fn [{:keys [db]} _]
(let [{:keys [story-id api-key]} (util/completion-data db)
story (vals (get-in db [:db/stories story-id :story/sentences]))
{:keys [uri params]} (open-ai/completion-with #_:ada :text-davinci-001
{:keys [uri params]} (open-ai/completion-with #_:ada :text-davinci-002
{:prompt (open-ai/format-title story)
:n 1
:max_tokens 15
Expand Down Expand Up @@ -290,7 +290,7 @@
n-unrealized-children (count unrealized-children)]
(when-not (or (zero? n-unrealized-children) (= new-personality (-> unrealized-children first :sentence/personality)))
(let [prompt (open-ai/format-prompt (util/paragraph db story-id parent-id))
{:keys [uri params]} (open-ai/completion-with #_:ada :text-davinci-001 {:prompt prompt :n n-unrealized-children})]
{:keys [uri params]} (open-ai/completion-with #_:ada :text-davinci-002 {:prompt prompt :n n-unrealized-children})]
{:db (-> db (assoc-in [:db/state :personality/active] new-personality)
(assoc-in [:db/state :open-ai/pending-request?] true))
:http-xhrio {:method :post
Expand All @@ -299,7 +299,7 @@
:params params
:format (ajax/json-request-format)
:response-format (ajax/json-response-format {:keywords? true})
:on-success [:open-ai/replace-children story-id parent-id (->> unrealized-children (map :sentence/id) set)]
:on-success [:open-ai/replace-children story-id parent-id (set (map :sentence/id unrealized-children))]
:on-failure [:open-ai/failure]}})))))

(reg-event-db
Expand Down
7 changes: 3 additions & 4 deletions src/org/motform/multiverse/open_ai.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:ada
:babbage
:curie :curie-instruct-beta
:davinci :text-davinci-001})
:davinci :text-davinci-001 :text-davinci-002})

(def valid-params
#{:logit_bias :frequency_penalty :presence_penalty
Expand All @@ -19,9 +19,8 @@

(def param-defaults
{:max_tokens 64
:temperature 0.8
:n 3
:top_p 1})
:temperature 0.9
:n 3})

(defn- request [engine task params]
{:uri (str "https://api.openai.com/v1/engines/" engine "/" task)
Expand Down

0 comments on commit db6280e

Please sign in to comment.