chansung commited on
Commit
3332aa4
1 Parent(s): e151138
app.py CHANGED
@@ -12,14 +12,17 @@ from constants import desc
12
  from interfaces import (
13
  ui, chat_ui, story_gen_ui, view_change_ui, export_ui
14
  )
15
- from modules.palmchat import GradioPaLMChatPPManager
16
 
17
  with gr.Blocks(css=STYLE) as demo:
 
 
 
18
  chat_mode = gr.State("setting_chat")
19
  chat_state = gr.State({
20
- "setting_chat": GradioPaLMChatPPManager(),
21
- "story_chat": GradioPaLMChatPPManager(),
22
- "export_chat": GradioPaLMChatPPManager(),
23
  })
24
 
25
  cur_cursor = gr.State(0)
@@ -269,7 +272,7 @@ with gr.Blocks(css=STYLE) as demo:
269
 
270
  with gr.Row():
271
  restart_from_export_view_btn = gr.Button("start over", elem_classes=["wrap", "control-button"])
272
- export_to_file_btn = gr.Button("Download as ZIP file (TBA)", interactive=False, elem_classes=["wrap", "control-button"], scale=2)
273
 
274
  with gr.Accordion("💬", open=False, elem_id="chat-section", visible=False) as chat_section:
275
  with gr.Column(scale=1):
@@ -934,12 +937,13 @@ with gr.Blocks(css=STYLE) as demo:
934
  # inputs=[
935
  # chat_input_txt, chat_mode, chat_state,
936
  # genre_dd, place_dd, mood_dd,
937
- # name_txt1, age_dd1, mbti_dd1, personality_dd1, job_dd1,
938
- # name_txt2, age_dd2, mbti_dd2, personality_dd2, job_dd2,
939
- # name_txt3, age_dd3, mbti_dd3, personality_dd3, job_dd3,
940
- # name_txt4, age_dd4, mbti_dd4, personality_dd4, job_dd4,
941
  # chapter1_title, chapter2_title, chapter3_title, chapter4_title,
942
- # chapter1_plot, chapter2_plot, chapter3_plot, chapter4_plot
 
943
  # ],
944
  # outputs=[chat_input_txt, chat_state, chatbot, regen_btn]
945
  # )
@@ -983,4 +987,4 @@ with gr.Blocks(css=STYLE) as demo:
983
  outputs=[selected_side_char_image3]
984
  )
985
 
986
- demo.queue().launch()
 
12
  from interfaces import (
13
  ui, chat_ui, story_gen_ui, view_change_ui, export_ui
14
  )
15
+ from modules.llms import get_llm_factory
16
 
17
  with gr.Blocks(css=STYLE) as demo:
18
+ factory = get_llm_factory("PaLM") #TODO: Replace with selected LLM factory
19
+ ui_pp_manager = factory.create_ui_pp_manager()
20
+
21
  chat_mode = gr.State("setting_chat")
22
  chat_state = gr.State({
23
+ "setting_chat": ui_pp_manager,
24
+ "story_chat": ui_pp_manager,
25
+ "export_chat": ui_pp_manager,
26
  })
27
 
28
  cur_cursor = gr.State(0)
 
272
 
273
  with gr.Row():
274
  restart_from_export_view_btn = gr.Button("start over", elem_classes=["wrap", "control-button"])
275
+ export_to_file_btn = gr.Button("(TBD) Download as ZIP file", elem_classes=["wrap", "control-button"], interactive=False, scale=2)
276
 
277
  with gr.Accordion("💬", open=False, elem_id="chat-section", visible=False) as chat_section:
278
  with gr.Column(scale=1):
 
937
  # inputs=[
938
  # chat_input_txt, chat_mode, chat_state,
939
  # genre_dd, place_dd, mood_dd,
940
+ # name_txt1, age_dd1, personality_dd1, job_dd1,
941
+ # name_txt2, age_dd2, personality_dd2, job_dd2,
942
+ # name_txt3, age_dd3, personality_dd3, job_dd3,
943
+ # name_txt4, age_dd4, personality_dd4, job_dd4,
944
  # chapter1_title, chapter2_title, chapter3_title, chapter4_title,
945
+ # chapter1_plot, chapter2_plot, chapter3_plot, chapter4_plot,
946
+ # side_char_enable_ckb1, side_char_enable_ckb2, side_char_enable_ckb3,
947
  # ],
948
  # outputs=[chat_input_txt, chat_state, chatbot, regen_btn]
949
  # )
 
987
  outputs=[selected_side_char_image3]
988
  )
989
 
990
+ demo.queue().launch(share=True)
assets/gpt_prompts.toml ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [story_gen]
2
+ add_side_character = """side character #{cur_side_chars}
3
+ - name: {name},
4
+ - job: {job},
5
+ - age: {age},
6
+ - personality: {personality}
7
+
8
+ """
9
+ first_story_gen = """Write the first three paragraphs of a novel as much detailed as possible. They should be based on the background information. Blend 5W1H principle into the stories as a plain text. Don't let the paragraphs end the whole story.
10
+
11
+ background information:
12
+ - genre: {genre}
13
+ - where: {place}
14
+ - mood: {mood}
15
+
16
+ main character
17
+ - name: {main_char_name}
18
+ - job: {main_char_job}
19
+ - age: {main_char_age}
20
+ - personality: {main_char_personality}
21
+ {side_char_placeholder}
22
+ Fill in the following JSON output format:
23
+ {{"paragraphs":"string"}}
24
+
25
+ Write the JSON output:
26
+ """
27
+ next_story_gen = """Write the next paragraphs. The next paragraphs should be determined by an option and well connected to the current stories.
28
+
29
+ background information:
30
+ - genre: {genre}
31
+ - where: {place}
32
+ - mood: {mood}
33
+
34
+ main character
35
+ - name: {main_char_name}
36
+ - job: {main_char_job}
37
+ - age: {main_char_age}
38
+ - personality: {main_char_personality}
39
+ {side_char_placeholder}
40
+ Fill in the following JSON output format:
41
+ {{"paragraphs":"string"}}
42
+
43
+ stories
44
+ {stories}
45
+
46
+ option to the next stories: {action}
47
+
48
+ Write the JSON output:
49
+ """
50
+ actions_gen = """Suggest the 20 options to drive the stories to the next based on the information below.
51
+
52
+ background information:
53
+ - genre: {genre}
54
+ - where: {place}
55
+ - mood: {mood}
56
+
57
+ main character
58
+ - name: {main_char_name}
59
+ - job: {main_char_job}
60
+ - age: {main_char_age}
61
+ - personality: {main_char_personality}
62
+ {side_char_placeholder}
63
+ Fill in the following JSON output format:
64
+ {{"options":["string1", "string2", "string3"]}}
65
+
66
+ summary of the story
67
+ {summary}
68
+
69
+ Write the JSON output:
70
+ """
71
+ summarize = """Summarize the text below
72
+
73
+ {stories}
74
+
75
+ """
76
+
77
+ [chat_gen]
78
+ chapter_title_ctx = """
79
+ chapter{title_idx} {{
80
+ title: {chapter_title},
81
+ plot: {chapter_plot}
82
+ }}
83
+ """
84
+ add_side_character = """side character{cur_side_chars}: {{
85
+ name: {name},
86
+ job: {job},
87
+ age: {age},
88
+ personality: {personality}
89
+ }}
90
+
91
+ """
92
+ chat_context = """You are a professional writing advisor, especially specialized in developing ideas on plotting stories and creating characters. I provide genre, where, and mood along with the rough description of one main character and three side characters.
93
+
94
+ Give creative but not too long responses based on the following information.
95
+
96
+ genre: {genre}
97
+ where: {place}
98
+ mood: {mood}
99
+
100
+ main character: {{
101
+ name: {name1},
102
+ job: {job1},
103
+ age: {age1},
104
+ personality: {personality1}
105
+ }}
106
+ {side_char_placeholder}
107
+ {chapter_title_placeholder}
108
+ """
109
+
110
+ [plot_gen]
111
+ main_plot_gen="""Write a title and an outline of a novel based on the background information below in Ronald Tobias's plot theory. The outline should follow the "rising action", "crisis", "climax", "falling action", and "denouement" plot types. Each should be filled with a VERY detailed and descriptive at least two paragraphs of string. Randomly choose if the story goes optimistic or tragic.
112
+
113
+ background information:
114
+ - genre: string
115
+ - where: string
116
+ - mood: string
117
+
118
+ main character
119
+ - name: string
120
+ - job: string
121
+ - age: string
122
+ - personality: string
123
+
124
+ JSON output:
125
+ {{
126
+ "title": "string",
127
+ "outline": {{
128
+ "rising action": "paragraphs of string",
129
+ "crisis": "paragraphs of string",
130
+ "climax": "paragraphs of string",
131
+ "falling action": "paragraphs of string",
132
+ "denouement": "paragraphs of string"
133
+ }}
134
+ }}
135
+
136
+ background information:
137
+ - genre: {genre}
138
+ - where: {place}
139
+ - mood: {mood}
140
+
141
+ main character
142
+ - name: {main_char_name}
143
+ - job: {main_char_job}
144
+ - age: {main_char_age}
145
+ - personality: {main_char_personality}
146
+ {side_char_placeholder}
147
+ JSON output:
148
+ """
149
+ first_story_gen="""Write the chapter title and the first few paragraphs of the "rising action" plot based on the background information below in Ronald Tobias's plot theory. Also, suggest three choosable actions to drive current story in different directions. The first few paragraphs should be filled with a VERY MUCH detailed and descriptive at least two paragraphs of string.
150
+
151
+ REMEMBER the first few paragraphs should not end the whole story and allow leaway for the next paragraphs to come.
152
+ The whole story SHOULD stick to the "rising action -> crisis -> climax -> falling action -> denouement" flow, so REMEMBER not to write anything mentioned from the next plots of crisis, climax, falling action, and denouement yet.
153
+
154
+ background information:
155
+ - genre: string
156
+ - where: string
157
+ - mood: string
158
+
159
+ main character
160
+ - name: string
161
+ - job: string
162
+ - age: string
163
+ - personality: string
164
+
165
+ overall outline
166
+ - title: string
167
+ - rising action: string
168
+ - crisis: string
169
+ - climax: string
170
+ - falling action: string
171
+ - denouement: string
172
+
173
+ JSON output:
174
+ {{
175
+ "chapter_title": "string",
176
+ "paragraphs": ["string", "string", ...],
177
+ "actions": ["string", "string", "string"]
178
+ }}
179
+
180
+ background information:
181
+ - genre: {genre}
182
+ - where: {place}
183
+ - mood: {mood}
184
+
185
+ main character
186
+ - name: {main_char_name}
187
+ - job: {main_char_job}
188
+ - age: {main_char_age}
189
+ - personality: {main_char_personality}
190
+ {side_char_placeholder}
191
+ overall outline
192
+ - title: {title}
193
+ - rising action: {rising_action}
194
+ - crisis: {crisis}
195
+ - climax: {climax}
196
+ - falling action: {falling_action}
197
+ - denouement: {denouement}
198
+
199
+ JSON output:
200
+ """
201
+
202
+ [image_gen]
203
+ neg_prompt="nsfw, worst quality, low quality, lowres, bad anatomy, bad hands, text, watermark, signature, error, missing fingers, extra digit, fewer digits, cropped, worst quality, normal quality, blurry, username, extra limbs, twins, boring, jpeg artifacts"
204
+
205
+ [image_gen.character]
206
+ gen_prompt = """Based on my brief descriptions of the character, suggest a "primary descriptive sentence" and "concise descriptors" to visualize them. Ensure you consider elements like the character's gender, age, appearance, occupation, clothing, posture, facial expression, mood, among others.
207
+ Once complete, please output only a single "primary descriptive sentence" and the "concise descriptors" in a syntactically valid JSON format.
208
+ The output template is as follows: {{"primary_sentence":"primary descriptive sentence","descriptors":["concise descriptor 1","concise descriptor 2","concise descriptor 3"]}}.
209
+ To enhance the quality of your character's description or expression, you might consider drawing from the following categories:
210
+ - Emotions and Expressions: "ecstatic", "melancholic", "furious", "startled", "bewildered", "pensive", "overjoyed", "crushed", "elated", "panicked", "satisfied", "cynical", "apathetic", "delighted", "terrified", "desperate", "triumphant", "mortified", "envious", "appreciative", "blissful", "heartbroken", "livid", "astounded", "baffled", "smiling", "frowning", "grinning", "crying", "pouting", "glaring", "blinking", "winking", "smirking", "whistling".
211
+ - Physical Features: "upper body", "very long hair", "looking at viewer", "looking to the side", "looking at another", "thick lips", "skin spots", "acnes", "skin blemishes", "age spot", "perfect eyes", "detailed eyes", "realistic eyes", "dynamic standing", "beautiful face", "necklace", "high detailed skin", "hair ornament", "blush", "shiny skin", "long sleeves", "cleavage", "rubber suit", "slim", "plump", "muscular", "pale skin", "tan skin", "dark skin", "blonde hair", "brunette hair", "black hair", "blue eyes", "green eyes", "brown eyes", "curly hair", "short hair", "wavy hair".
212
+ - Visual Enhancements: "masterpiece", "cinematic lighting", "detailed lighting", "tyndall effect", "soft lighting", "volumetric lighting", "close up", "wide shot", "glossy", "beautiful lighting", "warm lighting", "extreme", "ultimate", "best", "supreme", "ultra", "intense", "powerful", "exceptional", "remarkable", "strong", "vigorous", "dynamic angle", "front view person", "bangs", "waist up", "bokeh".
213
+ - Age and Gender: "1boy", "1man", "1male", "1girl", "1woman", "1female", "teen", "teenage", "twenties", "thirties", "forties", "fifties", "middle-age".
214
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
215
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
216
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
217
+ Do not output anything other than JSON values.
218
+ Do not provide any additional explanation of the following.
219
+ Only JSON is allowed.
220
+ ===
221
+ This is some examples.
222
+ Q:
223
+ The character's name is Liam, their job is as the Secret Agent, and they are in their 50s. And the keywords that help in associating with the character are "Thriller, Underground Warehouse, Darkness, ESTP, Ambitious, Generous".
224
+ Print out no more than 45 words in syntactically valid JSON format.
225
+ A:
226
+ {{"primary_sentence":"Middle-aged man pointing a gun in an underground warehouse","descriptors":["1man","solo","masterpiece","best quality","upper body","black suit","pistol in hand","dramatic lighting","muscular physique","intense brown eyes","raven-black hair","stylish cut","determined gaze","looking at viewer","stealthy demeanor","cunning strategist","advanced techwear","sleek","night operative","shadowy figure","night atmosphere","mysterious aura","highly detailed","film grain","detailed eyes and face"]}}
227
+
228
+ Q:
229
+ The character's name is Catherine, their job is as the Traveler, and they are in their 10s. And the keywords that help in associating with the character are "Romance, Starlit Bridge, Dreamy, ENTJ, Ambitious".
230
+ Print out no more than 45 words in syntactically valid JSON format.
231
+ A:
232
+ {{"primary_sentence":"A dreamy teenage girl standing on a starlit bridge with romantic ambitions","descriptors":["1girl","solo","masterpiece","best quality","upper body","flowing skirt","sun hat","bright-eyed","map in hand","ethereal beauty","wanderlust","scarf","whimsical","graceful poise","celestial allure","close-up","warm soft lighting","luminescent glow","gentle aura","mystic charm","smirk","dreamy landscape","poetic demeanor","cinematic lighting","extremely detailed","film grain","detailed eyes and face"]}}
233
+
234
+ Q:
235
+ The character's name is Claire, their job is as the Technological Advancement, and they are in their 20s. And the keywords that help in associating with the character are "Science Fiction, Space Station, INFP, Ambitious, Generous".
236
+ Print out no more than 45 words in syntactically valid JSON format.
237
+ A:
238
+ {{"primary_sentence":"A young ambitious woman tech expert aboard a futuristic space station","descriptors":["1girl","solo","masterpiece","best quality","upper body","sleek silver jumpsuit","futuristic heels","contemplative","editorial portrait","dynamic angle","sci-fi","techno-savvy","sharp focus","bokeh","beautiful lighting","intricate circuitry","robotic grace","rich colors","vivid contrasts","dramatic lighting","futuristic flair","avant-garde","high-tech allure","innovative mind","mechanical sophistication","film grain","detailed eyes and face"]}}
239
+
240
+ Q:
241
+ The character's name is Sophie, their job is as a Ballet Dancer, and they are in their 10s. And the keywords that help in associating with the character are "Grace, Dance Studio, Elegance, ISFJ, Gentle, Passionate"
242
+ Print out no more than 45 words in syntactically valid JSON format.
243
+ A:
244
+ {{"primary_sentence":"An elegant dancer poses gracefully in a mirrored studio","descriptors":["1girl","teen","solo","masterpiece","best quality","upper body","beautiful face","shiny skin","wavy hair","ballet attire","tiptoe stance","flowing skirt","focused gaze","soft ambiance","soft lighting","film grain","detailed eyes and face"]}}
245
+ ===
246
+ This is my request.
247
+ Q:
248
+ {input}
249
+ A:
250
+ """
251
+ query = """
252
+ The character's name is {character_name}, their job is as the {job}, and they are in their {age}. And the keywords that help in associating with the character are "{keywords}".
253
+ Print out no more than 45 words in syntactically valid JSON format.
254
+ """
255
+
256
+ [image_gen.background]
257
+ gen_prompt = """Based on my brief descriptions of the scene, suggest a "primary descriptive sentence" and "concise descriptors" to visualize it. Ensure you consider elements like the setting's time of day, atmosphere, prominent objects, mood, location, natural phenomena, architecture, among others.
258
+ Once complete, please output only a single "primary descriptive sentence" and the "concise descriptors" in a syntactically valid JSON format.
259
+ The output template is as follows: {{"primary_sentence":"primary descriptive sentence","descriptors":["concise descriptor 1","concise descriptor 2","concise descriptor 3"]}}.
260
+ To enhance the quality of your scene's description or expression, you might consider drawing from the following categories:
261
+ - Atmosphere and Time: "dawn", "dusk", "midday", "midnight", "sunset", "sunrise", "foggy", "misty", "stormy", "calm", "clear night", "starlit", "moonlit", "golden hour".
262
+ - Natural Phenomena: "rainbow", "thunderstorm", "snowfall", "aurora borealis", "shooting star", "rain shower", "windy", "sunny".
263
+ - Location and Architecture: "urban", "rural", "mountainous", "oceanfront", "forest", "desert", "island", "modern city", "ancient ruins", "castle", "village", "meadow", "cave", "bridge".
264
+ - Prominent Objects: "giant tree", "waterfall", "stream", "rock formation", "ancient artifact", "bonfire", "tent", "vehicle", "statue", "fountain".
265
+ - Visual Enhancements: "masterpiece", "cinematic lighting", "detailed lighting", "soft lighting", "volumetric lighting", "tyndall effect", "warm lighting", "close up", "wide shot", "beautiful perspective", "bokeh".
266
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
267
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
268
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
269
+ Do not output anything other than JSON values.
270
+ Do not provide any additional explanation of the following.
271
+ Only JSON is allowed.
272
+ ===
273
+ This is some examples.
274
+ Q:
275
+ The genre is "Fantasy", the place is "Enchanted Forest", the mood is "Mystical", the title of the novel is "Whispering Leaves", and the chapter plot revolves around "A hidden glade where elves sing under the moonlight".
276
+ Print out no more than 45 words in syntactically valid JSON format.
277
+ A:
278
+ {{"primary_sentence":"a mystical glade in an enchanted forest where elves sing beneath the moonlight","descriptors":["no humans","masterpiece","fantasy","enchanted forest","moonlit glade","mystical atmosphere","singing elves","luminous fireflies","ancient trees","shimmering leaves","whispering winds","hidden secrets","elven magic","masterpiece","soft lighting","silver glow","detailed shadows","enchanted mood","highly detailed","film grain"]}}
279
+
280
+ Q:
281
+ The genre is "Science Fiction", the place is "Galactic Space Station", the mood is "Tense", the title of the novel is "Stars Unbound", and the chapter plot revolves around "Ambassadors from different galaxies discussing a new treaty".
282
+ Print out no more than 45 words in syntactically valid JSON format.
283
+ A:
284
+ {{"primary_sentence":"a tense gathering in a galactic space station where interstellar ambassadors negotiate","descriptors":["no humans","masterpiece","science fiction","galactic space station","star-studded backdrop","advanced technology","diverse aliens","hovering spacecrafts","futuristic architecture","tense discussions","interstellar politics","neon lights","holographic displays","masterpiece","detailed lighting","cinematic mood","highly detailed","film grain"]}}
285
+
286
+ Q:
287
+ The genre is "Romance", the place is "Beach", the mood is "Heartfelt", the title of the novel is "Waves of Passion", and the chapter plot revolves around "Two lovers reconciling their differences by the shore".
288
+ Print out no more than 45 words in syntactically valid JSON format.
289
+ A:
290
+ {{"primary_sentence":"a heartfelt scene on a beach during sunset where two lovers reconcile","descriptors":["no humans","masterpiece","romance","beach","sunset horizon","golden sands","lapping waves","embrace","teary-eyed confessions","seashells","reflective waters","warm hues","silhouette of lovers","soft breeze","beautiful perspective","detailed shadows","emotional atmosphere","highly detailed","film grain"]}}
291
+
292
+ Q:
293
+ The genre is "Middle Ages", the place is "Royal Palace", the mood is "Epic Adventure", the title of the novel is "Throne of Fates", and the chapter plot revolves around "A brave knight receiving a quest from the king".
294
+ Print out no more than 45 words in syntactically valid JSON format.
295
+ A:
296
+ {{"primary_sentence":"an epic scene in a royal palace where a knight is tasked with a quest by the king","descriptors":["no humans","masterpiece","middle ages","royal palace","castle","grand throne room","golden hour","armored knight","majestic king","tapestries","stone walls","torches","glistening armor","banner flags","medieval atmosphere","heroic demeanor","detailed architecture","golden crowns","highly detailed","film grain"]}}
297
+ ===
298
+ This is my request.
299
+ Q:
300
+ {input}
301
+ A:
302
+ """
303
+ query = """
304
+ The genre is "{genre}", the place is "{place}", the mood is "{mood}", the title of the novel is "{title}", and the chapter plot revolves around "{chapter_plot}".
305
+ Print out no more than 45 words in syntactically valid JSON format.
306
+ """
307
+
308
+ [music_gen]
309
+ gen_prompt = """Based on my brief descriptions of the novel's mood, theme, or setting, suggest a "primary descriptive sentence" to conceptualize the musical piece. Ensure you consider elements like the music's genre, BPM, primary instruments, emotions evoked, era (if applicable), and other relevant musical characteristics.
310
+ Once complete, please output only a single "primary descriptive sentence" in a syntactically valid JSON format.
311
+ The output template is as follows:
312
+ {{"primary_sentence":"primary descriptive sentence"}}.
313
+ To enhance the quality of your music's description or expression, you might consider drawing from the following categories:
314
+ - Musical Genre and Era: "80s", "90s", "classical", "jazz", "EDM", "rock", "folk", "baroque", "bebop", "grunge", "funk", "hip-hop", "blues", "country".
315
+ - BPM and Rhythm: "slow-paced", "mid-tempo", "upbeat", "rhythmic", "syncopated", "steady beat", "dynamic tempo".
316
+ - Primary Instruments and Sound: "guitar", "synth", "piano", "saxophone", "drums", "violin", "flute", "bassy", "treble-heavy", "distorted", "acoustic", "electric", "ambient sounds".
317
+ - Emotions and Atmosphere: "nostalgic", "energetic", "melancholic", "uplifting", "dark", "light-hearted", "intense", "relaxing", "haunting", "joyful", "sombre", "celebratory", "mystical".
318
+ - Musical Techniques and Enhancements: "harmonious", "dissonant", "layered", "minimalistic", "rich textures", "simple melody", "complex rhythms", "vocal harmonies", "instrumental solo".
319
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
320
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
321
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
322
+ Do not output anything other than JSON values.
323
+ Do not provide any additional explanation of the following.
324
+ Only JSON is allowed.
325
+ ===
326
+ This is some examples.
327
+ Q:
328
+ The genre is "Fantasy", the place is "Enchanted Forest", the mood is "Mystical", the title of the novel is "Whispering Leaves", and the chapter plot revolves around "A hidden glade where elves sing under the moonlight".
329
+ A:
330
+ {{"primary_sentence":"a gentle folk melody filled with whimsical flutes, echoing harps, and distant ethereal vocals, capturing the enchantment of a moonlit forest and the mystique of singing elves"}}
331
+
332
+ Q:
333
+ The genre is "Science Fiction", the place is "Galactic Space Station", the mood is "Tense", the title of the novel is "Stars Unbound", and the chapter plot revolves around "Ambassadors from different galaxies discussing a new treaty".
334
+ A:
335
+ {{"primary_sentence":"an ambient electronic track, with pulsating synths, spacey reverberations, and occasional digital glitches, reflecting the vastness of space and the tension of intergalactic diplomacy"}}
336
+
337
+ Q:
338
+ The genre is "Romance", the place is "Beach", the mood is "Heartfelt", the title of the novel is "Waves of Passion", and the chapter plot revolves around "Two lovers reconciling their differences by the shore".
339
+ A:
340
+ {{"primary_sentence":"a soft acoustic ballad featuring soulful guitars, delicate percussion, and heartfelt vocals, evoking feelings of love, reconciliation, and the gentle ebb and flow of the ocean waves"}}
341
+
342
+ Q:
343
+ The genre is "Middle Ages", the place is "Royal Palace", the mood is "Epic Adventure", the title of the novel is "Throne of Fates", and the chapter plot revolves around "A brave knight receiving a quest from the king".
344
+ A:
345
+ {{"primary_sentence":"a grand orchestral piece, dominated by powerful brass, rhythmic drums, and soaring strings, portraying the valor of knights, the majesty of royalty, and the anticipation of an epic quest"}}
346
+ ===
347
+ This is my request.
348
+ Q:
349
+ {input}
350
+ A:
351
+ """
352
+ query = """
353
+ The genre is "{genre}", the place is "{place}", the mood is "{mood}", the title of the novel is "{title}", and the chapter plot revolves around "{chapter_plot}".
354
+ Print out only one primary_sentence in syntactically valid JSON format.
355
+ """
assets/llama_prompts.toml ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [story_gen]
2
+ add_side_character = """side character #{cur_side_chars}
3
+ - name: {name},
4
+ - job: {job},
5
+ - age: {age},
6
+ - personality: {personality}
7
+
8
+ """
9
+ first_story_gen = """Write the first three paragraphs of a novel as much detailed as possible. They should be based on the background information. Blend 5W1H principle into the stories as a plain text. Don't let the paragraphs end the whole story.
10
+
11
+ background information:
12
+ - genre: {genre}
13
+ - where: {place}
14
+ - mood: {mood}
15
+
16
+ main character
17
+ - name: {main_char_name}
18
+ - job: {main_char_job}
19
+ - age: {main_char_age}
20
+ - personality: {main_char_personality}
21
+ {side_char_placeholder}
22
+ Fill in the following JSON output format:
23
+ {{"paragraphs":"string"}}
24
+
25
+ Write the JSON output:
26
+ """
27
+ next_story_gen = """Write the next paragraphs. The next paragraphs should be determined by an option and well connected to the current stories.
28
+
29
+ background information:
30
+ - genre: {genre}
31
+ - where: {place}
32
+ - mood: {mood}
33
+
34
+ main character
35
+ - name: {main_char_name}
36
+ - job: {main_char_job}
37
+ - age: {main_char_age}
38
+ - personality: {main_char_personality}
39
+ {side_char_placeholder}
40
+ Fill in the following JSON output format:
41
+ {{"paragraphs":"string"}}
42
+
43
+ stories
44
+ {stories}
45
+
46
+ option to the next stories: {action}
47
+
48
+ Write the JSON output:
49
+ """
50
+ actions_gen = """Suggest the 20 options to drive the stories to the next based on the information below.
51
+
52
+ background information:
53
+ - genre: {genre}
54
+ - where: {place}
55
+ - mood: {mood}
56
+
57
+ main character
58
+ - name: {main_char_name}
59
+ - job: {main_char_job}
60
+ - age: {main_char_age}
61
+ - personality: {main_char_personality}
62
+ {side_char_placeholder}
63
+ Fill in the following JSON output format:
64
+ {{"options":["string1", "string2", "string3"]}}
65
+
66
+ summary of the story
67
+ {summary}
68
+
69
+ Write the JSON output:
70
+ """
71
+ summarize = """Summarize the text below
72
+
73
+ {stories}
74
+
75
+ """
76
+
77
+ [chat_gen]
78
+ chapter_title_ctx = """
79
+ chapter{title_idx} {{
80
+ title: {chapter_title},
81
+ plot: {chapter_plot}
82
+ }}
83
+ """
84
+ add_side_character = """side character{cur_side_chars}: {{
85
+ name: {name},
86
+ job: {job},
87
+ age: {age},
88
+ personality: {personality}
89
+ }}
90
+
91
+ """
92
+ chat_context = """You are a professional writing advisor, especially specialized in developing ideas on plotting stories and creating characters. I provide genre, where, and mood along with the rough description of one main character and three side characters.
93
+
94
+ Give creative but not too long responses based on the following information.
95
+
96
+ genre: {genre}
97
+ where: {place}
98
+ mood: {mood}
99
+
100
+ main character: {{
101
+ name: {name1},
102
+ job: {job1},
103
+ age: {age1},
104
+ personality: {personality1}
105
+ }}
106
+ {side_char_placeholder}
107
+ {chapter_title_placeholder}
108
+ """
109
+
110
+ [plot_gen]
111
+ main_plot_gen="""Write a title and an outline of a novel based on the background information below in Ronald Tobias's plot theory. The outline should follow the "rising action", "crisis", "climax", "falling action", and "denouement" plot types. Each should be filled with a VERY detailed and descriptive at least two paragraphs of string. Randomly choose if the story goes optimistic or tragic.
112
+
113
+ background information:
114
+ - genre: string
115
+ - where: string
116
+ - mood: string
117
+
118
+ main character
119
+ - name: string
120
+ - job: string
121
+ - age: string
122
+ - personality: string
123
+
124
+ JSON output:
125
+ {{
126
+ "title": "string",
127
+ "outline": {{
128
+ "rising action": "paragraphs of string",
129
+ "crisis": "paragraphs of string",
130
+ "climax": "paragraphs of string",
131
+ "falling action": "paragraphs of string",
132
+ "denouement": "paragraphs of string"
133
+ }}
134
+ }}
135
+
136
+ background information:
137
+ - genre: {genre}
138
+ - where: {place}
139
+ - mood: {mood}
140
+
141
+ main character
142
+ - name: {main_char_name}
143
+ - job: {main_char_job}
144
+ - age: {main_char_age}
145
+ - personality: {main_char_personality}
146
+ {side_char_placeholder}
147
+ JSON output:
148
+ """
149
+ first_story_gen="""Write the chapter title and the first few paragraphs of the "rising action" plot based on the background information below in Ronald Tobias's plot theory. Also, suggest three choosable actions to drive current story in different directions. The first few paragraphs should be filled with a VERY MUCH detailed and descriptive at least two paragraphs of string.
150
+
151
+ REMEMBER the first few paragraphs should not end the whole story and allow leaway for the next paragraphs to come.
152
+ The whole story SHOULD stick to the "rising action -> crisis -> climax -> falling action -> denouement" flow, so REMEMBER not to write anything mentioned from the next plots of crisis, climax, falling action, and denouement yet.
153
+
154
+ background information:
155
+ - genre: string
156
+ - where: string
157
+ - mood: string
158
+
159
+ main character
160
+ - name: string
161
+ - job: string
162
+ - age: string
163
+ - personality: string
164
+
165
+ overall outline
166
+ - title: string
167
+ - rising action: string
168
+ - crisis: string
169
+ - climax: string
170
+ - falling action: string
171
+ - denouement: string
172
+
173
+ JSON output:
174
+ {{
175
+ "chapter_title": "string",
176
+ "paragraphs": ["string", "string", ...],
177
+ "actions": ["string", "string", "string"]
178
+ }}
179
+
180
+ background information:
181
+ - genre: {genre}
182
+ - where: {place}
183
+ - mood: {mood}
184
+
185
+ main character
186
+ - name: {main_char_name}
187
+ - job: {main_char_job}
188
+ - age: {main_char_age}
189
+ - personality: {main_char_personality}
190
+ {side_char_placeholder}
191
+ overall outline
192
+ - title: {title}
193
+ - rising action: {rising_action}
194
+ - crisis: {crisis}
195
+ - climax: {climax}
196
+ - falling action: {falling_action}
197
+ - denouement: {denouement}
198
+
199
+ JSON output:
200
+ """
201
+
202
+ [image_gen]
203
+ neg_prompt="nsfw, worst quality, low quality, lowres, bad anatomy, bad hands, text, watermark, signature, error, missing fingers, extra digit, fewer digits, cropped, worst quality, normal quality, blurry, username, extra limbs, twins, boring, jpeg artifacts"
204
+
205
+ [image_gen.character]
206
+ gen_prompt = """Based on my brief descriptions of the character, suggest a "primary descriptive sentence" and "concise descriptors" to visualize them. Ensure you consider elements like the character's gender, age, appearance, occupation, clothing, posture, facial expression, mood, among others.
207
+ Once complete, please output only a single "primary descriptive sentence" and the "concise descriptors" in a syntactically valid JSON format.
208
+ The output template is as follows: {{"primary_sentence":"primary descriptive sentence","descriptors":["concise descriptor 1","concise descriptor 2","concise descriptor 3"]}}.
209
+ To enhance the quality of your character's description or expression, you might consider drawing from the following categories:
210
+ - Emotions and Expressions: "ecstatic", "melancholic", "furious", "startled", "bewildered", "pensive", "overjoyed", "crushed", "elated", "panicked", "satisfied", "cynical", "apathetic", "delighted", "terrified", "desperate", "triumphant", "mortified", "envious", "appreciative", "blissful", "heartbroken", "livid", "astounded", "baffled", "smiling", "frowning", "grinning", "crying", "pouting", "glaring", "blinking", "winking", "smirking", "whistling".
211
+ - Physical Features: "upper body", "very long hair", "looking at viewer", "looking to the side", "looking at another", "thick lips", "skin spots", "acnes", "skin blemishes", "age spot", "perfect eyes", "detailed eyes", "realistic eyes", "dynamic standing", "beautiful face", "necklace", "high detailed skin", "hair ornament", "blush", "shiny skin", "long sleeves", "cleavage", "rubber suit", "slim", "plump", "muscular", "pale skin", "tan skin", "dark skin", "blonde hair", "brunette hair", "black hair", "blue eyes", "green eyes", "brown eyes", "curly hair", "short hair", "wavy hair".
212
+ - Visual Enhancements: "masterpiece", "cinematic lighting", "detailed lighting", "tyndall effect", "soft lighting", "volumetric lighting", "close up", "wide shot", "glossy", "beautiful lighting", "warm lighting", "extreme", "ultimate", "best", "supreme", "ultra", "intense", "powerful", "exceptional", "remarkable", "strong", "vigorous", "dynamic angle", "front view person", "bangs", "waist up", "bokeh".
213
+ - Age and Gender: "1boy", "1man", "1male", "1girl", "1woman", "1female", "teen", "teenage", "twenties", "thirties", "forties", "fifties", "middle-age".
214
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
215
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
216
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
217
+ Do not output anything other than JSON values.
218
+ Do not provide any additional explanation of the following.
219
+ Only JSON is allowed.
220
+ ===
221
+ This is some examples.
222
+ Q:
223
+ The character's name is Liam, their job is as the Secret Agent, and they are in their 50s. And the keywords that help in associating with the character are "Thriller, Underground Warehouse, Darkness, ESTP, Ambitious, Generous".
224
+ Print out no more than 45 words in syntactically valid JSON format.
225
+ A:
226
+ {{"primary_sentence":"Middle-aged man pointing a gun in an underground warehouse","descriptors":["1man","solo","masterpiece","best quality","upper body","black suit","pistol in hand","dramatic lighting","muscular physique","intense brown eyes","raven-black hair","stylish cut","determined gaze","looking at viewer","stealthy demeanor","cunning strategist","advanced techwear","sleek","night operative","shadowy figure","night atmosphere","mysterious aura","highly detailed","film grain","detailed eyes and face"]}}
227
+
228
+ Q:
229
+ The character's name is Catherine, their job is as the Traveler, and they are in their 10s. And the keywords that help in associating with the character are "Romance, Starlit Bridge, Dreamy, ENTJ, Ambitious".
230
+ Print out no more than 45 words in syntactically valid JSON format.
231
+ A:
232
+ {{"primary_sentence":"A dreamy teenage girl standing on a starlit bridge with romantic ambitions","descriptors":["1girl","solo","masterpiece","best quality","upper body","flowing skirt","sun hat","bright-eyed","map in hand","ethereal beauty","wanderlust","scarf","whimsical","graceful poise","celestial allure","close-up","warm soft lighting","luminescent glow","gentle aura","mystic charm","smirk","dreamy landscape","poetic demeanor","cinematic lighting","extremely detailed","film grain","detailed eyes and face"]}}
233
+
234
+ Q:
235
+ The character's name is Claire, their job is as the Technological Advancement, and they are in their 20s. And the keywords that help in associating with the character are "Science Fiction, Space Station, INFP, Ambitious, Generous".
236
+ Print out no more than 45 words in syntactically valid JSON format.
237
+ A:
238
+ {{"primary_sentence":"A young ambitious woman tech expert aboard a futuristic space station","descriptors":["1girl","solo","masterpiece","best quality","upper body","sleek silver jumpsuit","futuristic heels","contemplative","editorial portrait","dynamic angle","sci-fi","techno-savvy","sharp focus","bokeh","beautiful lighting","intricate circuitry","robotic grace","rich colors","vivid contrasts","dramatic lighting","futuristic flair","avant-garde","high-tech allure","innovative mind","mechanical sophistication","film grain","detailed eyes and face"]}}
239
+
240
+ Q:
241
+ The character's name is Sophie, their job is as a Ballet Dancer, and they are in their 10s. And the keywords that help in associating with the character are "Grace, Dance Studio, Elegance, ISFJ, Gentle, Passionate"
242
+ Print out no more than 45 words in syntactically valid JSON format.
243
+ A:
244
+ {{"primary_sentence":"An elegant dancer poses gracefully in a mirrored studio","descriptors":["1girl","teen","solo","masterpiece","best quality","upper body","beautiful face","shiny skin","wavy hair","ballet attire","tiptoe stance","flowing skirt","focused gaze","soft ambiance","soft lighting","film grain","detailed eyes and face"]}}
245
+ ===
246
+ This is my request.
247
+ Q:
248
+ {input}
249
+ A:
250
+ """
251
+ query = """
252
+ The character's name is {character_name}, their job is as the {job}, and they are in their {age}. And the keywords that help in associating with the character are "{keywords}".
253
+ Print out no more than 45 words in syntactically valid JSON format.
254
+ """
255
+
256
+ [image_gen.background]
257
+ gen_prompt = """Based on my brief descriptions of the scene, suggest a "primary descriptive sentence" and "concise descriptors" to visualize it. Ensure you consider elements like the setting's time of day, atmosphere, prominent objects, mood, location, natural phenomena, architecture, among others.
258
+ Once complete, please output only a single "primary descriptive sentence" and the "concise descriptors" in a syntactically valid JSON format.
259
+ The output template is as follows: {{"primary_sentence":"primary descriptive sentence","descriptors":["concise descriptor 1","concise descriptor 2","concise descriptor 3"]}}.
260
+ To enhance the quality of your scene's description or expression, you might consider drawing from the following categories:
261
+ - Atmosphere and Time: "dawn", "dusk", "midday", "midnight", "sunset", "sunrise", "foggy", "misty", "stormy", "calm", "clear night", "starlit", "moonlit", "golden hour".
262
+ - Natural Phenomena: "rainbow", "thunderstorm", "snowfall", "aurora borealis", "shooting star", "rain shower", "windy", "sunny".
263
+ - Location and Architecture: "urban", "rural", "mountainous", "oceanfront", "forest", "desert", "island", "modern city", "ancient ruins", "castle", "village", "meadow", "cave", "bridge".
264
+ - Prominent Objects: "giant tree", "waterfall", "stream", "rock formation", "ancient artifact", "bonfire", "tent", "vehicle", "statue", "fountain".
265
+ - Visual Enhancements: "masterpiece", "cinematic lighting", "detailed lighting", "soft lighting", "volumetric lighting", "tyndall effect", "warm lighting", "close up", "wide shot", "beautiful perspective", "bokeh".
266
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
267
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
268
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
269
+ Do not output anything other than JSON values.
270
+ Do not provide any additional explanation of the following.
271
+ Only JSON is allowed.
272
+ ===
273
+ This is some examples.
274
+ Q:
275
+ The genre is "Fantasy", the place is "Enchanted Forest", the mood is "Mystical", the title of the novel is "Whispering Leaves", and the chapter plot revolves around "A hidden glade where elves sing under the moonlight".
276
+ Print out no more than 45 words in syntactically valid JSON format.
277
+ A:
278
+ {{"primary_sentence":"a mystical glade in an enchanted forest where elves sing beneath the moonlight","descriptors":["no humans","masterpiece","fantasy","enchanted forest","moonlit glade","mystical atmosphere","singing elves","luminous fireflies","ancient trees","shimmering leaves","whispering winds","hidden secrets","elven magic","masterpiece","soft lighting","silver glow","detailed shadows","enchanted mood","highly detailed","film grain"]}}
279
+
280
+ Q:
281
+ The genre is "Science Fiction", the place is "Galactic Space Station", the mood is "Tense", the title of the novel is "Stars Unbound", and the chapter plot revolves around "Ambassadors from different galaxies discussing a new treaty".
282
+ Print out no more than 45 words in syntactically valid JSON format.
283
+ A:
284
+ {{"primary_sentence":"a tense gathering in a galactic space station where interstellar ambassadors negotiate","descriptors":["no humans","masterpiece","science fiction","galactic space station","star-studded backdrop","advanced technology","diverse aliens","hovering spacecrafts","futuristic architecture","tense discussions","interstellar politics","neon lights","holographic displays","masterpiece","detailed lighting","cinematic mood","highly detailed","film grain"]}}
285
+
286
+ Q:
287
+ The genre is "Romance", the place is "Beach", the mood is "Heartfelt", the title of the novel is "Waves of Passion", and the chapter plot revolves around "Two lovers reconciling their differences by the shore".
288
+ Print out no more than 45 words in syntactically valid JSON format.
289
+ A:
290
+ {{"primary_sentence":"a heartfelt scene on a beach during sunset where two lovers reconcile","descriptors":["no humans","masterpiece","romance","beach","sunset horizon","golden sands","lapping waves","embrace","teary-eyed confessions","seashells","reflective waters","warm hues","silhouette of lovers","soft breeze","beautiful perspective","detailed shadows","emotional atmosphere","highly detailed","film grain"]}}
291
+
292
+ Q:
293
+ The genre is "Middle Ages", the place is "Royal Palace", the mood is "Epic Adventure", the title of the novel is "Throne of Fates", and the chapter plot revolves around "A brave knight receiving a quest from the king".
294
+ Print out no more than 45 words in syntactically valid JSON format.
295
+ A:
296
+ {{"primary_sentence":"an epic scene in a royal palace where a knight is tasked with a quest by the king","descriptors":["no humans","masterpiece","middle ages","royal palace","castle","grand throne room","golden hour","armored knight","majestic king","tapestries","stone walls","torches","glistening armor","banner flags","medieval atmosphere","heroic demeanor","detailed architecture","golden crowns","highly detailed","film grain"]}}
297
+ ===
298
+ This is my request.
299
+ Q:
300
+ {input}
301
+ A:
302
+ """
303
+ query = """
304
+ The genre is "{genre}", the place is "{place}", the mood is "{mood}", the title of the novel is "{title}", and the chapter plot revolves around "{chapter_plot}".
305
+ Print out no more than 45 words in syntactically valid JSON format.
306
+ """
307
+
308
+ [music_gen]
309
+ gen_prompt = """Based on my brief descriptions of the novel's mood, theme, or setting, suggest a "primary descriptive sentence" to conceptualize the musical piece. Ensure you consider elements like the music's genre, BPM, primary instruments, emotions evoked, era (if applicable), and other relevant musical characteristics.
310
+ Once complete, please output only a single "primary descriptive sentence" in a syntactically valid JSON format.
311
+ The output template is as follows:
312
+ {{"primary_sentence":"primary descriptive sentence"}}.
313
+ To enhance the quality of your music's description or expression, you might consider drawing from the following categories:
314
+ - Musical Genre and Era: "80s", "90s", "classical", "jazz", "EDM", "rock", "folk", "baroque", "bebop", "grunge", "funk", "hip-hop", "blues", "country".
315
+ - BPM and Rhythm: "slow-paced", "mid-tempo", "upbeat", "rhythmic", "syncopated", "steady beat", "dynamic tempo".
316
+ - Primary Instruments and Sound: "guitar", "synth", "piano", "saxophone", "drums", "violin", "flute", "bassy", "treble-heavy", "distorted", "acoustic", "electric", "ambient sounds".
317
+ - Emotions and Atmosphere: "nostalgic", "energetic", "melancholic", "uplifting", "dark", "light-hearted", "intense", "relaxing", "haunting", "joyful", "sombre", "celebratory", "mystical".
318
+ - Musical Techniques and Enhancements: "harmonious", "dissonant", "layered", "minimalistic", "rich textures", "simple melody", "complex rhythms", "vocal harmonies", "instrumental solo".
319
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
320
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
321
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
322
+ Do not output anything other than JSON values.
323
+ Do not provide any additional explanation of the following.
324
+ Only JSON is allowed.
325
+ ===
326
+ This is some examples.
327
+ Q:
328
+ The genre is "Fantasy", the place is "Enchanted Forest", the mood is "Mystical", the title of the novel is "Whispering Leaves", and the chapter plot revolves around "A hidden glade where elves sing under the moonlight".
329
+ A:
330
+ {{"primary_sentence":"a gentle folk melody filled with whimsical flutes, echoing harps, and distant ethereal vocals, capturing the enchantment of a moonlit forest and the mystique of singing elves"}}
331
+
332
+ Q:
333
+ The genre is "Science Fiction", the place is "Galactic Space Station", the mood is "Tense", the title of the novel is "Stars Unbound", and the chapter plot revolves around "Ambassadors from different galaxies discussing a new treaty".
334
+ A:
335
+ {{"primary_sentence":"an ambient electronic track, with pulsating synths, spacey reverberations, and occasional digital glitches, reflecting the vastness of space and the tension of intergalactic diplomacy"}}
336
+
337
+ Q:
338
+ The genre is "Romance", the place is "Beach", the mood is "Heartfelt", the title of the novel is "Waves of Passion", and the chapter plot revolves around "Two lovers reconciling their differences by the shore".
339
+ A:
340
+ {{"primary_sentence":"a soft acoustic ballad featuring soulful guitars, delicate percussion, and heartfelt vocals, evoking feelings of love, reconciliation, and the gentle ebb and flow of the ocean waves"}}
341
+
342
+ Q:
343
+ The genre is "Middle Ages", the place is "Royal Palace", the mood is "Epic Adventure", the title of the novel is "Throne of Fates", and the chapter plot revolves around "A brave knight receiving a quest from the king".
344
+ A:
345
+ {{"primary_sentence":"a grand orchestral piece, dominated by powerful brass, rhythmic drums, and soaring strings, portraying the valor of knights, the majesty of royalty, and the anticipation of an epic quest"}}
346
+ ===
347
+ This is my request.
348
+ Q:
349
+ {input}
350
+ A:
351
+ """
352
+ query = """
353
+ The genre is "{genre}", the place is "{place}", the mood is "{mood}", the title of the novel is "{title}", and the chapter plot revolves around "{chapter_plot}".
354
+ Print out only one primary_sentence in syntactically valid JSON format.
355
+ """
cute20vae.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:008c88ced6307623d5f620404695970ae74da80c87a70e4cf3851b8fab4272b8
3
- size 334640982
 
 
 
 
hellonijicute25d_V10b.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:349e1d80f2954416cb93fa7afad001fd6df6c55b602dd344493065ec7500cc59
3
- size 2132625644
 
 
 
 
interfaces/chat_ui.py CHANGED
@@ -1,22 +1,22 @@
1
  import gradio as gr
2
 
3
- from interfaces import utils
4
- from modules import (
5
- palmchat, palm_prompts,
6
- )
7
-
8
  from pingpong import PingPong
9
 
 
 
 
10
  def rollback_last_ui(history):
11
  return history[:-1]
12
 
13
 
14
- def add_side_character(enable, name, age, personality, job):
 
 
15
  cur_side_chars = 1
16
  prompt = ""
17
  for idx in range(len(enable)):
18
  if enable[idx]:
19
- prompt += palm_prompts['chat_gen']['add_side_character'].format(
20
  cur_side_chars=cur_side_chars,
21
  name=name[idx],
22
  job=job[idx],
@@ -27,12 +27,14 @@ def add_side_character(enable, name, age, personality, job):
27
  return "\n" + prompt if prompt else ""
28
 
29
 
30
- def add_chapter_title_ctx(chapter_title, chapter_plot):
 
 
31
  title_idx = 1
32
  prompt = ""
33
  for idx in range(len(chapter_title)):
34
  if chapter_title[idx] :
35
- prompt += palm_prompts['chat_gen']['chapter_title_ctx'].format(
36
  title_idx=title_idx,
37
  chapter_title=chapter_title[idx],
38
  chapter_plot=chapter_plot[idx],
@@ -51,7 +53,10 @@ async def chat(
51
  chapter1_title, chapter2_title, chapter3_title, chapter4_title,
52
  chapter1_plot, chapter2_plot, chapter3_plot, chapter4_plot,
53
  side_char_enable1, side_char_enable2, side_char_enable3,
 
54
  ):
 
 
55
  chapter_title_ctx = add_chapter_title_ctx(
56
  [chapter1_title, chapter2_title, chapter3_title, chapter4_title],
57
  [chapter1_plot, chapter2_plot, chapter3_plot, chapter4_plot],
@@ -63,7 +68,7 @@ async def chat(
63
  [side_char_age1, side_char_age2, side_char_age3],
64
  [side_char_personality1, side_char_personality2, side_char_personality3],
65
  )
66
- prompt = palm_prompts['chat_gen']['chat_context'].format(
67
  genre=genre, place=place, mood=mood,
68
  main_char_name=main_char_name,
69
  main_char_job=main_char_job,
@@ -112,8 +117,10 @@ async def chat_regen(chat_mode, chat_state):
112
  ppm.build_uis()
113
  )
114
 
115
- def chat_reset(chat_mode, chat_state):
116
- chat_state[chat_mode] = palmchat.GradioPaLMChatPPManager()
 
 
117
 
118
  return (
119
  "",
 
1
  import gradio as gr
2
 
 
 
 
 
 
3
  from pingpong import PingPong
4
 
5
+ from interfaces import utils
6
+ from modules.llms import get_llm_factory
7
+
8
  def rollback_last_ui(history):
9
  return history[:-1]
10
 
11
 
12
+ def add_side_character(enable, name, age, personality, job, llm_type='PaLM'):
13
+ prompts = get_llm_factory(llm_type).create_prompt_manager().prompts
14
+
15
  cur_side_chars = 1
16
  prompt = ""
17
  for idx in range(len(enable)):
18
  if enable[idx]:
19
+ prompt += prompts['chat_gen']['add_side_character'].format(
20
  cur_side_chars=cur_side_chars,
21
  name=name[idx],
22
  job=job[idx],
 
27
  return "\n" + prompt if prompt else ""
28
 
29
 
30
+ def add_chapter_title_ctx(chapter_title, chapter_plot, llm_type='PaLM'):
31
+ prompts = get_llm_factory(llm_type).create_prompt_manager().prompts
32
+
33
  title_idx = 1
34
  prompt = ""
35
  for idx in range(len(chapter_title)):
36
  if chapter_title[idx] :
37
+ prompt += prompts['chat_gen']['chapter_title_ctx'].format(
38
  title_idx=title_idx,
39
  chapter_title=chapter_title[idx],
40
  chapter_plot=chapter_plot[idx],
 
53
  chapter1_title, chapter2_title, chapter3_title, chapter4_title,
54
  chapter1_plot, chapter2_plot, chapter3_plot, chapter4_plot,
55
  side_char_enable1, side_char_enable2, side_char_enable3,
56
+ llm_type='PaLM',
57
  ):
58
+ prompts = get_llm_factory(llm_type).create_prompt_manager().prompts
59
+
60
  chapter_title_ctx = add_chapter_title_ctx(
61
  [chapter1_title, chapter2_title, chapter3_title, chapter4_title],
62
  [chapter1_plot, chapter2_plot, chapter3_plot, chapter4_plot],
 
68
  [side_char_age1, side_char_age2, side_char_age3],
69
  [side_char_personality1, side_char_personality2, side_char_personality3],
70
  )
71
+ prompt = prompts['chat_gen']['chat_context'].format(
72
  genre=genre, place=place, mood=mood,
73
  main_char_name=main_char_name,
74
  main_char_job=main_char_job,
 
117
  ppm.build_uis()
118
  )
119
 
120
+ def chat_reset(chat_mode, chat_state, llm_type='PaLM'):
121
+ factory = get_llm_factory(llm_type)
122
+
123
+ chat_state[chat_mode] = factory.create_ui_pp_manager()
124
 
125
  return (
126
  "",
interfaces/export_ui.py CHANGED
@@ -1,30 +1,23 @@
1
  import gradio as gr
2
  from templates import parser
3
  from interfaces import utils
4
- from modules import palmchat
5
 
6
  template_file = "templates/basic.jinja"
7
 
8
- async def title_gen(cursors):
9
  stories = ""
10
  for cursor in cursors:
11
  stories = stories + cursor["story"]
12
-
13
- prompt = f"""what would be the title of the story below? be specific and creative.
 
 
14
 
15
- {stories}
16
 
17
- title: """
18
-
19
- parameters = {
20
- 'model': 'models/text-bison-001',
21
- 'candidate_count': 1,
22
- 'temperature': 0.7,
23
- 'top_k': 40,
24
- 'top_p': 1,
25
- 'max_output_tokens': 4096,
26
- }
27
- _, title = await palmchat.gen_text(prompt, mode="text", parameters=parameters)
28
  return title
29
 
30
  def export(
 
1
  import gradio as gr
2
  from templates import parser
3
  from interfaces import utils
4
+ from modules.llms import get_llm_factory
5
 
6
  template_file = "templates/basic.jinja"
7
 
8
+ async def title_gen(cursors, llm_type="PaLM"):
9
  stories = ""
10
  for cursor in cursors:
11
  stories = stories + cursor["story"]
12
+
13
+ factory = get_llm_factory(llm_type)
14
+ prompts = factory.create_prompt_manager().prompts
15
+ llm_service = factory.create_llm_service()
16
 
17
+ prompt = prompts['story_gen']['title'].format(stories=stories)
18
 
19
+ parameters = llm_service.make_params(mode="text", temperature=0.7, top_k=40, top_p=1.0, max_output_tokens=4096)
20
+ _, title = await llm_service.gen_text(prompt, mode="text", parameters=parameters)
 
 
 
 
 
 
 
 
 
21
  return title
22
 
23
  def export(
interfaces/plot_gen_ui.py CHANGED
@@ -1,12 +1,7 @@
1
  import re
2
  import gradio as gr
3
  from interfaces import utils
4
- from modules import(
5
- palmchat,
6
- palm_prompts,
7
- )
8
-
9
- print(palm_prompts)
10
 
11
  async def plot_gen(
12
  temperature,
@@ -16,7 +11,12 @@ async def plot_gen(
16
  side_char_name1, side_char_age1, side_char_personality1, side_char_job1,
17
  side_char_name2, side_char_age2, side_char_personality2, side_char_job2,
18
  side_char_name3, side_char_age3, side_char_personality3, side_char_job3,
 
19
  ):
 
 
 
 
20
  side_char_prompt = utils.add_side_character(
21
  [side_char_enable1, side_char_enable2, side_char_enable3],
22
  [side_char_name1, side_char_name2, side_char_name3],
@@ -24,7 +24,7 @@ async def plot_gen(
24
  [side_char_age1, side_char_age2, side_char_age3],
25
  [side_char_personality1, side_char_personality2, side_char_personality3],
26
  )
27
- prompt = palm_prompts['plot_gen']['main_plot_gen'].format(
28
  genre=genre, place=place, mood=mood,
29
  main_char_name=main_char_name,
30
  main_char_job=main_char_job,
@@ -34,14 +34,7 @@ async def plot_gen(
34
  )
35
 
36
  print(f"generated prompt:\n{prompt}")
37
- parameters = {
38
- 'model': 'models/text-bison-001',
39
- 'candidate_count': 1,
40
- 'temperature': temperature,
41
- 'top_k': 40,
42
- 'top_p': 1,
43
- 'max_output_tokens': 4096,
44
- }
45
  response_json = await utils.retry_until_valid_json(prompt, parameters=parameters)
46
 
47
  return (
@@ -64,8 +57,13 @@ async def first_story_gen(
64
  side_char_name1, side_char_age1, side_char_personality1, side_char_job1,
65
  side_char_name2, side_char_age2, side_char_personality2, side_char_job2,
66
  side_char_name3, side_char_age3, side_char_personality3, side_char_job3,
67
- cursors, cur_cursor
 
68
  ):
 
 
 
 
69
  side_char_prompt = utils.add_side_character(
70
  [side_char_enable1, side_char_enable2, side_char_enable3],
71
  [side_char_name1, side_char_name2, side_char_name3],
@@ -73,7 +71,7 @@ async def first_story_gen(
73
  [side_char_age1, side_char_age2, side_char_age3],
74
  [side_char_personality1, side_char_personality2, side_char_personality3],
75
  )
76
- prompt = palm_prompts['plot_gen']['first_story_gen'].format(
77
  genre=genre, place=place, mood=mood,
78
  main_char_name=main_char_name,
79
  main_char_job=main_char_job,
@@ -89,14 +87,7 @@ async def first_story_gen(
89
  )
90
 
91
  print(f"generated prompt:\n{prompt}")
92
- parameters = {
93
- 'model': 'models/text-bison-001',
94
- 'candidate_count': 1,
95
- 'temperature': 1,
96
- 'top_k': 40,
97
- 'top_p': 1,
98
- 'max_output_tokens': 4096,
99
- }
100
  response_json = await utils.retry_until_valid_json(prompt, parameters=parameters)
101
 
102
  chapter_title = response_json["chapter_title"]
 
1
  import re
2
  import gradio as gr
3
  from interfaces import utils
4
+ from modules import get_llm_factory
 
 
 
 
 
5
 
6
  async def plot_gen(
7
  temperature,
 
11
  side_char_name1, side_char_age1, side_char_personality1, side_char_job1,
12
  side_char_name2, side_char_age2, side_char_personality2, side_char_job2,
13
  side_char_name3, side_char_age3, side_char_personality3, side_char_job3,
14
+ llm_type="PaLM"
15
  ):
16
+ factory = get_llm_factory(llm_type)
17
+ prompts = factory.create_prompt_manager().prompts
18
+ llm_service = factory.create_llm_service()
19
+
20
  side_char_prompt = utils.add_side_character(
21
  [side_char_enable1, side_char_enable2, side_char_enable3],
22
  [side_char_name1, side_char_name2, side_char_name3],
 
24
  [side_char_age1, side_char_age2, side_char_age3],
25
  [side_char_personality1, side_char_personality2, side_char_personality3],
26
  )
27
+ prompt = prompts['plot_gen']['main_plot_gen'].format(
28
  genre=genre, place=place, mood=mood,
29
  main_char_name=main_char_name,
30
  main_char_job=main_char_job,
 
34
  )
35
 
36
  print(f"generated prompt:\n{prompt}")
37
+ parameters = llm_service.make_params(mode="text", temperature=temperature, top_k=40, top_p=1.0, max_output_tokens=4096)
 
 
 
 
 
 
 
38
  response_json = await utils.retry_until_valid_json(prompt, parameters=parameters)
39
 
40
  return (
 
57
  side_char_name1, side_char_age1, side_char_personality1, side_char_job1,
58
  side_char_name2, side_char_age2, side_char_personality2, side_char_job2,
59
  side_char_name3, side_char_age3, side_char_personality3, side_char_job3,
60
+ cursors, cur_cursor,
61
+ llm_type="PaLM"
62
  ):
63
+ factory = get_llm_factory(llm_type)
64
+ prompts = factory.create_prompt_manager().prompts
65
+ llm_service = factory.create_llm_service()
66
+
67
  side_char_prompt = utils.add_side_character(
68
  [side_char_enable1, side_char_enable2, side_char_enable3],
69
  [side_char_name1, side_char_name2, side_char_name3],
 
71
  [side_char_age1, side_char_age2, side_char_age3],
72
  [side_char_personality1, side_char_personality2, side_char_personality3],
73
  )
74
+ prompt = prompts['plot_gen']['first_story_gen'].format(
75
  genre=genre, place=place, mood=mood,
76
  main_char_name=main_char_name,
77
  main_char_job=main_char_job,
 
87
  )
88
 
89
  print(f"generated prompt:\n{prompt}")
90
+ parameters = llm_service.make_params(mode="text", temperature=1.0, top_k=40, top_p=1.0, max_output_tokens=4096)
 
 
 
 
 
 
 
91
  response_json = await utils.retry_until_valid_json(prompt, parameters=parameters)
92
 
93
  chapter_title = response_json["chapter_title"]
interfaces/story_gen_ui.py CHANGED
@@ -6,8 +6,9 @@ from gradio_client import Client
6
  from pathlib import Path
7
 
8
  from modules import (
9
- ImageMaker, MusicMaker, palmchat, palm_prompts, merge_video
10
  )
 
11
  from interfaces import utils
12
 
13
  from pingpong import PingPong
@@ -20,13 +21,6 @@ bgm_maker = MusicMaker(model_size='small', output_format='mp3')
20
 
21
  video_gen_client_url = None # e.g. "https://0447df3cf5f7c49c46.gradio.live"
22
 
23
- # default safety settings
24
- safety_settings = [{"category":"HARM_CATEGORY_DEROGATORY","threshold":1},
25
- {"category":"HARM_CATEGORY_TOXICITY","threshold":1},
26
- {"category":"HARM_CATEGORY_VIOLENCE","threshold":2},
27
- {"category":"HARM_CATEGORY_SEXUAL","threshold":2},
28
- {"category":"HARM_CATEGORY_MEDICAL","threshold":2},
29
- {"category":"HARM_CATEGORY_DANGEROUS","threshold":2}]
30
 
31
  async def update_story_gen(
32
  cursors, cur_cursor_idx,
@@ -66,8 +60,13 @@ async def next_story_gen(
66
  side_char_enable1, side_char_name1, side_char_age1, side_char_personality1, side_char_job1,
67
  side_char_enable2, side_char_name2, side_char_age2, side_char_personality2, side_char_job2,
68
  side_char_enable3, side_char_name3, side_char_age3, side_char_personality3, side_char_job3,
69
- cur_cursor_idx=None
 
70
  ):
 
 
 
 
71
  stories = ""
72
  cur_side_chars = 1
73
 
@@ -85,7 +84,7 @@ async def next_story_gen(
85
  [side_char_personality1, side_char_personality2, side_char_personality3],
86
  )
87
 
88
- prompt = palm_prompts['story_gen']['next_story_gen'].format(
89
  genre=genre, place=place, mood=mood,
90
  main_char_name=main_char_name,
91
  main_char_job=main_char_job,
@@ -96,15 +95,7 @@ async def next_story_gen(
96
  )
97
 
98
  print(f"generated prompt:\n{prompt}")
99
- parameters = {
100
- 'model': 'models/text-bison-001',
101
- 'candidate_count': 1,
102
- 'temperature': 1.0,
103
- 'top_k': 40,
104
- 'top_p': 1,
105
- 'max_output_tokens': 4096,
106
- 'safety_settings': safety_settings,
107
- }
108
  try:
109
  response_json = await utils.retry_until_valid_json(prompt, parameters=parameters)
110
  except Exception as e:
@@ -147,8 +138,13 @@ async def actions_gen(
147
  side_char_enable1, side_char_name1, side_char_age1, side_char_personality1, side_char_job1,
148
  side_char_enable2, side_char_name2, side_char_age2, side_char_personality2, side_char_job2,
149
  side_char_enable3, side_char_name3, side_char_age3, side_char_personality3, side_char_job3,
150
- cur_cursor_idx=None
 
151
  ):
 
 
 
 
152
  stories = ""
153
  cur_side_chars = 1
154
  end_idx = len(cursors) if cur_cursor_idx is None else len(cursors)-1
@@ -156,21 +152,13 @@ async def actions_gen(
156
  for cursor in cursors[:end_idx]:
157
  stories = stories + cursor["story"]
158
 
159
- summary_prompt = palm_prompts['story_gen']['summarize'].format(stories=stories)
160
 
161
  print(f"generated prompt:\n{summary_prompt}")
162
- parameters = {
163
- 'model': 'models/text-bison-001',
164
- 'candidate_count': 1,
165
- 'temperature': 1.0,
166
- 'top_k': 40,
167
- 'top_p': 1,
168
- 'max_output_tokens': 4096,
169
- 'safety_settings': safety_settings,
170
- }
171
 
172
  try:
173
- _, summary = await palmchat.gen_text(summary_prompt, mode="text", parameters=parameters)
174
  except Exception as e:
175
  print(e)
176
  raise gr.Error(e)
@@ -182,7 +170,7 @@ async def actions_gen(
182
  [side_char_age1, side_char_age2, side_char_age3],
183
  [side_char_personality1, side_char_personality2, side_char_personality3],
184
  )
185
- prompt = palm_prompts['story_gen']['actions_gen'].format(
186
  genre=genre, place=place, mood=mood,
187
  main_char_name=main_char_name,
188
  main_char_job=main_char_job,
@@ -193,15 +181,7 @@ async def actions_gen(
193
  )
194
 
195
  print(f"generated prompt:\n{prompt}")
196
- parameters = {
197
- 'model': 'models/text-bison-001',
198
- 'candidate_count': 1,
199
- 'temperature': 1.0,
200
- 'top_k': 40,
201
- 'top_p': 1,
202
- 'max_output_tokens': 4096,
203
- 'safety_settings': safety_settings,
204
- }
205
  try:
206
  response_json = await utils.retry_until_valid_json(prompt, parameters=parameters)
207
  except Exception as e:
@@ -225,8 +205,13 @@ async def first_story_gen(
225
  side_char_enable1, side_char_name1, side_char_age1, side_char_personality1, side_char_job1,
226
  side_char_enable2, side_char_name2, side_char_age2, side_char_personality2, side_char_job2,
227
  side_char_enable3, side_char_name3, side_char_age3, side_char_personality3, side_char_job3,
228
- cur_cursor_idx=None
 
229
  ):
 
 
 
 
230
  cur_side_chars = 1
231
 
232
  side_char_prompt = utils.add_side_character(
@@ -236,7 +221,7 @@ async def first_story_gen(
236
  [side_char_age1, side_char_age2, side_char_age3],
237
  [side_char_personality1, side_char_personality2, side_char_personality3],
238
  )
239
- prompt = palm_prompts['story_gen']['first_story_gen'].format(
240
  genre=genre, place=place, mood=mood,
241
  main_char_name=main_char_name,
242
  main_char_job=main_char_job,
@@ -246,15 +231,7 @@ async def first_story_gen(
246
  )
247
 
248
  print(f"generated prompt:\n{prompt}")
249
- parameters = {
250
- 'model': 'models/text-bison-001',
251
- 'candidate_count': 1,
252
- 'temperature': 1.0,
253
- 'top_k': 40,
254
- 'top_p': 1,
255
- 'max_output_tokens': 4096,
256
- 'safety_settings': safety_settings,
257
- }
258
  try:
259
  response_json = await utils.retry_until_valid_json(prompt, parameters=parameters)
260
  except Exception as e:
@@ -317,12 +294,12 @@ def video_gen(
317
 
318
 
319
  def image_gen(
320
- genre, place, mood, title, story_content, cursors, cur_cursor
321
  ):
322
- # generate prompts for background image with PaLM
323
  for _ in range(3):
324
  try:
325
- prompt, neg_prompt = img_maker.generate_background_prompts(genre, place, mood, title, "", story_content)
326
  print(f"Image Prompt: {prompt}")
327
  print(f"Negative Prompt: {neg_prompt}")
328
  break
@@ -350,12 +327,12 @@ def image_gen(
350
 
351
 
352
  def audio_gen(
353
- genre, place, mood, title, story_content, cursors, cur_cursor
354
  ):
355
- # generate prompt for background music with PaLM
356
  for _ in range(3):
357
  try:
358
- prompt = bgm_maker.generate_prompt(genre, place, mood, title, "", story_content)
359
  print(f"Music Prompt: {prompt}")
360
  break
361
  except Exception as e:
 
6
  from pathlib import Path
7
 
8
  from modules import (
9
+ ImageMaker, MusicMaker, merge_video
10
  )
11
+ from modules.llms import get_llm_factory
12
  from interfaces import utils
13
 
14
  from pingpong import PingPong
 
21
 
22
  video_gen_client_url = None # e.g. "https://0447df3cf5f7c49c46.gradio.live"
23
 
 
 
 
 
 
 
 
24
 
25
  async def update_story_gen(
26
  cursors, cur_cursor_idx,
 
60
  side_char_enable1, side_char_name1, side_char_age1, side_char_personality1, side_char_job1,
61
  side_char_enable2, side_char_name2, side_char_age2, side_char_personality2, side_char_job2,
62
  side_char_enable3, side_char_name3, side_char_age3, side_char_personality3, side_char_job3,
63
+ cur_cursor_idx=None,
64
+ llm_type="PaLM"
65
  ):
66
+ factory = get_llm_factory(llm_type)
67
+ prompts = factory.create_prompt_manager().prompts
68
+ llm_service = factory.create_llm_service()
69
+
70
  stories = ""
71
  cur_side_chars = 1
72
 
 
84
  [side_char_personality1, side_char_personality2, side_char_personality3],
85
  )
86
 
87
+ prompt = prompts['story_gen']['next_story_gen'].format(
88
  genre=genre, place=place, mood=mood,
89
  main_char_name=main_char_name,
90
  main_char_job=main_char_job,
 
95
  )
96
 
97
  print(f"generated prompt:\n{prompt}")
98
+ parameters = llm_service.make_params(mode="text", temperature=1.0, top_k=40, top_p=0.9, max_output_tokens=4096)
 
 
 
 
 
 
 
 
99
  try:
100
  response_json = await utils.retry_until_valid_json(prompt, parameters=parameters)
101
  except Exception as e:
 
138
  side_char_enable1, side_char_name1, side_char_age1, side_char_personality1, side_char_job1,
139
  side_char_enable2, side_char_name2, side_char_age2, side_char_personality2, side_char_job2,
140
  side_char_enable3, side_char_name3, side_char_age3, side_char_personality3, side_char_job3,
141
+ cur_cursor_idx=None,
142
+ llm_type="PaLM"
143
  ):
144
+ factory = get_llm_factory(llm_type)
145
+ prompts = factory.create_prompt_manager().prompts
146
+ llm_service = factory.create_llm_service()
147
+
148
  stories = ""
149
  cur_side_chars = 1
150
  end_idx = len(cursors) if cur_cursor_idx is None else len(cursors)-1
 
152
  for cursor in cursors[:end_idx]:
153
  stories = stories + cursor["story"]
154
 
155
+ summary_prompt = prompts['story_gen']['summarize'].format(stories=stories)
156
 
157
  print(f"generated prompt:\n{summary_prompt}")
158
+ parameters = llm_service.make_params(mode="text", temperature=1.0, top_k=40, top_p=1.0, max_output_tokens=4096)
 
 
 
 
 
 
 
 
159
 
160
  try:
161
+ _, summary = await llm_service.gen_text(summary_prompt, mode="text", parameters=parameters)
162
  except Exception as e:
163
  print(e)
164
  raise gr.Error(e)
 
170
  [side_char_age1, side_char_age2, side_char_age3],
171
  [side_char_personality1, side_char_personality2, side_char_personality3],
172
  )
173
+ prompt = prompts['story_gen']['actions_gen'].format(
174
  genre=genre, place=place, mood=mood,
175
  main_char_name=main_char_name,
176
  main_char_job=main_char_job,
 
181
  )
182
 
183
  print(f"generated prompt:\n{prompt}")
184
+ parameters = llm_service.make_params(mode="text", temperature=1.0, top_k=40, top_p=1.0, max_output_tokens=4096)
 
 
 
 
 
 
 
 
185
  try:
186
  response_json = await utils.retry_until_valid_json(prompt, parameters=parameters)
187
  except Exception as e:
 
205
  side_char_enable1, side_char_name1, side_char_age1, side_char_personality1, side_char_job1,
206
  side_char_enable2, side_char_name2, side_char_age2, side_char_personality2, side_char_job2,
207
  side_char_enable3, side_char_name3, side_char_age3, side_char_personality3, side_char_job3,
208
+ cur_cursor_idx=None,
209
+ llm_type="PaLM"
210
  ):
211
+ factory = get_llm_factory(llm_type)
212
+ prompts = factory.create_prompt_manager().prompts
213
+ llm_service = factory.create_llm_service()
214
+
215
  cur_side_chars = 1
216
 
217
  side_char_prompt = utils.add_side_character(
 
221
  [side_char_age1, side_char_age2, side_char_age3],
222
  [side_char_personality1, side_char_personality2, side_char_personality3],
223
  )
224
+ prompt = prompts['story_gen']['first_story_gen'].format(
225
  genre=genre, place=place, mood=mood,
226
  main_char_name=main_char_name,
227
  main_char_job=main_char_job,
 
231
  )
232
 
233
  print(f"generated prompt:\n{prompt}")
234
+ parameters = llm_service.make_params(mode="text", temperature=1.0, top_k=40, top_p=1.0, max_output_tokens=4096)
 
 
 
 
 
 
 
 
235
  try:
236
  response_json = await utils.retry_until_valid_json(prompt, parameters=parameters)
237
  except Exception as e:
 
294
 
295
 
296
  def image_gen(
297
+ genre, place, mood, title, story_content, cursors, cur_cursor, llm_type="PaLM"
298
  ):
299
+ # generate prompts for background image with LLM
300
  for _ in range(3):
301
  try:
302
+ prompt, neg_prompt = img_maker.generate_background_prompts(genre, place, mood, title, "", story_content, llm_type)
303
  print(f"Image Prompt: {prompt}")
304
  print(f"Negative Prompt: {neg_prompt}")
305
  break
 
327
 
328
 
329
  def audio_gen(
330
+ genre, place, mood, title, story_content, cursors, cur_cursor, llm_type="PaLM"
331
  ):
332
+ # generate prompt for background music with LLM
333
  for _ in range(3):
334
  try:
335
+ prompt = bgm_maker.generate_prompt(genre, place, mood, title, "", story_content, llm_type)
336
  print(f"Music Prompt: {prompt}")
337
  break
338
  except Exception as e:
interfaces/ui.py CHANGED
@@ -10,9 +10,8 @@ from constants.init_values import (
10
  genres, places, moods, jobs, random_names, default_character_images
11
  )
12
 
13
- from modules import (
14
- ImageMaker, palmchat
15
- )
16
 
17
  from interfaces import utils
18
 
@@ -64,7 +63,7 @@ def gen_character_image(
64
  name, age, personality, job,
65
  genre, place, mood, creative_mode
66
  ):
67
- # generate prompts for character image with PaLM
68
  for _ in range(3):
69
  try:
70
  prompt, neg_prompt = img_maker.generate_character_prompts(name, age, job, keywords=[personality, genre, place, mood], creative_mode=creative_mode)
@@ -120,17 +119,18 @@ def update_on_main_tabs(chat_state, evt: gr.SelectData):
120
  ppm = chat_state[chat_mode]
121
  return chat_mode, ppm.build_uis()
122
 
123
- def reset():
124
- from modules.palmchat import GradioPaLMChatPPManager
125
-
 
126
  return (
127
  [], # cursors
128
  0, # cur_cursor
129
 
130
  {
131
- "setting_chat": GradioPaLMChatPPManager(),
132
- "story_chat": GradioPaLMChatPPManager(),
133
- "export_chat": GradioPaLMChatPPManager(),
134
  }, # chat_state
135
  "setting_chat", # chat_mode
136
 
 
10
  genres, places, moods, jobs, random_names, default_character_images
11
  )
12
 
13
+ from modules import ImageMaker
14
+ from modules.llms import get_llm_factory
 
15
 
16
  from interfaces import utils
17
 
 
63
  name, age, personality, job,
64
  genre, place, mood, creative_mode
65
  ):
66
+ # generate prompts for character image with LLM
67
  for _ in range(3):
68
  try:
69
  prompt, neg_prompt = img_maker.generate_character_prompts(name, age, job, keywords=[personality, genre, place, mood], creative_mode=creative_mode)
 
119
  ppm = chat_state[chat_mode]
120
  return chat_mode, ppm.build_uis()
121
 
122
+ def reset(llm_type="PaLM"):
123
+ factory = get_llm_factory(llm_type)
124
+ ui_pp_manager = factory.create_ui_pp_manager()
125
+
126
  return (
127
  [], # cursors
128
  0, # cur_cursor
129
 
130
  {
131
+ "setting_chat": ui_pp_manager,
132
+ "story_chat": ui_pp_manager,
133
+ "export_chat": ui_pp_manager,
134
  }, # chat_state
135
  "setting_chat", # chat_mode
136
 
interfaces/utils.py CHANGED
@@ -2,10 +2,9 @@ import copy
2
  import json
3
  import string
4
  import random
 
5
 
6
- from modules import (
7
- palmchat, palm_prompts,
8
- )
9
 
10
  from pingpong.context import CtxLastWindowStrategy
11
 
@@ -23,12 +22,14 @@ def add_side_character_to_export(
23
 
24
  return characters
25
 
26
- def add_side_character(enable, name, age, personality, job):
 
 
27
  cur_side_chars = 1
28
  prompt = ""
29
  for idx in range(len(enable)):
30
  if enable[idx]:
31
- prompt += palm_prompts['story_gen']['add_side_character'].format(
32
  cur_side_chars=cur_side_chars,
33
  name=name[idx],
34
  job=job[idx],
@@ -56,28 +57,38 @@ def parse_first_json_code_snippet(code_snippet):
56
  json_code_snippet = code_snippet[json_start_index + 7:json_end_index]
57
  json_parsed_string = json.loads(json_code_snippet, strict=False)
58
  finally:
 
 
59
  return json_parsed_string
60
 
61
- async def retry_until_valid_json(prompt, parameters=None):
62
  response_json = None
 
 
63
 
64
  for _ in range(3):
65
  try:
66
- response, response_txt = await palmchat.gen_text(prompt, mode="text", parameters=parameters)
 
 
67
  print(response_txt)
 
 
68
  except Exception as e:
69
- print("PaLM API has withheld a response due to content safety concerns. Retrying...")
70
  continue
71
 
72
  try:
73
  response_json = parse_first_json_code_snippet(response_txt)
74
- break
 
 
75
  except:
76
  print("Parsing JSON failed. Retrying...")
77
  pass
78
 
79
  if len(response.filters) > 0:
80
- raise ValueError("PaLM API has withheld a response due to content safety concerns.")
81
  elif response_json is None:
82
  print("=== Failed to generate valid JSON response. ===")
83
  print(response_txt)
@@ -90,17 +101,12 @@ def build_prompts(ppm, win_size=3):
90
  lws = CtxLastWindowStrategy(win_size)
91
  return lws(dummy_ppm)
92
 
93
- async def get_chat_response(prompt, ctx=None):
94
- parameters = {
95
- 'model': 'models/chat-bison-001',
96
- 'candidate_count': 1,
97
- 'context': "" if ctx is None else ctx,
98
- 'temperature': 1.0,
99
- 'top_k': 50,
100
- 'top_p': 0.9,
101
- }
102
 
103
- _, response_txt = await palmchat.gen_text(
104
  prompt,
105
  parameters=parameters
106
  )
 
2
  import json
3
  import string
4
  import random
5
+ import asyncio
6
 
7
+ from modules.llms import get_llm_factory
 
 
8
 
9
  from pingpong.context import CtxLastWindowStrategy
10
 
 
22
 
23
  return characters
24
 
25
+ def add_side_character(enable, name, age, personality, job, llm_type="PaLM"):
26
+ prompts = get_llm_factory(llm_type).create_prompt_manager().prompts
27
+
28
  cur_side_chars = 1
29
  prompt = ""
30
  for idx in range(len(enable)):
31
  if enable[idx]:
32
+ prompt += prompts['story_gen']['add_side_character'].format(
33
  cur_side_chars=cur_side_chars,
34
  name=name[idx],
35
  job=job[idx],
 
57
  json_code_snippet = code_snippet[json_start_index + 7:json_end_index]
58
  json_parsed_string = json.loads(json_code_snippet, strict=False)
59
  finally:
60
+ if json_parsed_string is None:
61
+ raise ValueError('No JSON code snippet found in string.')
62
  return json_parsed_string
63
 
64
+ async def retry_until_valid_json(prompt, parameters=None, llm_type="PaLM"):
65
  response_json = None
66
+ factory = get_llm_factory(llm_type)
67
+ llm_service = factory.create_llm_service()
68
 
69
  for _ in range(3):
70
  try:
71
+ response, response_txt = await asyncio.wait_for(llm_service.gen_text(prompt, mode="text", parameters=parameters),
72
+ timeout=10)
73
+
74
  print(response_txt)
75
+ except asyncio.TimeoutError:
76
+ raise TimeoutError(f"The response time for {llm_type} API exceeded the limit.")
77
  except Exception as e:
78
+ print(f"{llm_type} API has encountered an error. Retrying...")
79
  continue
80
 
81
  try:
82
  response_json = parse_first_json_code_snippet(response_txt)
83
+ if not response_json:
84
+ print("Parsing JSON failed. Retrying...")
85
+ continue
86
  except:
87
  print("Parsing JSON failed. Retrying...")
88
  pass
89
 
90
  if len(response.filters) > 0:
91
+ raise ValueError(f"{llm_type} API has withheld a response due to content safety concerns.")
92
  elif response_json is None:
93
  print("=== Failed to generate valid JSON response. ===")
94
  print(response_txt)
 
101
  lws = CtxLastWindowStrategy(win_size)
102
  return lws(dummy_ppm)
103
 
104
+ async def get_chat_response(prompt, ctx=None, llm_type="PaLM"):
105
+ factory = get_llm_factory(llm_type)
106
+ llm_service = factory.create_llm_service()
107
+ parameters = llm_service.make_params(mode="chat", temperature=1.0, top_k=50, top_p=0.9)
 
 
 
 
 
108
 
109
+ _, response_txt = await llm_service.gen_text(
110
  prompt,
111
  parameters=parameters
112
  )
klF8Anime2Fp16.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e9ed949371dba2dd8e7d57d6f87cfe2d9e7b71062bad8a235fe74e91149a8573
3
- size 167333131
 
 
 
 
landscapeAnimePro_v20Inspiration.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f62f8870cf33daf414dc06b606c946062ec9ed8f3d5b2b566813b068a1686288
3
- size 4244098926
 
 
 
 
modules/__init__.py CHANGED
@@ -1,11 +1,5 @@
1
  from .image_maker import ImageMaker
2
  from .music_maker import MusicMaker
3
- from .palmchat import (
4
- PaLMChatPromptFmt,
5
- PaLMChatPPManager,
6
- GradioPaLMChatPPManager,
7
- palm_prompts,
8
- )
9
  from .utils import (
10
  merge_video,
11
  )
 
1
  from .image_maker import ImageMaker
2
  from .music_maker import MusicMaker
 
 
 
 
 
 
3
  from .utils import (
4
  merge_video,
5
  )
modules/image_maker.py CHANGED
@@ -21,13 +21,8 @@ from diffusers import (
21
  DEISMultistepScheduler,
22
  )
23
 
24
- from .utils import (
25
- set_all_seeds,
26
- )
27
- from .palmchat import (
28
- palm_prompts,
29
- gen_text,
30
- )
31
 
32
  _gpus = 0
33
 
@@ -62,6 +57,7 @@ class ImageMaker:
62
  safety (bool, optional): Whether to use the safety checker. Defaults to True.
63
  variant (str, optional): Variant of the model. Defaults to None.
64
  from_hf (bool, optional): Whether to load the model from HuggingFace. Defaults to False.
 
65
  device (str, optional): Device to use for the model. Defaults to None.
66
  """
67
 
@@ -169,7 +165,9 @@ class ImageMaker:
169
 
170
  def generate_character_prompts(self, character_name: str, age: str, job: str,
171
  keywords: list[str] = None,
172
- creative_mode: Literal['sd character', 'cartoon', 'realistic'] = 'cartoon') -> tuple[str, str]:
 
 
173
  """Generate positive and negative prompts for a character based on given attributes.
174
 
175
  Args:
@@ -177,24 +175,29 @@ class ImageMaker:
177
  age (str): Age of the character.
178
  job (str): The profession or job of the character.
179
  keywords (list[str]): List of descriptive words for the character.
 
 
180
 
181
  Returns:
182
  tuple[str, str]: A tuple of positive and negative prompts.
183
  """
 
 
 
184
 
185
  positive = "" # add static prompt for character if needed (e.g. "chibi, cute, anime")
186
- negative = palm_prompts['image_gen']['neg_prompt']
187
 
188
- # Generate prompts with PaLM
189
- t = palm_prompts['image_gen']['character']['gen_prompt']
190
- q = palm_prompts['image_gen']['character']['query']
191
  query_string = t.format(input=q.format(character_name=character_name,
192
  job=job,
193
  age=age,
194
  keywords=', '.join(keywords) if keywords else 'Nothing'))
195
  try:
196
  response, response_txt = asyncio.run(asyncio.wait_for(
197
- gen_text(query_string, mode="text", use_filter=False),
198
  timeout=10)
199
  )
200
  except asyncio.TimeoutError:
@@ -219,7 +222,9 @@ class ImageMaker:
219
 
220
 
221
  def generate_background_prompts(self, genre:str, place:str, mood:str,
222
- title:str, chapter_title:str, chapter_plot:str) -> tuple[str, str]:
 
 
223
  """Generate positive and negative prompts for a background image based on given attributes.
224
 
225
  Args:
@@ -229,17 +234,21 @@ class ImageMaker:
229
  title (str): Title of the story.
230
  chapter_title (str): Title of the chapter.
231
  chapter_plot (str): Plot of the chapter.
 
232
 
233
  Returns:
234
  tuple[str, str]: A tuple of positive and negative prompts.
235
  """
 
 
 
236
 
237
  positive = "painting+++, anime+, catoon, watercolor, wallpaper, text---" # add static prompt for background if needed (e.g. "chibi, cute, anime")
238
- negative = "realistic, human, character, people, photograph, 3d render, blurry, grayscale, oversaturated, " + palm_prompts['image_gen']['neg_prompt']
239
 
240
  # Generate prompts with PaLM
241
- t = palm_prompts['image_gen']['background']['gen_prompt']
242
- q = palm_prompts['image_gen']['background']['query']
243
  query_string = t.format(input=q.format(genre=genre,
244
  place=place,
245
  mood=mood,
@@ -248,7 +257,7 @@ class ImageMaker:
248
  chapter_plot=chapter_plot))
249
  try:
250
  response, response_txt = asyncio.run(asyncio.wait_for(
251
- gen_text(query_string, mode="text", use_filter=False),
252
  timeout=10)
253
  )
254
  except asyncio.TimeoutError:
 
21
  DEISMultistepScheduler,
22
  )
23
 
24
+ from .utils import set_all_seeds
25
+ from modules.llms import get_llm_factory
 
 
 
 
 
26
 
27
  _gpus = 0
28
 
 
57
  safety (bool, optional): Whether to use the safety checker. Defaults to True.
58
  variant (str, optional): Variant of the model. Defaults to None.
59
  from_hf (bool, optional): Whether to load the model from HuggingFace. Defaults to False.
60
+ llm_type (str, optional): Type of the LLM. Defaults to 'PaLM'.
61
  device (str, optional): Device to use for the model. Defaults to None.
62
  """
63
 
 
165
 
166
  def generate_character_prompts(self, character_name: str, age: str, job: str,
167
  keywords: list[str] = None,
168
+ creative_mode: Literal['sd character', 'cartoon', 'realistic'] = 'cartoon',
169
+ llm_type: str = 'PaLM',
170
+ ) -> tuple[str, str]:
171
  """Generate positive and negative prompts for a character based on given attributes.
172
 
173
  Args:
 
175
  age (str): Age of the character.
176
  job (str): The profession or job of the character.
177
  keywords (list[str]): List of descriptive words for the character.
178
+ creative_mode (Literal['sd character', 'cartoon', 'realistic']): Creative mode for the character.
179
+ llm_type (str, optional): Type of the LLM. Defaults to 'PaLM'.
180
 
181
  Returns:
182
  tuple[str, str]: A tuple of positive and negative prompts.
183
  """
184
+ factory = get_llm_factory(llm_type)
185
+ prompt_manager = factory.create_prompt_manager()
186
+ llm_service = factory.create_llm_service()
187
 
188
  positive = "" # add static prompt for character if needed (e.g. "chibi, cute, anime")
189
+ negative = prompt_manager.prompts['image_gen']['neg_prompt']
190
 
191
+ # Generate prompts with LLM
192
+ t = prompt_manager.prompts['image_gen']['character']['gen_prompt']
193
+ q = prompt_manager.prompts['image_gen']['character']['query']
194
  query_string = t.format(input=q.format(character_name=character_name,
195
  job=job,
196
  age=age,
197
  keywords=', '.join(keywords) if keywords else 'Nothing'))
198
  try:
199
  response, response_txt = asyncio.run(asyncio.wait_for(
200
+ llm_service.gen_text(query_string, mode="text", use_filter=False),
201
  timeout=10)
202
  )
203
  except asyncio.TimeoutError:
 
222
 
223
 
224
  def generate_background_prompts(self, genre:str, place:str, mood:str,
225
+ title:str, chapter_title:str, chapter_plot:str,
226
+ llm_type: str = 'PaLM',
227
+ ) -> tuple[str, str]:
228
  """Generate positive and negative prompts for a background image based on given attributes.
229
 
230
  Args:
 
234
  title (str): Title of the story.
235
  chapter_title (str): Title of the chapter.
236
  chapter_plot (str): Plot of the chapter.
237
+ llm_type (str, optional): Type of the LLM. Defaults to 'PaLM'.
238
 
239
  Returns:
240
  tuple[str, str]: A tuple of positive and negative prompts.
241
  """
242
+ factory = get_llm_factory(llm_type)
243
+ prompt_manager = factory.create_prompt_manager()
244
+ llm_service = factory.create_llm_service()
245
 
246
  positive = "painting+++, anime+, catoon, watercolor, wallpaper, text---" # add static prompt for background if needed (e.g. "chibi, cute, anime")
247
+ negative = "realistic, human, character, people, photograph, 3d render, blurry, grayscale, oversaturated, " + prompt_manager.prompts['image_gen']['neg_prompt']
248
 
249
  # Generate prompts with PaLM
250
+ t = prompt_manager.prompts['image_gen']['background']['gen_prompt']
251
+ q = prompt_manager.prompts['image_gen']['background']['query']
252
  query_string = t.format(input=q.format(genre=genre,
253
  place=place,
254
  mood=mood,
 
257
  chapter_plot=chapter_plot))
258
  try:
259
  response, response_txt = asyncio.run(asyncio.wait_for(
260
+ llm_service.gen_text(query_string, mode="text", use_filter=False),
261
  timeout=10)
262
  )
263
  except asyncio.TimeoutError:
modules/llms/__init__.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .llm_factory_abstracts import (
2
+ LLMFactory,
3
+ PromptFmt, PromptManager, PPManager, UIPPManager, LLMService
4
+ )
5
+
6
+ from .palm_service import (
7
+ PaLMFactory,
8
+ PaLMChatPromptFmt, PaLMPromptManager, PaLMChatPPManager, GradioPaLMChatPPManager, PaLMService,
9
+ )
10
+
11
+ from .utils import get_llm_factory
modules/llms/chatgpt_service.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import threading
3
+ import toml
4
+ from pathlib import Path
5
+
6
+ from pingpong import PingPong
7
+ from pingpong.pingpong import PPManager
8
+ from pingpong.pingpong import PromptFmt
9
+ from pingpong.pingpong import UIFmt
10
+ from pingpong.gradio import GradioChatUIFmt
11
+
12
+ from modules.llms import (
13
+ LLMFactory,
14
+ PromptFmt, PromptManager, PPManager, UIPPManager, LLMService
15
+ )
16
+
17
+ class ChatGPTFactory(LLMFactory):
18
+ def __init__(self):
19
+ pass
20
+
21
+ def create_prompt_format(self):
22
+ return ChatGPTChatPromptFmt()
23
+
24
+ def create_prompt_manager(self, prompts_path: str=None):
25
+ return ChatGPTPromptManager((prompts_path or Path('.') / 'prompts' / 'chatgpt_prompts.toml'))
26
+
27
+ def create_pp_manager(self):
28
+ return ChatGPTChatPPManager()
29
+
30
+ def create_ui_pp_manager(self):
31
+ return GradioChatGPTChatPPManager()
32
+
33
+ def create_llm_service(self):
34
+ return ChatGPTService()
35
+
36
+
37
+ class ChatGPTChatPromptFmt(PromptFmt):
38
+ @classmethod
39
+ def ctx(cls, context):
40
+ pass
41
+
42
+ @classmethod
43
+ def prompt(cls, pingpong, truncate_size):
44
+ pass
45
+
46
+
47
+ class ChatGPTPromptManager(PromptManager):
48
+ _instance = None
49
+ _lock = threading.Lock()
50
+ _prompts = None
51
+
52
+ def __new__(cls, prompts_path):
53
+ if cls._instance is None:
54
+ with cls._lock:
55
+ if not cls._instance:
56
+ cls._instance = super(ChatGPTPromptManager, cls).__new__(cls)
57
+ cls._instance.load_prompts(prompts_path)
58
+ return cls._instance
59
+
60
+ def load_prompts(self, prompts_path):
61
+ self._prompts_path = prompts_path
62
+ self.reload_prompts()
63
+
64
+ def reload_prompts(self):
65
+ assert self.prompts_path, "Prompt path is missing."
66
+ self._prompts = toml.load(self.prompts_path)
67
+
68
+ @property
69
+ def prompts_path(self):
70
+ return self._prompts_path
71
+
72
+ @prompts_path.setter
73
+ def prompts_path(self, prompts_path):
74
+ self._prompts_path = prompts_path
75
+ self.reload_prompts()
76
+
77
+ @property
78
+ def prompts(self):
79
+ if self._prompts is None:
80
+ self.load_prompts()
81
+ return self._prompts
82
+
83
+
84
+ class ChatGPTChatPPManager(PPManager):
85
+ def build_prompts(self, from_idx: int=0, to_idx: int=-1, fmt: PromptFmt=None, truncate_size: int=None):
86
+ pass
87
+
88
+
89
+ class GradioChatGPTChatPPManager(UIPPManager, ChatGPTChatPPManager):
90
+ def build_uis(self, from_idx: int=0, to_idx: int=-1, fmt: UIFmt=GradioChatUIFmt):
91
+ pass
92
+
93
+ class ChatGPTService(LLMService):
94
+ def make_params(self, mode="chat",
95
+ temperature=None,
96
+ candidate_count=None,
97
+ top_k=None,
98
+ top_p=None,
99
+ max_output_tokens=None,
100
+ use_filter=True):
101
+ pass
102
+
103
+ async def gen_text(
104
+ self,
105
+ prompt,
106
+ mode="chat", #chat or text
107
+ parameters=None,
108
+ use_filter=True
109
+ ):
110
+ pass
modules/llms/llama_service.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import threading
3
+ import toml
4
+ from pathlib import Path
5
+
6
+ from pingpong import PingPong
7
+ from pingpong.pingpong import PPManager
8
+ from pingpong.pingpong import PromptFmt
9
+ from pingpong.pingpong import UIFmt
10
+ from pingpong.gradio import GradioChatUIFmt
11
+
12
+ from modules.llms import (
13
+ LLMFactory,
14
+ PromptFmt, PromptManager, PPManager, UIPPManager, LLMService
15
+ )
16
+
17
+ class LLaMAFactory(LLMFactory):
18
+ def __init__(self):
19
+ pass
20
+
21
+ def create_prompt_format(self):
22
+ return LLaMAChatPromptFmt()
23
+
24
+ def create_prompt_manager(self, prompts_path: str=None):
25
+ return LLaMAPromptManager((prompts_path or Path('.') / 'prompts' / 'llama_prompts.toml'))
26
+
27
+ def create_pp_manager(self):
28
+ return LLaMAChatPPManager()
29
+
30
+ def create_ui_pp_manager(self):
31
+ return GradioLLaMAChatPPManager()
32
+
33
+ def create_llm_service(self):
34
+ return LLaMAService()
35
+
36
+
37
+ class LLaMAChatPromptFmt(PromptFmt):
38
+ @classmethod
39
+ def ctx(cls, context):
40
+ pass
41
+
42
+ @classmethod
43
+ def prompt(cls, pingpong, truncate_size):
44
+ pass
45
+
46
+
47
+ class LLaMAPromptManager(PromptManager):
48
+ _instance = None
49
+ _lock = threading.Lock()
50
+ _prompts = None
51
+
52
+ def __new__(cls, prompts_path):
53
+ if cls._instance is None:
54
+ with cls._lock:
55
+ if not cls._instance:
56
+ cls._instance = super(LLaMAPromptManager, cls).__new__(cls)
57
+ cls._instance.load_prompts(prompts_path)
58
+ return cls._instance
59
+
60
+ def load_prompts(self, prompts_path):
61
+ self._prompts_path = prompts_path
62
+ self.reload_prompts()
63
+
64
+ def reload_prompts(self):
65
+ assert self.prompts_path, "Prompt path is missing."
66
+ self._prompts = toml.load(self.prompts_path)
67
+
68
+ @property
69
+ def prompts_path(self):
70
+ return self._prompts_path
71
+
72
+ @prompts_path.setter
73
+ def prompts_path(self, prompts_path):
74
+ self._prompts_path = prompts_path
75
+ self.reload_prompts()
76
+
77
+ @property
78
+ def prompts(self):
79
+ if self._prompts is None:
80
+ self.load_prompts()
81
+ return self._prompts
82
+
83
+
84
+ class LLaMAChatPPManager(PPManager):
85
+ def build_prompts(self, from_idx: int=0, to_idx: int=-1, fmt: PromptFmt=None, truncate_size: int=None):
86
+ pass
87
+
88
+
89
+ class GradioLLaMAChatPPManager(UIPPManager, LLaMAChatPPManager):
90
+ def build_uis(self, from_idx: int=0, to_idx: int=-1, fmt: UIFmt=GradioChatUIFmt):
91
+ pass
92
+
93
+ class LLaMAService(LLMService):
94
+ def make_params(self, mode="chat",
95
+ temperature=None,
96
+ candidate_count=None,
97
+ top_k=None,
98
+ top_p=None,
99
+ max_output_tokens=None,
100
+ use_filter=True):
101
+ pass
102
+
103
+ async def gen_text(
104
+ self,
105
+ prompt,
106
+ mode="chat", #chat or text
107
+ parameters=None,
108
+ use_filter=True
109
+ ):
110
+ pass
modules/llms/llm_factory_abstracts.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from abc import ABCMeta, abstractmethod
2
+
3
+ class LLMFactory(metaclass=ABCMeta):
4
+ @abstractmethod
5
+ def create_prompt_format(self):
6
+ pass
7
+
8
+ @abstractmethod
9
+ def create_prompt_manager(self):
10
+ pass
11
+
12
+ @abstractmethod
13
+ def create_pp_manager(self):
14
+ pass
15
+
16
+ @abstractmethod
17
+ def create_ui_pp_manager(self):
18
+ pass
19
+
20
+ @abstractmethod
21
+ def create_llm_service(self):
22
+ pass
23
+
24
+
25
+ class PromptFmt(metaclass=ABCMeta):
26
+ @classmethod
27
+ @abstractmethod
28
+ def ctx(cls, context):
29
+ pass
30
+
31
+ @classmethod
32
+ @abstractmethod
33
+ def prompt(cls, pingpong, truncate_size):
34
+ pass
35
+
36
+
37
+ class PromptManager(metaclass=ABCMeta):
38
+ @abstractmethod
39
+ def load_prompts(self):
40
+ pass
41
+
42
+ @abstractmethod
43
+ def reload_prompts(self):
44
+ pass
45
+
46
+ @property
47
+ @abstractmethod
48
+ def prompts_path(self):
49
+ pass
50
+
51
+ @prompts_path.setter
52
+ @abstractmethod
53
+ def prompts_path(self, prompts_path):
54
+ pass
55
+
56
+ @property
57
+ @abstractmethod
58
+ def prompts(self):
59
+ pass
60
+
61
+
62
+ class PPManager(metaclass=ABCMeta):
63
+ @abstractmethod
64
+ def build_prompts(self, from_idx: int=0, to_idx: int=-1, fmt: PromptFmt=None, truncate_size: int=None):
65
+ pass
66
+
67
+
68
+ class UIPPManager(PPManager, metaclass=ABCMeta):
69
+ @abstractmethod
70
+ def build_uis(self, from_idx: int=0, to_idx: int=-1):
71
+ pass
72
+
73
+
74
+ class LLMService(metaclass=ABCMeta):
75
+ @abstractmethod
76
+ def make_params(self, mode="chat",
77
+ temperature=None,
78
+ candidate_count=None,
79
+ top_k=None,
80
+ top_p=None,
81
+ max_output_tokens=None,
82
+ use_filter=True):
83
+ pass
84
+
85
+ @abstractmethod
86
+ async def gen_text(self, prompt, mode="chat", parameters=None, use_filter=True):
87
+ pass
modules/llms/palm_service.py ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import threading
3
+ import toml
4
+ from pathlib import Path
5
+ import google.generativeai as palm_api
6
+
7
+ from pingpong import PingPong
8
+ from pingpong.pingpong import PPManager
9
+ from pingpong.pingpong import PromptFmt
10
+ from pingpong.pingpong import UIFmt
11
+ from pingpong.gradio import GradioChatUIFmt
12
+
13
+ from modules.llms import (
14
+ LLMFactory,
15
+ PromptFmt, PromptManager, PPManager, UIPPManager, LLMService
16
+ )
17
+
18
+ class PaLMFactory(LLMFactory):
19
+ _palm_api_key = None
20
+
21
+ def __init__(self, palm_api_key=None):
22
+ if not PaLMFactory._palm_api_key:
23
+ PaLMFactory.load_palm_api_key()
24
+ assert PaLMFactory._palm_api_key, "PaLM API Key is missing."
25
+ palm_api.configure(api_key=PaLMFactory._palm_api_key)
26
+
27
+ def create_prompt_format(self):
28
+ return PaLMChatPromptFmt()
29
+
30
+ def create_prompt_manager(self, prompts_path: str=None):
31
+ return PaLMPromptManager((prompts_path or Path('.') / 'prompts' / 'palm_prompts.toml'))
32
+
33
+ def create_pp_manager(self):
34
+ return PaLMChatPPManager()
35
+
36
+ def create_ui_pp_manager(self):
37
+ return GradioPaLMChatPPManager()
38
+
39
+ def create_llm_service(self):
40
+ return PaLMService()
41
+
42
+ @classmethod
43
+ def load_palm_api_key(cls, palm_api_key: str=None):
44
+ if palm_api_key:
45
+ cls._palm_api_key = palm_api_key
46
+ else:
47
+ palm_api_key = os.getenv("PALM_API_KEY")
48
+
49
+ if palm_api_key is None:
50
+ with open('.palm_api_key.txt', 'r') as file:
51
+ palm_api_key = file.read().strip()
52
+
53
+ if not palm_api_key:
54
+ raise ValueError("PaLM API Key is missing.")
55
+ cls._palm_api_key = palm_api_key
56
+
57
+ @property
58
+ def palm_api_key(self):
59
+ return PaLMFactory._palm_api_key
60
+
61
+ @palm_api_key.setter
62
+ def palm_api_key(self, palm_api_key: str):
63
+ assert palm_api_key, "PaLM API Key is missing."
64
+ PaLMFactory._palm_api_key = palm_api_key
65
+ palm_api.configure(api_key=PaLMFactory._palm_api_key)
66
+
67
+
68
+ class PaLMChatPromptFmt(PromptFmt):
69
+ @classmethod
70
+ def ctx(cls, context):
71
+ pass
72
+
73
+ @classmethod
74
+ def prompt(cls, pingpong, truncate_size):
75
+ ping = pingpong.ping[:truncate_size]
76
+ pong = pingpong.pong
77
+
78
+ if pong is None or pong.strip() == "":
79
+ return [
80
+ {
81
+ "author": "USER",
82
+ "content": ping
83
+ },
84
+ ]
85
+ else:
86
+ pong = pong[:truncate_size]
87
+
88
+ return [
89
+ {
90
+ "author": "USER",
91
+ "content": ping
92
+ },
93
+ {
94
+ "author": "AI",
95
+ "content": pong
96
+ },
97
+ ]
98
+
99
+
100
+ class PaLMPromptManager(PromptManager):
101
+ _instance = None
102
+ _lock = threading.Lock()
103
+ _prompts = None
104
+
105
+ def __new__(cls, prompts_path):
106
+ if cls._instance is None:
107
+ with cls._lock:
108
+ if not cls._instance:
109
+ cls._instance = super(PaLMPromptManager, cls).__new__(cls)
110
+ cls._instance.load_prompts(prompts_path)
111
+ return cls._instance
112
+
113
+ def load_prompts(self, prompts_path):
114
+ self._prompts_path = prompts_path
115
+ self.reload_prompts()
116
+
117
+ def reload_prompts(self):
118
+ assert self.prompts_path, "Prompt path is missing."
119
+ self._prompts = toml.load(self.prompts_path)
120
+
121
+ @property
122
+ def prompts_path(self):
123
+ return self._prompts_path
124
+
125
+ @prompts_path.setter
126
+ def prompts_path(self, prompts_path):
127
+ self._prompts_path = prompts_path
128
+ self.reload_prompts()
129
+
130
+ @property
131
+ def prompts(self):
132
+ if self._prompts is None:
133
+ self.load_prompts()
134
+ return self._prompts
135
+
136
+
137
+ class PaLMChatPPManager(PPManager):
138
+ def build_prompts(self, from_idx: int=0, to_idx: int=-1, fmt: PromptFmt=None, truncate_size: int=None):
139
+ if fmt is None:
140
+ factory = PaLMFactory()
141
+ fmt = factory.create_prompt_format()
142
+
143
+ results = []
144
+
145
+ if to_idx == -1 or to_idx >= len(self.pingpongs):
146
+ to_idx = len(self.pingpongs)
147
+
148
+ for idx, pingpong in enumerate(self.pingpongs[from_idx:to_idx]):
149
+ results += fmt.prompt(pingpong, truncate_size=truncate_size)
150
+
151
+ return results
152
+
153
+
154
+ class GradioPaLMChatPPManager(UIPPManager, PaLMChatPPManager):
155
+ def build_uis(self, from_idx: int=0, to_idx: int=-1, fmt: UIFmt=GradioChatUIFmt):
156
+ if to_idx == -1 or to_idx >= len(self.pingpongs):
157
+ to_idx = len(self.pingpongs)
158
+
159
+ results = []
160
+
161
+ for pingpong in self.pingpongs[from_idx:to_idx]:
162
+ results.append(fmt.ui(pingpong))
163
+
164
+ return results
165
+
166
+ class PaLMService(LLMService):
167
+ def __init__(self):
168
+ self._default_parameters_text = {
169
+ 'model': 'models/text-bison-001',
170
+ 'temperature': 0.7,
171
+ 'candidate_count': 1,
172
+ 'top_k': 40,
173
+ 'top_p': 0.95,
174
+ 'max_output_tokens': 1024,
175
+ 'stop_sequences': [],
176
+ 'safety_settings': [{"category":"HARM_CATEGORY_DEROGATORY","threshold":1},
177
+ {"category":"HARM_CATEGORY_TOXICITY","threshold":1},
178
+ {"category":"HARM_CATEGORY_VIOLENCE","threshold":2},
179
+ {"category":"HARM_CATEGORY_SEXUAL","threshold":2},
180
+ {"category":"HARM_CATEGORY_MEDICAL","threshold":2},
181
+ {"category":"HARM_CATEGORY_DANGEROUS","threshold":2}],
182
+ }
183
+ self._default_parameters_chat = {
184
+ 'model': 'models/chat-bison-001',
185
+ 'temperature': 0.25,
186
+ 'candidate_count': 1,
187
+ 'top_k': 40,
188
+ 'top_p': 0.95,
189
+ }
190
+
191
+
192
+ def make_params(self, mode="chat",
193
+ temperature=None,
194
+ candidate_count=None,
195
+ top_k=None,
196
+ top_p=None,
197
+ max_output_tokens=None,
198
+ use_filter=True):
199
+ parameters = None
200
+
201
+ if mode == "chat":
202
+ parameters = self._default_parameters_chat.copy()
203
+ elif mode == "text":
204
+ parameters = self._default_parameters_text.copy()
205
+
206
+ if temperature is not None:
207
+ parameters['temperature'] = temperature
208
+ if candidate_count is not None:
209
+ parameters['candidate_count'] = candidate_count
210
+ if top_k is not None:
211
+ parameters['top_k'] = top_k
212
+ if max_output_tokens is not None and mode == "text":
213
+ parameters['max_output_tokens'] = max_output_tokens
214
+ if not use_filter and mode == "text":
215
+ for idx, _ in enumerate(parameters['safety_settings']):
216
+ parameters['safety_settings'][idx]['threshold'] = 4
217
+
218
+ return parameters
219
+
220
+
221
+ async def gen_text(
222
+ self,
223
+ prompt,
224
+ mode="chat", #chat or text
225
+ parameters=None,
226
+ use_filter=True
227
+ ):
228
+ if parameters is None:
229
+ temperature = 1.0
230
+ top_k = 40
231
+ top_p = 0.95
232
+ max_output_tokens = 1024
233
+
234
+ # default safety settings
235
+ safety_settings = [{"category":"HARM_CATEGORY_DEROGATORY","threshold":1},
236
+ {"category":"HARM_CATEGORY_TOXICITY","threshold":1},
237
+ {"category":"HARM_CATEGORY_VIOLENCE","threshold":2},
238
+ {"category":"HARM_CATEGORY_SEXUAL","threshold":2},
239
+ {"category":"HARM_CATEGORY_MEDICAL","threshold":2},
240
+ {"category":"HARM_CATEGORY_DANGEROUS","threshold":2}]
241
+ if not use_filter:
242
+ for idx, _ in enumerate(safety_settings):
243
+ safety_settings[idx]['threshold'] = 4
244
+
245
+ if mode == "chat":
246
+ parameters = {
247
+ 'model': 'models/chat-bison-001',
248
+ 'candidate_count': 1,
249
+ 'context': "",
250
+ 'temperature': temperature,
251
+ 'top_k': top_k,
252
+ 'top_p': top_p,
253
+ 'safety_settings': safety_settings,
254
+ }
255
+ else:
256
+ parameters = {
257
+ 'model': 'models/text-bison-001',
258
+ 'candidate_count': 1,
259
+ 'temperature': temperature,
260
+ 'top_k': top_k,
261
+ 'top_p': top_p,
262
+ 'max_output_tokens': max_output_tokens,
263
+ 'safety_settings': safety_settings,
264
+ }
265
+
266
+ try:
267
+ if mode == "chat":
268
+ response = await palm_api.chat_async(**parameters, messages=prompt)
269
+ else:
270
+ response = palm_api.generate_text(**parameters, prompt=prompt)
271
+ except:
272
+ raise EnvironmentError("PaLM API is not available.")
273
+
274
+ if use_filter and len(response.filters) > 0:
275
+ raise Exception("PaLM API has withheld a response due to content safety concerns.")
276
+ else:
277
+ if mode == "chat":
278
+ response_txt = response.last
279
+ else:
280
+ response_txt = response.result
281
+
282
+ return response, response_txt
modules/llms/utils.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from modules.llms import *
2
+
3
+ def get_llm_factory(llm_type: str) -> 'PaLM':
4
+ factory = None
5
+ if llm_type.lower() == 'palm':
6
+ factory = PaLMFactory()
7
+
8
+ return factory
modules/music_maker.py CHANGED
@@ -14,13 +14,8 @@ from audiocraft.models import MusicGen
14
  from audiocraft.data.audio import audio_write
15
  from pydub import AudioSegment
16
 
17
- from .utils import (
18
- set_all_seeds,
19
- )
20
- from .palmchat import (
21
- palm_prompts,
22
- gen_text,
23
- )
24
 
25
  class MusicMaker:
26
  # TODO: DocString...
@@ -93,7 +88,9 @@ class MusicMaker:
93
 
94
 
95
  def generate_prompt(self, genre:str, place:str, mood:str,
96
- title:str, chapter_title:str, chapter_plot:str) -> str:
 
 
97
  """Generate a prompt for a background music based on given attributes.
98
 
99
  Args:
@@ -107,10 +104,13 @@ class MusicMaker:
107
  Returns:
108
  str: Generated prompt.
109
  """
 
 
 
110
 
111
  # Generate prompts with PaLM
112
- t = palm_prompts['music_gen']['gen_prompt']
113
- q = palm_prompts['music_gen']['query']
114
  query_string = t.format(input=q.format(genre=genre,
115
  place=place,
116
  mood=mood,
@@ -119,7 +119,7 @@ class MusicMaker:
119
  chapter_plot=chapter_plot))
120
  try:
121
  response, response_txt = asyncio.run(asyncio.wait_for(
122
- gen_text(query_string, mode="text", use_filter=False),
123
  timeout=10)
124
  )
125
  except asyncio.TimeoutError:
 
14
  from audiocraft.data.audio import audio_write
15
  from pydub import AudioSegment
16
 
17
+ from .utils import set_all_seeds
18
+ from modules.llms import get_llm_factory
 
 
 
 
 
19
 
20
  class MusicMaker:
21
  # TODO: DocString...
 
88
 
89
 
90
  def generate_prompt(self, genre:str, place:str, mood:str,
91
+ title:str, chapter_title:str, chapter_plot:str,
92
+ llm_type:str="PaLM",
93
+ ) -> str:
94
  """Generate a prompt for a background music based on given attributes.
95
 
96
  Args:
 
104
  Returns:
105
  str: Generated prompt.
106
  """
107
+ factory = get_llm_factory(llm_type)
108
+ prompt_manager = factory.create_prompt_manager()
109
+ llm_service = factory.create_llm_service()
110
 
111
  # Generate prompts with PaLM
112
+ t = prompt_manager.prompts['music_gen']['gen_prompt']
113
+ q = prompt_manager.prompts['music_gen']['query']
114
  query_string = t.format(input=q.format(genre=genre,
115
  place=place,
116
  mood=mood,
 
119
  chapter_plot=chapter_plot))
120
  try:
121
  response, response_txt = asyncio.run(asyncio.wait_for(
122
+ llm_service.gen_text(query_string, mode="text", use_filter=False),
123
  timeout=10)
124
  )
125
  except asyncio.TimeoutError:
modules/palmchat.py CHANGED
@@ -21,10 +21,11 @@ palm_prompts = toml.load(Path('.') / 'assets' / 'palm_prompts.toml')
21
  class PaLMChatPromptFmt(PromptFmt):
22
  @classmethod
23
  def ctx(cls, context):
24
- pass
25
 
26
  @classmethod
27
  def prompt(cls, pingpong, truncate_size):
 
28
  ping = pingpong.ping[:truncate_size]
29
  pong = pingpong.pong
30
 
@@ -51,6 +52,7 @@ class PaLMChatPromptFmt(PromptFmt):
51
 
52
  class PaLMChatPPManager(PPManager):
53
  def build_prompts(self, from_idx: int=0, to_idx: int=-1, fmt: PromptFmt=PaLMChatPromptFmt, truncate_size: int=None):
 
54
  results = []
55
 
56
  if to_idx == -1 or to_idx >= len(self.pingpongs):
@@ -63,6 +65,7 @@ class PaLMChatPPManager(PPManager):
63
 
64
  class GradioPaLMChatPPManager(PaLMChatPPManager):
65
  def build_uis(self, from_idx: int=0, to_idx: int=-1, fmt: UIFmt=GradioChatUIFmt):
 
66
  if to_idx == -1 or to_idx >= len(self.pingpongs):
67
  to_idx = len(self.pingpongs)
68
 
@@ -79,6 +82,7 @@ async def gen_text(
79
  parameters=None,
80
  use_filter=True
81
  ):
 
82
  if parameters is None:
83
  temperature = 1.0
84
  top_k = 40
 
21
  class PaLMChatPromptFmt(PromptFmt):
22
  @classmethod
23
  def ctx(cls, context):
24
+ warnings.warn("The 'palmchat' is deprecated and will not be supported in future versions.", DeprecationWarning, stacklevel=2)
25
 
26
  @classmethod
27
  def prompt(cls, pingpong, truncate_size):
28
+ warnings.warn("The 'palmchat' is deprecated and will not be supported in future versions.", DeprecationWarning, stacklevel=2)
29
  ping = pingpong.ping[:truncate_size]
30
  pong = pingpong.pong
31
 
 
52
 
53
  class PaLMChatPPManager(PPManager):
54
  def build_prompts(self, from_idx: int=0, to_idx: int=-1, fmt: PromptFmt=PaLMChatPromptFmt, truncate_size: int=None):
55
+ warnings.warn("The 'palmchat' is deprecated and will not be supported in future versions.", DeprecationWarning, stacklevel=2)
56
  results = []
57
 
58
  if to_idx == -1 or to_idx >= len(self.pingpongs):
 
65
 
66
  class GradioPaLMChatPPManager(PaLMChatPPManager):
67
  def build_uis(self, from_idx: int=0, to_idx: int=-1, fmt: UIFmt=GradioChatUIFmt):
68
+ warnings.warn("The 'palmchat' is deprecated and will not be supported in future versions.", DeprecationWarning, stacklevel=2)
69
  if to_idx == -1 or to_idx >= len(self.pingpongs):
70
  to_idx = len(self.pingpongs)
71
 
 
82
  parameters=None,
83
  use_filter=True
84
  ):
85
+ warnings.warn("The 'palmchat' is deprecated and will not be supported in future versions.", DeprecationWarning, stacklevel=2)
86
  if parameters is None:
87
  temperature = 1.0
88
  top_k = 40
modules/utils.py CHANGED
@@ -12,7 +12,6 @@ from PIL import ImageFont
12
 
13
  import torch
14
 
15
- import google.generativeai as palm_api
16
 
17
  def set_all_seeds(random_seed: int) -> None:
18
  # TODO: DocString...
@@ -26,22 +25,6 @@ def set_all_seeds(random_seed: int) -> None:
26
  print(f"Using seed {random_seed}")
27
 
28
 
29
- def get_palm_api_key() -> str:
30
- palm_api_key = os.getenv("PALM_API_KEY")
31
-
32
- if palm_api_key is None:
33
- with open('.palm_api_key.txt', 'r') as file:
34
- palm_api_key = file.read().strip()
35
-
36
- if not palm_api_key:
37
- raise ValueError("PaLM API Key is missing.")
38
- return palm_api_key
39
-
40
-
41
- def set_palm_api_key(palm_api_key:str = None) -> None:
42
- palm_api.configure(api_key=(palm_api_key or get_palm_api_key()))
43
-
44
-
45
  def merge_video(image_path: str, audio_path: str, story_title:str = None) -> str:
46
  output_filename = Path('.') / 'outputs' / str(uuid.uuid4())
47
  output_filename = str(output_filename.with_suffix('.mp4'))
 
12
 
13
  import torch
14
 
 
15
 
16
  def set_all_seeds(random_seed: int) -> None:
17
  # TODO: DocString...
 
25
  print(f"Using seed {random_seed}")
26
 
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  def merge_video(image_path: str, audio_path: str, story_title:str = None) -> str:
29
  output_filename = Path('.') / 'outputs' / str(uuid.uuid4())
30
  output_filename = str(output_filename.with_suffix('.mp4'))
prompts/chatgpt_prompts.toml ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [story_gen]
2
+ add_side_character = """side character #{cur_side_chars}
3
+ - name: {name},
4
+ - job: {job},
5
+ - age: {age},
6
+ - personality: {personality}
7
+
8
+ """
9
+ first_story_gen = """Write the first three paragraphs of a novel as much detailed as possible. They should be based on the background information. Blend 5W1H principle into the stories as a plain text. Don't let the paragraphs end the whole story.
10
+
11
+ background information:
12
+ - genre: {genre}
13
+ - where: {place}
14
+ - mood: {mood}
15
+
16
+ main character
17
+ - name: {main_char_name}
18
+ - job: {main_char_job}
19
+ - age: {main_char_age}
20
+ - personality: {main_char_personality}
21
+ {side_char_placeholder}
22
+ Fill in the following JSON output format:
23
+ {{"paragraphs":"string"}}
24
+
25
+ Write the JSON output:
26
+ """
27
+ next_story_gen = """Write the next paragraphs. The next paragraphs should be determined by an option and well connected to the current stories.
28
+
29
+ background information:
30
+ - genre: {genre}
31
+ - where: {place}
32
+ - mood: {mood}
33
+
34
+ main character
35
+ - name: {main_char_name}
36
+ - job: {main_char_job}
37
+ - age: {main_char_age}
38
+ - personality: {main_char_personality}
39
+ {side_char_placeholder}
40
+ Fill in the following JSON output format:
41
+ {{"paragraphs":"string"}}
42
+
43
+ stories
44
+ {stories}
45
+
46
+ option to the next stories: {action}
47
+
48
+ Write the JSON output:
49
+ """
50
+ actions_gen = """Suggest the 20 options to drive the stories to the next based on the information below.
51
+
52
+ background information:
53
+ - genre: {genre}
54
+ - where: {place}
55
+ - mood: {mood}
56
+
57
+ main character
58
+ - name: {main_char_name}
59
+ - job: {main_char_job}
60
+ - age: {main_char_age}
61
+ - personality: {main_char_personality}
62
+ {side_char_placeholder}
63
+ Fill in the following JSON output format:
64
+ {{"options":["string1", "string2", "string3"]}}
65
+
66
+ summary of the story
67
+ {summary}
68
+
69
+ Write the JSON output:
70
+ """
71
+ summarize = """Summarize the text below
72
+
73
+ {stories}
74
+
75
+ """
76
+ title="""what would be the title of the story below? be specific and creative.
77
+
78
+ {stories}
79
+
80
+ title: """
81
+
82
+ [chat_gen]
83
+ chapter_title_ctx = """
84
+ chapter{title_idx} {{
85
+ title: {chapter_title},
86
+ plot: {chapter_plot}
87
+ }}
88
+ """
89
+ add_side_character = """side character{cur_side_chars}: {{
90
+ name: {name},
91
+ job: {job},
92
+ age: {age},
93
+ personality: {personality}
94
+ }}
95
+
96
+ """
97
+ chat_context = """You are a professional writing advisor, especially specialized in developing ideas on plotting stories and creating characters. I provide genre, where, and mood along with the rough description of one main character and three side characters.
98
+
99
+ Give creative but not too long responses based on the following information.
100
+
101
+ genre: {genre}
102
+ where: {place}
103
+ mood: {mood}
104
+
105
+ main character: {{
106
+ name: {name1},
107
+ job: {job1},
108
+ age: {age1},
109
+ personality: {personality1}
110
+ }}
111
+ {side_char_placeholder}
112
+ {chapter_title_placeholder}
113
+ """
114
+
115
+ [plot_gen]
116
+ main_plot_gen="""Write a title and an outline of a novel based on the background information below in Ronald Tobias's plot theory. The outline should follow the "rising action", "crisis", "climax", "falling action", and "denouement" plot types. Each should be filled with a VERY detailed and descriptive at least two paragraphs of string. Randomly choose if the story goes optimistic or tragic.
117
+
118
+ background information:
119
+ - genre: string
120
+ - where: string
121
+ - mood: string
122
+
123
+ main character
124
+ - name: string
125
+ - job: string
126
+ - age: string
127
+ - personality: string
128
+
129
+ JSON output:
130
+ {{
131
+ "title": "string",
132
+ "outline": {{
133
+ "rising action": "paragraphs of string",
134
+ "crisis": "paragraphs of string",
135
+ "climax": "paragraphs of string",
136
+ "falling action": "paragraphs of string",
137
+ "denouement": "paragraphs of string"
138
+ }}
139
+ }}
140
+
141
+ background information:
142
+ - genre: {genre}
143
+ - where: {place}
144
+ - mood: {mood}
145
+
146
+ main character
147
+ - name: {main_char_name}
148
+ - job: {main_char_job}
149
+ - age: {main_char_age}
150
+ - personality: {main_char_personality}
151
+ {side_char_placeholder}
152
+ JSON output:
153
+ """
154
+ first_story_gen="""Write the chapter title and the first few paragraphs of the "rising action" plot based on the background information below in Ronald Tobias's plot theory. Also, suggest three choosable actions to drive current story in different directions. The first few paragraphs should be filled with a VERY MUCH detailed and descriptive at least two paragraphs of string.
155
+
156
+ REMEMBER the first few paragraphs should not end the whole story and allow leaway for the next paragraphs to come.
157
+ The whole story SHOULD stick to the "rising action -> crisis -> climax -> falling action -> denouement" flow, so REMEMBER not to write anything mentioned from the next plots of crisis, climax, falling action, and denouement yet.
158
+
159
+ background information:
160
+ - genre: string
161
+ - where: string
162
+ - mood: string
163
+
164
+ main character
165
+ - name: string
166
+ - job: string
167
+ - age: string
168
+ - personality: string
169
+
170
+ overall outline
171
+ - title: string
172
+ - rising action: string
173
+ - crisis: string
174
+ - climax: string
175
+ - falling action: string
176
+ - denouement: string
177
+
178
+ JSON output:
179
+ {{
180
+ "chapter_title": "string",
181
+ "paragraphs": ["string", "string", ...],
182
+ "actions": ["string", "string", "string"]
183
+ }}
184
+
185
+ background information:
186
+ - genre: {genre}
187
+ - where: {place}
188
+ - mood: {mood}
189
+
190
+ main character
191
+ - name: {main_char_name}
192
+ - job: {main_char_job}
193
+ - age: {main_char_age}
194
+ - personality: {main_char_personality}
195
+ {side_char_placeholder}
196
+ overall outline
197
+ - title: {title}
198
+ - rising action: {rising_action}
199
+ - crisis: {crisis}
200
+ - climax: {climax}
201
+ - falling action: {falling_action}
202
+ - denouement: {denouement}
203
+
204
+ JSON output:
205
+ """
206
+
207
+ [image_gen]
208
+ neg_prompt="nsfw, worst quality, low quality, lowres, bad anatomy, bad hands, text, watermark, signature, error, missing fingers, extra digit, fewer digits, cropped, worst quality, normal quality, blurry, username, extra limbs, twins, boring, jpeg artifacts"
209
+
210
+ [image_gen.character]
211
+ gen_prompt = """Based on my brief descriptions of the character, suggest a "primary descriptive sentence" and "concise descriptors" to visualize them. Ensure you consider elements like the character's gender, age, appearance, occupation, clothing, posture, facial expression, mood, among others.
212
+ Once complete, please output only a single "primary descriptive sentence" and the "concise descriptors" in a syntactically valid JSON format.
213
+ The output template is as follows: {{"primary_sentence":"primary descriptive sentence","descriptors":["concise descriptor 1","concise descriptor 2","concise descriptor 3"]}}.
214
+ To enhance the quality of your character's description or expression, you might consider drawing from the following categories:
215
+ - Emotions and Expressions: "ecstatic", "melancholic", "furious", "startled", "bewildered", "pensive", "overjoyed", "crushed", "elated", "panicked", "satisfied", "cynical", "apathetic", "delighted", "terrified", "desperate", "triumphant", "mortified", "envious", "appreciative", "blissful", "heartbroken", "livid", "astounded", "baffled", "smiling", "frowning", "grinning", "crying", "pouting", "glaring", "blinking", "winking", "smirking", "whistling".
216
+ - Physical Features: "upper body", "very long hair", "looking at viewer", "looking to the side", "looking at another", "thick lips", "skin spots", "acnes", "skin blemishes", "age spot", "perfect eyes", "detailed eyes", "realistic eyes", "dynamic standing", "beautiful face", "necklace", "high detailed skin", "hair ornament", "blush", "shiny skin", "long sleeves", "cleavage", "rubber suit", "slim", "plump", "muscular", "pale skin", "tan skin", "dark skin", "blonde hair", "brunette hair", "black hair", "blue eyes", "green eyes", "brown eyes", "curly hair", "short hair", "wavy hair".
217
+ - Visual Enhancements: "masterpiece", "cinematic lighting", "detailed lighting", "tyndall effect", "soft lighting", "volumetric lighting", "close up", "wide shot", "glossy", "beautiful lighting", "warm lighting", "extreme", "ultimate", "best", "supreme", "ultra", "intense", "powerful", "exceptional", "remarkable", "strong", "vigorous", "dynamic angle", "front view person", "bangs", "waist up", "bokeh".
218
+ - Age and Gender: "1boy", "1man", "1male", "1girl", "1woman", "1female", "teen", "teenage", "twenties", "thirties", "forties", "fifties", "middle-age".
219
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
220
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
221
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
222
+ Do not output anything other than JSON values.
223
+ Do not provide any additional explanation of the following.
224
+ Only JSON is allowed.
225
+ ===
226
+ This is some examples.
227
+ Q:
228
+ The character's name is Liam, their job is as the Secret Agent, and they are in their 50s. And the keywords that help in associating with the character are "Thriller, Underground Warehouse, Darkness, ESTP, Ambitious, Generous".
229
+ Print out no more than 45 words in syntactically valid JSON format.
230
+ A:
231
+ {{"primary_sentence":"Middle-aged man pointing a gun in an underground warehouse","descriptors":["1man","solo","masterpiece","best quality","upper body","black suit","pistol in hand","dramatic lighting","muscular physique","intense brown eyes","raven-black hair","stylish cut","determined gaze","looking at viewer","stealthy demeanor","cunning strategist","advanced techwear","sleek","night operative","shadowy figure","night atmosphere","mysterious aura","highly detailed","film grain","detailed eyes and face"]}}
232
+
233
+ Q:
234
+ The character's name is Catherine, their job is as the Traveler, and they are in their 10s. And the keywords that help in associating with the character are "Romance, Starlit Bridge, Dreamy, ENTJ, Ambitious".
235
+ Print out no more than 45 words in syntactically valid JSON format.
236
+ A:
237
+ {{"primary_sentence":"A dreamy teenage girl standing on a starlit bridge with romantic ambitions","descriptors":["1girl","solo","masterpiece","best quality","upper body","flowing skirt","sun hat","bright-eyed","map in hand","ethereal beauty","wanderlust","scarf","whimsical","graceful poise","celestial allure","close-up","warm soft lighting","luminescent glow","gentle aura","mystic charm","smirk","dreamy landscape","poetic demeanor","cinematic lighting","extremely detailed","film grain","detailed eyes and face"]}}
238
+
239
+ Q:
240
+ The character's name is Claire, their job is as the Technological Advancement, and they are in their 20s. And the keywords that help in associating with the character are "Science Fiction, Space Station, INFP, Ambitious, Generous".
241
+ Print out no more than 45 words in syntactically valid JSON format.
242
+ A:
243
+ {{"primary_sentence":"A young ambitious woman tech expert aboard a futuristic space station","descriptors":["1girl","solo","masterpiece","best quality","upper body","sleek silver jumpsuit","futuristic heels","contemplative","editorial portrait","dynamic angle","sci-fi","techno-savvy","sharp focus","bokeh","beautiful lighting","intricate circuitry","robotic grace","rich colors","vivid contrasts","dramatic lighting","futuristic flair","avant-garde","high-tech allure","innovative mind","mechanical sophistication","film grain","detailed eyes and face"]}}
244
+
245
+ Q:
246
+ The character's name is Sophie, their job is as a Ballet Dancer, and they are in their 10s. And the keywords that help in associating with the character are "Grace, Dance Studio, Elegance, ISFJ, Gentle, Passionate"
247
+ Print out no more than 45 words in syntactically valid JSON format.
248
+ A:
249
+ {{"primary_sentence":"An elegant dancer poses gracefully in a mirrored studio","descriptors":["1girl","teen","solo","masterpiece","best quality","upper body","beautiful face","shiny skin","wavy hair","ballet attire","tiptoe stance","flowing skirt","focused gaze","soft ambiance","soft lighting","film grain","detailed eyes and face"]}}
250
+ ===
251
+ This is my request.
252
+ Q:
253
+ {input}
254
+ A:
255
+ """
256
+ query = """
257
+ The character's name is {character_name}, their job is as the {job}, and they are in their {age}. And the keywords that help in associating with the character are "{keywords}".
258
+ Print out no more than 45 words in syntactically valid JSON format.
259
+ """
260
+
261
+ [image_gen.background]
262
+ gen_prompt = """Based on my brief descriptions of the scene, suggest a "primary descriptive sentence" and "concise descriptors" to visualize it. Ensure you consider elements like the setting's time of day, atmosphere, prominent objects, mood, location, natural phenomena, architecture, among others.
263
+ Once complete, please output only a single "primary descriptive sentence" and the "concise descriptors" in a syntactically valid JSON format.
264
+ The output template is as follows: {{"primary_sentence":"primary descriptive sentence","descriptors":["concise descriptor 1","concise descriptor 2","concise descriptor 3"]}}.
265
+ To enhance the quality of your scene's description or expression, you might consider drawing from the following categories:
266
+ - Atmosphere and Time: "dawn", "dusk", "midday", "midnight", "sunset", "sunrise", "foggy", "misty", "stormy", "calm", "clear night", "starlit", "moonlit", "golden hour".
267
+ - Natural Phenomena: "rainbow", "thunderstorm", "snowfall", "aurora borealis", "shooting star", "rain shower", "windy", "sunny".
268
+ - Location and Architecture: "urban", "rural", "mountainous", "oceanfront", "forest", "desert", "island", "modern city", "ancient ruins", "castle", "village", "meadow", "cave", "bridge".
269
+ - Prominent Objects: "giant tree", "waterfall", "stream", "rock formation", "ancient artifact", "bonfire", "tent", "vehicle", "statue", "fountain".
270
+ - Visual Enhancements: "masterpiece", "cinematic lighting", "detailed lighting", "soft lighting", "volumetric lighting", "tyndall effect", "warm lighting", "close up", "wide shot", "beautiful perspective", "bokeh".
271
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
272
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
273
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
274
+ Do not output anything other than JSON values.
275
+ Do not provide any additional explanation of the following.
276
+ Only JSON is allowed.
277
+ ===
278
+ This is some examples.
279
+ Q:
280
+ The genre is "Fantasy", the place is "Enchanted Forest", the mood is "Mystical", the title of the novel is "Whispering Leaves", and the chapter plot revolves around "A hidden glade where elves sing under the moonlight".
281
+ Print out no more than 45 words in syntactically valid JSON format.
282
+ A:
283
+ {{"primary_sentence":"a mystical glade in an enchanted forest where elves sing beneath the moonlight","descriptors":["no humans","masterpiece","fantasy","enchanted forest","moonlit glade","mystical atmosphere","singing elves","luminous fireflies","ancient trees","shimmering leaves","whispering winds","hidden secrets","elven magic","masterpiece","soft lighting","silver glow","detailed shadows","enchanted mood","highly detailed","film grain"]}}
284
+
285
+ Q:
286
+ The genre is "Science Fiction", the place is "Galactic Space Station", the mood is "Tense", the title of the novel is "Stars Unbound", and the chapter plot revolves around "Ambassadors from different galaxies discussing a new treaty".
287
+ Print out no more than 45 words in syntactically valid JSON format.
288
+ A:
289
+ {{"primary_sentence":"a tense gathering in a galactic space station where interstellar ambassadors negotiate","descriptors":["no humans","masterpiece","science fiction","galactic space station","star-studded backdrop","advanced technology","diverse aliens","hovering spacecrafts","futuristic architecture","tense discussions","interstellar politics","neon lights","holographic displays","masterpiece","detailed lighting","cinematic mood","highly detailed","film grain"]}}
290
+
291
+ Q:
292
+ The genre is "Romance", the place is "Beach", the mood is "Heartfelt", the title of the novel is "Waves of Passion", and the chapter plot revolves around "Two lovers reconciling their differences by the shore".
293
+ Print out no more than 45 words in syntactically valid JSON format.
294
+ A:
295
+ {{"primary_sentence":"a heartfelt scene on a beach during sunset where two lovers reconcile","descriptors":["no humans","masterpiece","romance","beach","sunset horizon","golden sands","lapping waves","embrace","teary-eyed confessions","seashells","reflective waters","warm hues","silhouette of lovers","soft breeze","beautiful perspective","detailed shadows","emotional atmosphere","highly detailed","film grain"]}}
296
+
297
+ Q:
298
+ The genre is "Middle Ages", the place is "Royal Palace", the mood is "Epic Adventure", the title of the novel is "Throne of Fates", and the chapter plot revolves around "A brave knight receiving a quest from the king".
299
+ Print out no more than 45 words in syntactically valid JSON format.
300
+ A:
301
+ {{"primary_sentence":"an epic scene in a royal palace where a knight is tasked with a quest by the king","descriptors":["no humans","masterpiece","middle ages","royal palace","castle","grand throne room","golden hour","armored knight","majestic king","tapestries","stone walls","torches","glistening armor","banner flags","medieval atmosphere","heroic demeanor","detailed architecture","golden crowns","highly detailed","film grain"]}}
302
+ ===
303
+ This is my request.
304
+ Q:
305
+ {input}
306
+ A:
307
+ """
308
+ query = """
309
+ The genre is "{genre}", the place is "{place}", the mood is "{mood}", the title of the novel is "{title}", and the chapter plot revolves around "{chapter_plot}".
310
+ Print out no more than 45 words in syntactically valid JSON format.
311
+ """
312
+
313
+ [music_gen]
314
+ gen_prompt = """Based on my brief descriptions of the novel's mood, theme, or setting, suggest a "primary descriptive sentence" to conceptualize the musical piece. Ensure you consider elements like the music's genre, BPM, primary instruments, emotions evoked, era (if applicable), and other relevant musical characteristics.
315
+ Once complete, please output only a single "primary descriptive sentence" in a syntactically valid JSON format.
316
+ The output template is as follows:
317
+ {{"primary_sentence":"primary descriptive sentence"}}.
318
+ To enhance the quality of your music's description or expression, you might consider drawing from the following categories:
319
+ - Musical Genre and Era: "80s", "90s", "classical", "jazz", "EDM", "rock", "folk", "baroque", "bebop", "grunge", "funk", "hip-hop", "blues", "country".
320
+ - BPM and Rhythm: "slow-paced", "mid-tempo", "upbeat", "rhythmic", "syncopated", "steady beat", "dynamic tempo".
321
+ - Primary Instruments and Sound: "guitar", "synth", "piano", "saxophone", "drums", "violin", "flute", "bassy", "treble-heavy", "distorted", "acoustic", "electric", "ambient sounds".
322
+ - Emotions and Atmosphere: "nostalgic", "energetic", "melancholic", "uplifting", "dark", "light-hearted", "intense", "relaxing", "haunting", "joyful", "sombre", "celebratory", "mystical".
323
+ - Musical Techniques and Enhancements: "harmonious", "dissonant", "layered", "minimalistic", "rich textures", "simple melody", "complex rhythms", "vocal harmonies", "instrumental solo".
324
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
325
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
326
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
327
+ Do not output anything other than JSON values.
328
+ Do not provide any additional explanation of the following.
329
+ Only JSON is allowed.
330
+ ===
331
+ This is some examples.
332
+ Q:
333
+ The genre is "Fantasy", the place is "Enchanted Forest", the mood is "Mystical", the title of the novel is "Whispering Leaves", and the chapter plot revolves around "A hidden glade where elves sing under the moonlight".
334
+ A:
335
+ {{"primary_sentence":"a gentle folk melody filled with whimsical flutes, echoing harps, and distant ethereal vocals, capturing the enchantment of a moonlit forest and the mystique of singing elves"}}
336
+
337
+ Q:
338
+ The genre is "Science Fiction", the place is "Galactic Space Station", the mood is "Tense", the title of the novel is "Stars Unbound", and the chapter plot revolves around "Ambassadors from different galaxies discussing a new treaty".
339
+ A:
340
+ {{"primary_sentence":"an ambient electronic track, with pulsating synths, spacey reverberations, and occasional digital glitches, reflecting the vastness of space and the tension of intergalactic diplomacy"}}
341
+
342
+ Q:
343
+ The genre is "Romance", the place is "Beach", the mood is "Heartfelt", the title of the novel is "Waves of Passion", and the chapter plot revolves around "Two lovers reconciling their differences by the shore".
344
+ A:
345
+ {{"primary_sentence":"a soft acoustic ballad featuring soulful guitars, delicate percussion, and heartfelt vocals, evoking feelings of love, reconciliation, and the gentle ebb and flow of the ocean waves"}}
346
+
347
+ Q:
348
+ The genre is "Middle Ages", the place is "Royal Palace", the mood is "Epic Adventure", the title of the novel is "Throne of Fates", and the chapter plot revolves around "A brave knight receiving a quest from the king".
349
+ A:
350
+ {{"primary_sentence":"a grand orchestral piece, dominated by powerful brass, rhythmic drums, and soaring strings, portraying the valor of knights, the majesty of royalty, and the anticipation of an epic quest"}}
351
+ ===
352
+ This is my request.
353
+ Q:
354
+ {input}
355
+ A:
356
+ """
357
+ query = """
358
+ The genre is "{genre}", the place is "{place}", the mood is "{mood}", the title of the novel is "{title}", and the chapter plot revolves around "{chapter_plot}".
359
+ Print out only one primary_sentence in syntactically valid JSON format.
360
+ """
prompts/llama_prompts.toml ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [story_gen]
2
+ add_side_character = """side character #{cur_side_chars}
3
+ - name: {name},
4
+ - job: {job},
5
+ - age: {age},
6
+ - personality: {personality}
7
+
8
+ """
9
+ first_story_gen = """Write the first three paragraphs of a novel as much detailed as possible. They should be based on the background information. Blend 5W1H principle into the stories as a plain text. Don't let the paragraphs end the whole story.
10
+
11
+ background information:
12
+ - genre: {genre}
13
+ - where: {place}
14
+ - mood: {mood}
15
+
16
+ main character
17
+ - name: {main_char_name}
18
+ - job: {main_char_job}
19
+ - age: {main_char_age}
20
+ - personality: {main_char_personality}
21
+ {side_char_placeholder}
22
+ Fill in the following JSON output format:
23
+ {{"paragraphs":"string"}}
24
+
25
+ Write the JSON output:
26
+ """
27
+ next_story_gen = """Write the next paragraphs. The next paragraphs should be determined by an option and well connected to the current stories.
28
+
29
+ background information:
30
+ - genre: {genre}
31
+ - where: {place}
32
+ - mood: {mood}
33
+
34
+ main character
35
+ - name: {main_char_name}
36
+ - job: {main_char_job}
37
+ - age: {main_char_age}
38
+ - personality: {main_char_personality}
39
+ {side_char_placeholder}
40
+ Fill in the following JSON output format:
41
+ {{"paragraphs":"string"}}
42
+
43
+ stories
44
+ {stories}
45
+
46
+ option to the next stories: {action}
47
+
48
+ Write the JSON output:
49
+ """
50
+ actions_gen = """Suggest the 20 options to drive the stories to the next based on the information below.
51
+
52
+ background information:
53
+ - genre: {genre}
54
+ - where: {place}
55
+ - mood: {mood}
56
+
57
+ main character
58
+ - name: {main_char_name}
59
+ - job: {main_char_job}
60
+ - age: {main_char_age}
61
+ - personality: {main_char_personality}
62
+ {side_char_placeholder}
63
+ Fill in the following JSON output format:
64
+ {{"options":["string1", "string2", "string3"]}}
65
+
66
+ summary of the story
67
+ {summary}
68
+
69
+ Write the JSON output:
70
+ """
71
+ summarize = """Summarize the text below
72
+
73
+ {stories}
74
+
75
+ """
76
+ title="""what would be the title of the story below? be specific and creative.
77
+
78
+ {stories}
79
+
80
+ title: """
81
+
82
+ [chat_gen]
83
+ chapter_title_ctx = """
84
+ chapter{title_idx} {{
85
+ title: {chapter_title},
86
+ plot: {chapter_plot}
87
+ }}
88
+ """
89
+ add_side_character = """side character{cur_side_chars}: {{
90
+ name: {name},
91
+ job: {job},
92
+ age: {age},
93
+ personality: {personality}
94
+ }}
95
+
96
+ """
97
+ chat_context = """You are a professional writing advisor, especially specialized in developing ideas on plotting stories and creating characters. I provide genre, where, and mood along with the rough description of one main character and three side characters.
98
+
99
+ Give creative but not too long responses based on the following information.
100
+
101
+ genre: {genre}
102
+ where: {place}
103
+ mood: {mood}
104
+
105
+ main character: {{
106
+ name: {name1},
107
+ job: {job1},
108
+ age: {age1},
109
+ personality: {personality1}
110
+ }}
111
+ {side_char_placeholder}
112
+ {chapter_title_placeholder}
113
+ """
114
+
115
+ [plot_gen]
116
+ main_plot_gen="""Write a title and an outline of a novel based on the background information below in Ronald Tobias's plot theory. The outline should follow the "rising action", "crisis", "climax", "falling action", and "denouement" plot types. Each should be filled with a VERY detailed and descriptive at least two paragraphs of string. Randomly choose if the story goes optimistic or tragic.
117
+
118
+ background information:
119
+ - genre: string
120
+ - where: string
121
+ - mood: string
122
+
123
+ main character
124
+ - name: string
125
+ - job: string
126
+ - age: string
127
+ - personality: string
128
+
129
+ JSON output:
130
+ {{
131
+ "title": "string",
132
+ "outline": {{
133
+ "rising action": "paragraphs of string",
134
+ "crisis": "paragraphs of string",
135
+ "climax": "paragraphs of string",
136
+ "falling action": "paragraphs of string",
137
+ "denouement": "paragraphs of string"
138
+ }}
139
+ }}
140
+
141
+ background information:
142
+ - genre: {genre}
143
+ - where: {place}
144
+ - mood: {mood}
145
+
146
+ main character
147
+ - name: {main_char_name}
148
+ - job: {main_char_job}
149
+ - age: {main_char_age}
150
+ - personality: {main_char_personality}
151
+ {side_char_placeholder}
152
+ JSON output:
153
+ """
154
+ first_story_gen="""Write the chapter title and the first few paragraphs of the "rising action" plot based on the background information below in Ronald Tobias's plot theory. Also, suggest three choosable actions to drive current story in different directions. The first few paragraphs should be filled with a VERY MUCH detailed and descriptive at least two paragraphs of string.
155
+
156
+ REMEMBER the first few paragraphs should not end the whole story and allow leaway for the next paragraphs to come.
157
+ The whole story SHOULD stick to the "rising action -> crisis -> climax -> falling action -> denouement" flow, so REMEMBER not to write anything mentioned from the next plots of crisis, climax, falling action, and denouement yet.
158
+
159
+ background information:
160
+ - genre: string
161
+ - where: string
162
+ - mood: string
163
+
164
+ main character
165
+ - name: string
166
+ - job: string
167
+ - age: string
168
+ - personality: string
169
+
170
+ overall outline
171
+ - title: string
172
+ - rising action: string
173
+ - crisis: string
174
+ - climax: string
175
+ - falling action: string
176
+ - denouement: string
177
+
178
+ JSON output:
179
+ {{
180
+ "chapter_title": "string",
181
+ "paragraphs": ["string", "string", ...],
182
+ "actions": ["string", "string", "string"]
183
+ }}
184
+
185
+ background information:
186
+ - genre: {genre}
187
+ - where: {place}
188
+ - mood: {mood}
189
+
190
+ main character
191
+ - name: {main_char_name}
192
+ - job: {main_char_job}
193
+ - age: {main_char_age}
194
+ - personality: {main_char_personality}
195
+ {side_char_placeholder}
196
+ overall outline
197
+ - title: {title}
198
+ - rising action: {rising_action}
199
+ - crisis: {crisis}
200
+ - climax: {climax}
201
+ - falling action: {falling_action}
202
+ - denouement: {denouement}
203
+
204
+ JSON output:
205
+ """
206
+
207
+ [image_gen]
208
+ neg_prompt="nsfw, worst quality, low quality, lowres, bad anatomy, bad hands, text, watermark, signature, error, missing fingers, extra digit, fewer digits, cropped, worst quality, normal quality, blurry, username, extra limbs, twins, boring, jpeg artifacts"
209
+
210
+ [image_gen.character]
211
+ gen_prompt = """Based on my brief descriptions of the character, suggest a "primary descriptive sentence" and "concise descriptors" to visualize them. Ensure you consider elements like the character's gender, age, appearance, occupation, clothing, posture, facial expression, mood, among others.
212
+ Once complete, please output only a single "primary descriptive sentence" and the "concise descriptors" in a syntactically valid JSON format.
213
+ The output template is as follows: {{"primary_sentence":"primary descriptive sentence","descriptors":["concise descriptor 1","concise descriptor 2","concise descriptor 3"]}}.
214
+ To enhance the quality of your character's description or expression, you might consider drawing from the following categories:
215
+ - Emotions and Expressions: "ecstatic", "melancholic", "furious", "startled", "bewildered", "pensive", "overjoyed", "crushed", "elated", "panicked", "satisfied", "cynical", "apathetic", "delighted", "terrified", "desperate", "triumphant", "mortified", "envious", "appreciative", "blissful", "heartbroken", "livid", "astounded", "baffled", "smiling", "frowning", "grinning", "crying", "pouting", "glaring", "blinking", "winking", "smirking", "whistling".
216
+ - Physical Features: "upper body", "very long hair", "looking at viewer", "looking to the side", "looking at another", "thick lips", "skin spots", "acnes", "skin blemishes", "age spot", "perfect eyes", "detailed eyes", "realistic eyes", "dynamic standing", "beautiful face", "necklace", "high detailed skin", "hair ornament", "blush", "shiny skin", "long sleeves", "cleavage", "rubber suit", "slim", "plump", "muscular", "pale skin", "tan skin", "dark skin", "blonde hair", "brunette hair", "black hair", "blue eyes", "green eyes", "brown eyes", "curly hair", "short hair", "wavy hair".
217
+ - Visual Enhancements: "masterpiece", "cinematic lighting", "detailed lighting", "tyndall effect", "soft lighting", "volumetric lighting", "close up", "wide shot", "glossy", "beautiful lighting", "warm lighting", "extreme", "ultimate", "best", "supreme", "ultra", "intense", "powerful", "exceptional", "remarkable", "strong", "vigorous", "dynamic angle", "front view person", "bangs", "waist up", "bokeh".
218
+ - Age and Gender: "1boy", "1man", "1male", "1girl", "1woman", "1female", "teen", "teenage", "twenties", "thirties", "forties", "fifties", "middle-age".
219
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
220
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
221
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
222
+ Do not output anything other than JSON values.
223
+ Do not provide any additional explanation of the following.
224
+ Only JSON is allowed.
225
+ ===
226
+ This is some examples.
227
+ Q:
228
+ The character's name is Liam, their job is as the Secret Agent, and they are in their 50s. And the keywords that help in associating with the character are "Thriller, Underground Warehouse, Darkness, ESTP, Ambitious, Generous".
229
+ Print out no more than 45 words in syntactically valid JSON format.
230
+ A:
231
+ {{"primary_sentence":"Middle-aged man pointing a gun in an underground warehouse","descriptors":["1man","solo","masterpiece","best quality","upper body","black suit","pistol in hand","dramatic lighting","muscular physique","intense brown eyes","raven-black hair","stylish cut","determined gaze","looking at viewer","stealthy demeanor","cunning strategist","advanced techwear","sleek","night operative","shadowy figure","night atmosphere","mysterious aura","highly detailed","film grain","detailed eyes and face"]}}
232
+
233
+ Q:
234
+ The character's name is Catherine, their job is as the Traveler, and they are in their 10s. And the keywords that help in associating with the character are "Romance, Starlit Bridge, Dreamy, ENTJ, Ambitious".
235
+ Print out no more than 45 words in syntactically valid JSON format.
236
+ A:
237
+ {{"primary_sentence":"A dreamy teenage girl standing on a starlit bridge with romantic ambitions","descriptors":["1girl","solo","masterpiece","best quality","upper body","flowing skirt","sun hat","bright-eyed","map in hand","ethereal beauty","wanderlust","scarf","whimsical","graceful poise","celestial allure","close-up","warm soft lighting","luminescent glow","gentle aura","mystic charm","smirk","dreamy landscape","poetic demeanor","cinematic lighting","extremely detailed","film grain","detailed eyes and face"]}}
238
+
239
+ Q:
240
+ The character's name is Claire, their job is as the Technological Advancement, and they are in their 20s. And the keywords that help in associating with the character are "Science Fiction, Space Station, INFP, Ambitious, Generous".
241
+ Print out no more than 45 words in syntactically valid JSON format.
242
+ A:
243
+ {{"primary_sentence":"A young ambitious woman tech expert aboard a futuristic space station","descriptors":["1girl","solo","masterpiece","best quality","upper body","sleek silver jumpsuit","futuristic heels","contemplative","editorial portrait","dynamic angle","sci-fi","techno-savvy","sharp focus","bokeh","beautiful lighting","intricate circuitry","robotic grace","rich colors","vivid contrasts","dramatic lighting","futuristic flair","avant-garde","high-tech allure","innovative mind","mechanical sophistication","film grain","detailed eyes and face"]}}
244
+
245
+ Q:
246
+ The character's name is Sophie, their job is as a Ballet Dancer, and they are in their 10s. And the keywords that help in associating with the character are "Grace, Dance Studio, Elegance, ISFJ, Gentle, Passionate"
247
+ Print out no more than 45 words in syntactically valid JSON format.
248
+ A:
249
+ {{"primary_sentence":"An elegant dancer poses gracefully in a mirrored studio","descriptors":["1girl","teen","solo","masterpiece","best quality","upper body","beautiful face","shiny skin","wavy hair","ballet attire","tiptoe stance","flowing skirt","focused gaze","soft ambiance","soft lighting","film grain","detailed eyes and face"]}}
250
+ ===
251
+ This is my request.
252
+ Q:
253
+ {input}
254
+ A:
255
+ """
256
+ query = """
257
+ The character's name is {character_name}, their job is as the {job}, and they are in their {age}. And the keywords that help in associating with the character are "{keywords}".
258
+ Print out no more than 45 words in syntactically valid JSON format.
259
+ """
260
+
261
+ [image_gen.background]
262
+ gen_prompt = """Based on my brief descriptions of the scene, suggest a "primary descriptive sentence" and "concise descriptors" to visualize it. Ensure you consider elements like the setting's time of day, atmosphere, prominent objects, mood, location, natural phenomena, architecture, among others.
263
+ Once complete, please output only a single "primary descriptive sentence" and the "concise descriptors" in a syntactically valid JSON format.
264
+ The output template is as follows: {{"primary_sentence":"primary descriptive sentence","descriptors":["concise descriptor 1","concise descriptor 2","concise descriptor 3"]}}.
265
+ To enhance the quality of your scene's description or expression, you might consider drawing from the following categories:
266
+ - Atmosphere and Time: "dawn", "dusk", "midday", "midnight", "sunset", "sunrise", "foggy", "misty", "stormy", "calm", "clear night", "starlit", "moonlit", "golden hour".
267
+ - Natural Phenomena: "rainbow", "thunderstorm", "snowfall", "aurora borealis", "shooting star", "rain shower", "windy", "sunny".
268
+ - Location and Architecture: "urban", "rural", "mountainous", "oceanfront", "forest", "desert", "island", "modern city", "ancient ruins", "castle", "village", "meadow", "cave", "bridge".
269
+ - Prominent Objects: "giant tree", "waterfall", "stream", "rock formation", "ancient artifact", "bonfire", "tent", "vehicle", "statue", "fountain".
270
+ - Visual Enhancements: "masterpiece", "cinematic lighting", "detailed lighting", "soft lighting", "volumetric lighting", "tyndall effect", "warm lighting", "close up", "wide shot", "beautiful perspective", "bokeh".
271
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
272
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
273
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
274
+ Do not output anything other than JSON values.
275
+ Do not provide any additional explanation of the following.
276
+ Only JSON is allowed.
277
+ ===
278
+ This is some examples.
279
+ Q:
280
+ The genre is "Fantasy", the place is "Enchanted Forest", the mood is "Mystical", the title of the novel is "Whispering Leaves", and the chapter plot revolves around "A hidden glade where elves sing under the moonlight".
281
+ Print out no more than 45 words in syntactically valid JSON format.
282
+ A:
283
+ {{"primary_sentence":"a mystical glade in an enchanted forest where elves sing beneath the moonlight","descriptors":["no humans","masterpiece","fantasy","enchanted forest","moonlit glade","mystical atmosphere","singing elves","luminous fireflies","ancient trees","shimmering leaves","whispering winds","hidden secrets","elven magic","masterpiece","soft lighting","silver glow","detailed shadows","enchanted mood","highly detailed","film grain"]}}
284
+
285
+ Q:
286
+ The genre is "Science Fiction", the place is "Galactic Space Station", the mood is "Tense", the title of the novel is "Stars Unbound", and the chapter plot revolves around "Ambassadors from different galaxies discussing a new treaty".
287
+ Print out no more than 45 words in syntactically valid JSON format.
288
+ A:
289
+ {{"primary_sentence":"a tense gathering in a galactic space station where interstellar ambassadors negotiate","descriptors":["no humans","masterpiece","science fiction","galactic space station","star-studded backdrop","advanced technology","diverse aliens","hovering spacecrafts","futuristic architecture","tense discussions","interstellar politics","neon lights","holographic displays","masterpiece","detailed lighting","cinematic mood","highly detailed","film grain"]}}
290
+
291
+ Q:
292
+ The genre is "Romance", the place is "Beach", the mood is "Heartfelt", the title of the novel is "Waves of Passion", and the chapter plot revolves around "Two lovers reconciling their differences by the shore".
293
+ Print out no more than 45 words in syntactically valid JSON format.
294
+ A:
295
+ {{"primary_sentence":"a heartfelt scene on a beach during sunset where two lovers reconcile","descriptors":["no humans","masterpiece","romance","beach","sunset horizon","golden sands","lapping waves","embrace","teary-eyed confessions","seashells","reflective waters","warm hues","silhouette of lovers","soft breeze","beautiful perspective","detailed shadows","emotional atmosphere","highly detailed","film grain"]}}
296
+
297
+ Q:
298
+ The genre is "Middle Ages", the place is "Royal Palace", the mood is "Epic Adventure", the title of the novel is "Throne of Fates", and the chapter plot revolves around "A brave knight receiving a quest from the king".
299
+ Print out no more than 45 words in syntactically valid JSON format.
300
+ A:
301
+ {{"primary_sentence":"an epic scene in a royal palace where a knight is tasked with a quest by the king","descriptors":["no humans","masterpiece","middle ages","royal palace","castle","grand throne room","golden hour","armored knight","majestic king","tapestries","stone walls","torches","glistening armor","banner flags","medieval atmosphere","heroic demeanor","detailed architecture","golden crowns","highly detailed","film grain"]}}
302
+ ===
303
+ This is my request.
304
+ Q:
305
+ {input}
306
+ A:
307
+ """
308
+ query = """
309
+ The genre is "{genre}", the place is "{place}", the mood is "{mood}", the title of the novel is "{title}", and the chapter plot revolves around "{chapter_plot}".
310
+ Print out no more than 45 words in syntactically valid JSON format.
311
+ """
312
+
313
+ [music_gen]
314
+ gen_prompt = """Based on my brief descriptions of the novel's mood, theme, or setting, suggest a "primary descriptive sentence" to conceptualize the musical piece. Ensure you consider elements like the music's genre, BPM, primary instruments, emotions evoked, era (if applicable), and other relevant musical characteristics.
315
+ Once complete, please output only a single "primary descriptive sentence" in a syntactically valid JSON format.
316
+ The output template is as follows:
317
+ {{"primary_sentence":"primary descriptive sentence"}}.
318
+ To enhance the quality of your music's description or expression, you might consider drawing from the following categories:
319
+ - Musical Genre and Era: "80s", "90s", "classical", "jazz", "EDM", "rock", "folk", "baroque", "bebop", "grunge", "funk", "hip-hop", "blues", "country".
320
+ - BPM and Rhythm: "slow-paced", "mid-tempo", "upbeat", "rhythmic", "syncopated", "steady beat", "dynamic tempo".
321
+ - Primary Instruments and Sound: "guitar", "synth", "piano", "saxophone", "drums", "violin", "flute", "bassy", "treble-heavy", "distorted", "acoustic", "electric", "ambient sounds".
322
+ - Emotions and Atmosphere: "nostalgic", "energetic", "melancholic", "uplifting", "dark", "light-hearted", "intense", "relaxing", "haunting", "joyful", "sombre", "celebratory", "mystical".
323
+ - Musical Techniques and Enhancements: "harmonious", "dissonant", "layered", "minimalistic", "rich textures", "simple melody", "complex rhythms", "vocal harmonies", "instrumental solo".
324
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
325
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
326
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
327
+ Do not output anything other than JSON values.
328
+ Do not provide any additional explanation of the following.
329
+ Only JSON is allowed.
330
+ ===
331
+ This is some examples.
332
+ Q:
333
+ The genre is "Fantasy", the place is "Enchanted Forest", the mood is "Mystical", the title of the novel is "Whispering Leaves", and the chapter plot revolves around "A hidden glade where elves sing under the moonlight".
334
+ A:
335
+ {{"primary_sentence":"a gentle folk melody filled with whimsical flutes, echoing harps, and distant ethereal vocals, capturing the enchantment of a moonlit forest and the mystique of singing elves"}}
336
+
337
+ Q:
338
+ The genre is "Science Fiction", the place is "Galactic Space Station", the mood is "Tense", the title of the novel is "Stars Unbound", and the chapter plot revolves around "Ambassadors from different galaxies discussing a new treaty".
339
+ A:
340
+ {{"primary_sentence":"an ambient electronic track, with pulsating synths, spacey reverberations, and occasional digital glitches, reflecting the vastness of space and the tension of intergalactic diplomacy"}}
341
+
342
+ Q:
343
+ The genre is "Romance", the place is "Beach", the mood is "Heartfelt", the title of the novel is "Waves of Passion", and the chapter plot revolves around "Two lovers reconciling their differences by the shore".
344
+ A:
345
+ {{"primary_sentence":"a soft acoustic ballad featuring soulful guitars, delicate percussion, and heartfelt vocals, evoking feelings of love, reconciliation, and the gentle ebb and flow of the ocean waves"}}
346
+
347
+ Q:
348
+ The genre is "Middle Ages", the place is "Royal Palace", the mood is "Epic Adventure", the title of the novel is "Throne of Fates", and the chapter plot revolves around "A brave knight receiving a quest from the king".
349
+ A:
350
+ {{"primary_sentence":"a grand orchestral piece, dominated by powerful brass, rhythmic drums, and soaring strings, portraying the valor of knights, the majesty of royalty, and the anticipation of an epic quest"}}
351
+ ===
352
+ This is my request.
353
+ Q:
354
+ {input}
355
+ A:
356
+ """
357
+ query = """
358
+ The genre is "{genre}", the place is "{place}", the mood is "{mood}", the title of the novel is "{title}", and the chapter plot revolves around "{chapter_plot}".
359
+ Print out only one primary_sentence in syntactically valid JSON format.
360
+ """
prompts/palm_prompts.toml ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [story_gen]
2
+ add_side_character = """side character #{cur_side_chars}
3
+ - name: {name},
4
+ - job: {job},
5
+ - age: {age},
6
+ - personality: {personality}
7
+
8
+ """
9
+ first_story_gen = """Write the first three paragraphs of a novel as much detailed as possible. They should be based on the background information. Blend 5W1H principle into the stories as a plain text. Don't let the paragraphs end the whole story.
10
+
11
+ background information:
12
+ - genre: {genre}
13
+ - where: {place}
14
+ - mood: {mood}
15
+
16
+ main character
17
+ - name: {main_char_name}
18
+ - job: {main_char_job}
19
+ - age: {main_char_age}
20
+ - personality: {main_char_personality}
21
+ {side_char_placeholder}
22
+ Fill in the following JSON output format:
23
+ {{"paragraphs":"string"}}
24
+
25
+ Write the JSON output:
26
+ """
27
+ next_story_gen = """Write the next paragraphs. The next paragraphs should be determined by an option and well connected to the current stories.
28
+
29
+ background information:
30
+ - genre: {genre}
31
+ - where: {place}
32
+ - mood: {mood}
33
+
34
+ main character
35
+ - name: {main_char_name}
36
+ - job: {main_char_job}
37
+ - age: {main_char_age}
38
+ - personality: {main_char_personality}
39
+ {side_char_placeholder}
40
+ Fill in the following JSON output format:
41
+ {{"paragraphs":"string"}}
42
+
43
+ stories
44
+ {stories}
45
+
46
+ option to the next stories: {action}
47
+
48
+ Write the JSON output:
49
+ """
50
+ actions_gen = """Suggest the 20 options to drive the stories to the next based on the information below.
51
+
52
+ background information:
53
+ - genre: {genre}
54
+ - where: {place}
55
+ - mood: {mood}
56
+
57
+ main character
58
+ - name: {main_char_name}
59
+ - job: {main_char_job}
60
+ - age: {main_char_age}
61
+ - personality: {main_char_personality}
62
+ {side_char_placeholder}
63
+ Fill in the following JSON output format:
64
+ {{"options":["string1", "string2", "string3"]}}
65
+
66
+ summary of the story
67
+ {summary}
68
+
69
+ Write the JSON output:
70
+ """
71
+ summarize = """Summarize the text below
72
+
73
+ {stories}
74
+
75
+ """
76
+ title="""what would be the title of the story below? be specific and creative.
77
+
78
+ {stories}
79
+
80
+ title: """
81
+
82
+ [chat_gen]
83
+ chapter_title_ctx = """
84
+ chapter{title_idx} {{
85
+ title: {chapter_title},
86
+ plot: {chapter_plot}
87
+ }}
88
+ """
89
+ add_side_character = """side character{cur_side_chars}: {{
90
+ name: {name},
91
+ job: {job},
92
+ age: {age},
93
+ personality: {personality}
94
+ }}
95
+
96
+ """
97
+ chat_context = """You are a professional writing advisor, especially specialized in developing ideas on plotting stories and creating characters. I provide genre, where, and mood along with the rough description of one main character and three side characters.
98
+
99
+ Give creative but not too long responses based on the following information.
100
+
101
+ genre: {genre}
102
+ where: {place}
103
+ mood: {mood}
104
+
105
+ main character: {{
106
+ name: {name1},
107
+ job: {job1},
108
+ age: {age1},
109
+ personality: {personality1}
110
+ }}
111
+ {side_char_placeholder}
112
+ {chapter_title_placeholder}
113
+ """
114
+
115
+ [plot_gen]
116
+ main_plot_gen="""Write a title and an outline of a novel based on the background information below in Ronald Tobias's plot theory. The outline should follow the "rising action", "crisis", "climax", "falling action", and "denouement" plot types. Each should be filled with a VERY detailed and descriptive at least two paragraphs of string. Randomly choose if the story goes optimistic or tragic.
117
+
118
+ background information:
119
+ - genre: string
120
+ - where: string
121
+ - mood: string
122
+
123
+ main character
124
+ - name: string
125
+ - job: string
126
+ - age: string
127
+ - personality: string
128
+
129
+ JSON output:
130
+ {{
131
+ "title": "string",
132
+ "outline": {{
133
+ "rising action": "paragraphs of string",
134
+ "crisis": "paragraphs of string",
135
+ "climax": "paragraphs of string",
136
+ "falling action": "paragraphs of string",
137
+ "denouement": "paragraphs of string"
138
+ }}
139
+ }}
140
+
141
+ background information:
142
+ - genre: {genre}
143
+ - where: {place}
144
+ - mood: {mood}
145
+
146
+ main character
147
+ - name: {main_char_name}
148
+ - job: {main_char_job}
149
+ - age: {main_char_age}
150
+ - personality: {main_char_personality}
151
+ {side_char_placeholder}
152
+ JSON output:
153
+ """
154
+ first_story_gen="""Write the chapter title and the first few paragraphs of the "rising action" plot based on the background information below in Ronald Tobias's plot theory. Also, suggest three choosable actions to drive current story in different directions. The first few paragraphs should be filled with a VERY MUCH detailed and descriptive at least two paragraphs of string.
155
+
156
+ REMEMBER the first few paragraphs should not end the whole story and allow leaway for the next paragraphs to come.
157
+ The whole story SHOULD stick to the "rising action -> crisis -> climax -> falling action -> denouement" flow, so REMEMBER not to write anything mentioned from the next plots of crisis, climax, falling action, and denouement yet.
158
+
159
+ background information:
160
+ - genre: string
161
+ - where: string
162
+ - mood: string
163
+
164
+ main character
165
+ - name: string
166
+ - job: string
167
+ - age: string
168
+ - personality: string
169
+
170
+ overall outline
171
+ - title: string
172
+ - rising action: string
173
+ - crisis: string
174
+ - climax: string
175
+ - falling action: string
176
+ - denouement: string
177
+
178
+ JSON output:
179
+ {{
180
+ "chapter_title": "string",
181
+ "paragraphs": ["string", "string", ...],
182
+ "actions": ["string", "string", "string"]
183
+ }}
184
+
185
+ background information:
186
+ - genre: {genre}
187
+ - where: {place}
188
+ - mood: {mood}
189
+
190
+ main character
191
+ - name: {main_char_name}
192
+ - job: {main_char_job}
193
+ - age: {main_char_age}
194
+ - personality: {main_char_personality}
195
+ {side_char_placeholder}
196
+ overall outline
197
+ - title: {title}
198
+ - rising action: {rising_action}
199
+ - crisis: {crisis}
200
+ - climax: {climax}
201
+ - falling action: {falling_action}
202
+ - denouement: {denouement}
203
+
204
+ JSON output:
205
+ """
206
+
207
+ [image_gen]
208
+ neg_prompt="nsfw, worst quality, low quality, lowres, bad anatomy, bad hands, text, watermark, signature, error, missing fingers, extra digit, fewer digits, cropped, worst quality, normal quality, blurry, username, extra limbs, twins, boring, jpeg artifacts"
209
+
210
+ [image_gen.character]
211
+ gen_prompt = """Based on my brief descriptions of the character, suggest a "primary descriptive sentence" and "concise descriptors" to visualize them. Ensure you consider elements like the character's gender, age, appearance, occupation, clothing, posture, facial expression, mood, among others.
212
+ Once complete, please output only a single "primary descriptive sentence" and the "concise descriptors" in a syntactically valid JSON format.
213
+ The output template is as follows: {{"primary_sentence":"primary descriptive sentence","descriptors":["concise descriptor 1","concise descriptor 2","concise descriptor 3"]}}.
214
+ To enhance the quality of your character's description or expression, you might consider drawing from the following categories:
215
+ - Emotions and Expressions: "ecstatic", "melancholic", "furious", "startled", "bewildered", "pensive", "overjoyed", "crushed", "elated", "panicked", "satisfied", "cynical", "apathetic", "delighted", "terrified", "desperate", "triumphant", "mortified", "envious", "appreciative", "blissful", "heartbroken", "livid", "astounded", "baffled", "smiling", "frowning", "grinning", "crying", "pouting", "glaring", "blinking", "winking", "smirking", "whistling".
216
+ - Physical Features: "upper body", "very long hair", "looking at viewer", "looking to the side", "looking at another", "thick lips", "skin spots", "acnes", "skin blemishes", "age spot", "perfect eyes", "detailed eyes", "realistic eyes", "dynamic standing", "beautiful face", "necklace", "high detailed skin", "hair ornament", "blush", "shiny skin", "long sleeves", "cleavage", "rubber suit", "slim", "plump", "muscular", "pale skin", "tan skin", "dark skin", "blonde hair", "brunette hair", "black hair", "blue eyes", "green eyes", "brown eyes", "curly hair", "short hair", "wavy hair".
217
+ - Visual Enhancements: "masterpiece", "cinematic lighting", "detailed lighting", "tyndall effect", "soft lighting", "volumetric lighting", "close up", "wide shot", "glossy", "beautiful lighting", "warm lighting", "extreme", "ultimate", "best", "supreme", "ultra", "intense", "powerful", "exceptional", "remarkable", "strong", "vigorous", "dynamic angle", "front view person", "bangs", "waist up", "bokeh".
218
+ - Age and Gender: "1boy", "1man", "1male", "1girl", "1woman", "1female", "teen", "teenage", "twenties", "thirties", "forties", "fifties", "middle-age".
219
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
220
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
221
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
222
+ Do not output anything other than JSON values.
223
+ Do not provide any additional explanation of the following.
224
+ Only JSON is allowed.
225
+ ===
226
+ This is some examples.
227
+ Q:
228
+ The character's name is Liam, their job is as the Secret Agent, and they are in their 50s. And the keywords that help in associating with the character are "Thriller, Underground Warehouse, Darkness, ESTP, Ambitious, Generous".
229
+ Print out no more than 45 words in syntactically valid JSON format.
230
+ A:
231
+ {{"primary_sentence":"Middle-aged man pointing a gun in an underground warehouse","descriptors":["1man","solo","masterpiece","best quality","upper body","black suit","pistol in hand","dramatic lighting","muscular physique","intense brown eyes","raven-black hair","stylish cut","determined gaze","looking at viewer","stealthy demeanor","cunning strategist","advanced techwear","sleek","night operative","shadowy figure","night atmosphere","mysterious aura","highly detailed","film grain","detailed eyes and face"]}}
232
+
233
+ Q:
234
+ The character's name is Catherine, their job is as the Traveler, and they are in their 10s. And the keywords that help in associating with the character are "Romance, Starlit Bridge, Dreamy, ENTJ, Ambitious".
235
+ Print out no more than 45 words in syntactically valid JSON format.
236
+ A:
237
+ {{"primary_sentence":"A dreamy teenage girl standing on a starlit bridge with romantic ambitions","descriptors":["1girl","solo","masterpiece","best quality","upper body","flowing skirt","sun hat","bright-eyed","map in hand","ethereal beauty","wanderlust","scarf","whimsical","graceful poise","celestial allure","close-up","warm soft lighting","luminescent glow","gentle aura","mystic charm","smirk","dreamy landscape","poetic demeanor","cinematic lighting","extremely detailed","film grain","detailed eyes and face"]}}
238
+
239
+ Q:
240
+ The character's name is Claire, their job is as the Technological Advancement, and they are in their 20s. And the keywords that help in associating with the character are "Science Fiction, Space Station, INFP, Ambitious, Generous".
241
+ Print out no more than 45 words in syntactically valid JSON format.
242
+ A:
243
+ {{"primary_sentence":"A young ambitious woman tech expert aboard a futuristic space station","descriptors":["1girl","solo","masterpiece","best quality","upper body","sleek silver jumpsuit","futuristic heels","contemplative","editorial portrait","dynamic angle","sci-fi","techno-savvy","sharp focus","bokeh","beautiful lighting","intricate circuitry","robotic grace","rich colors","vivid contrasts","dramatic lighting","futuristic flair","avant-garde","high-tech allure","innovative mind","mechanical sophistication","film grain","detailed eyes and face"]}}
244
+
245
+ Q:
246
+ The character's name is Sophie, their job is as a Ballet Dancer, and they are in their 10s. And the keywords that help in associating with the character are "Grace, Dance Studio, Elegance, ISFJ, Gentle, Passionate"
247
+ Print out no more than 45 words in syntactically valid JSON format.
248
+ A:
249
+ {{"primary_sentence":"An elegant dancer poses gracefully in a mirrored studio","descriptors":["1girl","teen","solo","masterpiece","best quality","upper body","beautiful face","shiny skin","wavy hair","ballet attire","tiptoe stance","flowing skirt","focused gaze","soft ambiance","soft lighting","film grain","detailed eyes and face"]}}
250
+ ===
251
+ This is my request.
252
+ Q:
253
+ {input}
254
+ A:
255
+ """
256
+ query = """
257
+ The character's name is {character_name}, their job is as the {job}, and they are in their {age}. And the keywords that help in associating with the character are "{keywords}".
258
+ Print out no more than 45 words in syntactically valid JSON format.
259
+ """
260
+
261
+ [image_gen.background]
262
+ gen_prompt = """Based on my brief descriptions of the scene, suggest a "primary descriptive sentence" and "concise descriptors" to visualize it. Ensure you consider elements like the setting's time of day, atmosphere, prominent objects, mood, location, natural phenomena, architecture, among others.
263
+ Once complete, please output only a single "primary descriptive sentence" and the "concise descriptors" in a syntactically valid JSON format.
264
+ The output template is as follows: {{"primary_sentence":"primary descriptive sentence","descriptors":["concise descriptor 1","concise descriptor 2","concise descriptor 3"]}}.
265
+ To enhance the quality of your scene's description or expression, you might consider drawing from the following categories:
266
+ - Atmosphere and Time: "dawn", "dusk", "midday", "midnight", "sunset", "sunrise", "foggy", "misty", "stormy", "calm", "clear night", "starlit", "moonlit", "golden hour".
267
+ - Natural Phenomena: "rainbow", "thunderstorm", "snowfall", "aurora borealis", "shooting star", "rain shower", "windy", "sunny".
268
+ - Location and Architecture: "urban", "rural", "mountainous", "oceanfront", "forest", "desert", "island", "modern city", "ancient ruins", "castle", "village", "meadow", "cave", "bridge".
269
+ - Prominent Objects: "giant tree", "waterfall", "stream", "rock formation", "ancient artifact", "bonfire", "tent", "vehicle", "statue", "fountain".
270
+ - Visual Enhancements: "masterpiece", "cinematic lighting", "detailed lighting", "soft lighting", "volumetric lighting", "tyndall effect", "warm lighting", "close up", "wide shot", "beautiful perspective", "bokeh".
271
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
272
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
273
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
274
+ Do not output anything other than JSON values.
275
+ Do not provide any additional explanation of the following.
276
+ Only JSON is allowed.
277
+ ===
278
+ This is some examples.
279
+ Q:
280
+ The genre is "Fantasy", the place is "Enchanted Forest", the mood is "Mystical", the title of the novel is "Whispering Leaves", and the chapter plot revolves around "A hidden glade where elves sing under the moonlight".
281
+ Print out no more than 45 words in syntactically valid JSON format.
282
+ A:
283
+ {{"primary_sentence":"a mystical glade in an enchanted forest where elves sing beneath the moonlight","descriptors":["no humans","masterpiece","fantasy","enchanted forest","moonlit glade","mystical atmosphere","singing elves","luminous fireflies","ancient trees","shimmering leaves","whispering winds","hidden secrets","elven magic","masterpiece","soft lighting","silver glow","detailed shadows","enchanted mood","highly detailed","film grain"]}}
284
+
285
+ Q:
286
+ The genre is "Science Fiction", the place is "Galactic Space Station", the mood is "Tense", the title of the novel is "Stars Unbound", and the chapter plot revolves around "Ambassadors from different galaxies discussing a new treaty".
287
+ Print out no more than 45 words in syntactically valid JSON format.
288
+ A:
289
+ {{"primary_sentence":"a tense gathering in a galactic space station where interstellar ambassadors negotiate","descriptors":["no humans","masterpiece","science fiction","galactic space station","star-studded backdrop","advanced technology","diverse aliens","hovering spacecrafts","futuristic architecture","tense discussions","interstellar politics","neon lights","holographic displays","masterpiece","detailed lighting","cinematic mood","highly detailed","film grain"]}}
290
+
291
+ Q:
292
+ The genre is "Romance", the place is "Beach", the mood is "Heartfelt", the title of the novel is "Waves of Passion", and the chapter plot revolves around "Two lovers reconciling their differences by the shore".
293
+ Print out no more than 45 words in syntactically valid JSON format.
294
+ A:
295
+ {{"primary_sentence":"a heartfelt scene on a beach during sunset where two lovers reconcile","descriptors":["no humans","masterpiece","romance","beach","sunset horizon","golden sands","lapping waves","embrace","teary-eyed confessions","seashells","reflective waters","warm hues","silhouette of lovers","soft breeze","beautiful perspective","detailed shadows","emotional atmosphere","highly detailed","film grain"]}}
296
+
297
+ Q:
298
+ The genre is "Middle Ages", the place is "Royal Palace", the mood is "Epic Adventure", the title of the novel is "Throne of Fates", and the chapter plot revolves around "A brave knight receiving a quest from the king".
299
+ Print out no more than 45 words in syntactically valid JSON format.
300
+ A:
301
+ {{"primary_sentence":"an epic scene in a royal palace where a knight is tasked with a quest by the king","descriptors":["no humans","masterpiece","middle ages","royal palace","castle","grand throne room","golden hour","armored knight","majestic king","tapestries","stone walls","torches","glistening armor","banner flags","medieval atmosphere","heroic demeanor","detailed architecture","golden crowns","highly detailed","film grain"]}}
302
+ ===
303
+ This is my request.
304
+ Q:
305
+ {input}
306
+ A:
307
+ """
308
+ query = """
309
+ The genre is "{genre}", the place is "{place}", the mood is "{mood}", the title of the novel is "{title}", and the chapter plot revolves around "{chapter_plot}".
310
+ Print out no more than 45 words in syntactically valid JSON format.
311
+ """
312
+
313
+ [music_gen]
314
+ gen_prompt = """Based on my brief descriptions of the novel's mood, theme, or setting, suggest a "primary descriptive sentence" to conceptualize the musical piece. Ensure you consider elements like the music's genre, BPM, primary instruments, emotions evoked, era (if applicable), and other relevant musical characteristics.
315
+ Once complete, please output only a single "primary descriptive sentence" in a syntactically valid JSON format.
316
+ The output template is as follows:
317
+ {{"primary_sentence":"primary descriptive sentence"}}.
318
+ To enhance the quality of your music's description or expression, you might consider drawing from the following categories:
319
+ - Musical Genre and Era: "80s", "90s", "classical", "jazz", "EDM", "rock", "folk", "baroque", "bebop", "grunge", "funk", "hip-hop", "blues", "country".
320
+ - BPM and Rhythm: "slow-paced", "mid-tempo", "upbeat", "rhythmic", "syncopated", "steady beat", "dynamic tempo".
321
+ - Primary Instruments and Sound: "guitar", "synth", "piano", "saxophone", "drums", "violin", "flute", "bassy", "treble-heavy", "distorted", "acoustic", "electric", "ambient sounds".
322
+ - Emotions and Atmosphere: "nostalgic", "energetic", "melancholic", "uplifting", "dark", "light-hearted", "intense", "relaxing", "haunting", "joyful", "sombre", "celebratory", "mystical".
323
+ - Musical Techniques and Enhancements: "harmonious", "dissonant", "layered", "minimalistic", "rich textures", "simple melody", "complex rhythms", "vocal harmonies", "instrumental solo".
324
+ Do note that this list isn't exhaustive, and you're encouraged to suggest similar terms not included here.
325
+ Exclude words from the suggestion that are redundant or have conflicting meanings.
326
+ Especially, Exclude words that conflict with the meaning of "primary_sentence".
327
+ Do not output anything other than JSON values.
328
+ Do not provide any additional explanation of the following.
329
+ Only JSON is allowed.
330
+ ===
331
+ This is some examples.
332
+ Q:
333
+ The genre is "Fantasy", the place is "Enchanted Forest", the mood is "Mystical", the title of the novel is "Whispering Leaves", and the chapter plot revolves around "A hidden glade where elves sing under the moonlight".
334
+ A:
335
+ {{"primary_sentence":"a gentle folk melody filled with whimsical flutes, echoing harps, and distant ethereal vocals, capturing the enchantment of a moonlit forest and the mystique of singing elves"}}
336
+
337
+ Q:
338
+ The genre is "Science Fiction", the place is "Galactic Space Station", the mood is "Tense", the title of the novel is "Stars Unbound", and the chapter plot revolves around "Ambassadors from different galaxies discussing a new treaty".
339
+ A:
340
+ {{"primary_sentence":"an ambient electronic track, with pulsating synths, spacey reverberations, and occasional digital glitches, reflecting the vastness of space and the tension of intergalactic diplomacy"}}
341
+
342
+ Q:
343
+ The genre is "Romance", the place is "Beach", the mood is "Heartfelt", the title of the novel is "Waves of Passion", and the chapter plot revolves around "Two lovers reconciling their differences by the shore".
344
+ A:
345
+ {{"primary_sentence":"a soft acoustic ballad featuring soulful guitars, delicate percussion, and heartfelt vocals, evoking feelings of love, reconciliation, and the gentle ebb and flow of the ocean waves"}}
346
+
347
+ Q:
348
+ The genre is "Middle Ages", the place is "Royal Palace", the mood is "Epic Adventure", the title of the novel is "Throne of Fates", and the chapter plot revolves around "A brave knight receiving a quest from the king".
349
+ A:
350
+ {{"primary_sentence":"a grand orchestral piece, dominated by powerful brass, rhythmic drums, and soaring strings, portraying the valor of knights, the majesty of royalty, and the anticipation of an epic quest"}}
351
+ ===
352
+ This is my request.
353
+ Q:
354
+ {input}
355
+ A:
356
+ """
357
+ query = """
358
+ The genre is "{genre}", the place is "{place}", the mood is "{mood}", the title of the novel is "{title}", and the chapter plot revolves around "{chapter_plot}".
359
+ Print out only one primary_sentence in syntactically valid JSON format.
360
+ """