Skip to content

Commit

Permalink
feat: Add header to markdown export
Browse files Browse the repository at this point in the history
  • Loading branch information
motform committed Oct 6, 2024
1 parent 13d5dad commit a77fe08
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
5 changes: 4 additions & 1 deletion src/org/motform/multiverse/components/library.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

(defn export-markdown []
(util/download-file
(->> @(rf/subscribe [:db/stories]) (map story/->md) (str/join "\n\n"))
(->> @(rf/subscribe [:db/stories])
(map story/->md)
(str/join "\n\n")
(str "# Multiverse Export (" (util/format-date (js/Date.)) ")\n\n"))
(str "multiverse-library-export-" (nano-id) ".md")
"text/markdown"))

Expand Down
14 changes: 1 addition & 13 deletions src/org/motform/multiverse/open_ai.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
(ns org.motform.multiverse.open-ai
(:require
[org.motform.multiverse.prompts :as prompts]))
(ns org.motform.multiverse.open-ai)

(defn auth [api-key]
{"Authorization" (str "Bearer " api-key)})
Expand Down Expand Up @@ -35,13 +33,3 @@
[(->message ::system system-message)
(map #(->message ::assistant (:sentence/text %)) paragraphs)
(->message ::user user-message)])})

;; Title

(defn request-title [model paragraphs]
{:pre [(valid-model? model)]}
(let [sentences (map :sentence/text paragraphs)]
{:n 1
:model model
:messages [(->message ::system prompts/title)
(->message ::user (apply str "Here is the short story:\n" sentences))]}))
20 changes: 13 additions & 7 deletions src/org/motform/multiverse/prompts.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,22 @@ BE CONCISE. Be creative. Be weird. Be yourself. Write like your life depends on
Your response should ONLY BE THE THE NEXT SENTENCE OF THE STORY.
It is very important that you only respond WITH A SINGLE SENTENCE, or else the game will break.
NEVER include your prompt, or any other texts other than THE NEXT SENTENCE ONLY."

:user
"Now it is your time to write the next sentence.
It is VERY important that respond in the style you were ask to emulate.
As a reminder, your style is: The story is written in a contemporary, neutral style.
The next sentence is:"}})

(def title
"You are an award winning AUTHOR writing an experimental, hypertext story.
Your work is boundary pushing and your titles are witty, smart and experimental. You will be provided with a short story.
Your task is to SUGGEST A TITLE FOR IT. The title should give the reader a good idea of the story, in a clever, funny way.
Respond ONLY with the title and no other content.
NEVER repeat anything from your prompt.
DO NOT ENCLOSE THE TITLE IN QUOTATION MARKS.")

(comment
{:prompt/v2
{:system "You are an award winning author writing fiction.
We are currently writing your next story together.
You will get the story as it is written up to this point
Your response should ONLY BE THE THE NEXT SENTENCE OF THE STORY.
It is very important that you only respond WITH A SINGLE SENTENCE, or else the game will break.
NEVER include your prompt, or any other texts other than THE NEXT SENTENCE."
:user "Now it is your time to write the next sentence of this story.
The next sentence is:"}}
#_c)
10 changes: 5 additions & 5 deletions src/org/motform/multiverse/story.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
(defn ->md [story]
(let [meta (:story/meta story)]
(str
"# " (:story/title meta) "\n"
"## " (:story/title meta) "\n"
"---\n"
"id:" (:story/id meta) "\n"
"model:" (name (:story/model meta)) "\n"
"prompt-version:" (:story/prompt-version meta) "\n"
"date:" (util/format-date (:story/updated meta)) "\n"
"id: " (:story/id meta) "\n"
"model: " (name (:story/model meta)) "\n"
"prompt-version: " (name (:story/prompt-version meta)) "\n"
"date: " (util/format-date (:story/updated meta)) "\n"
"---\n"
(longest-sentence story))))

Expand Down

0 comments on commit a77fe08

Please sign in to comment.