Spaces:
Sleeping
Sleeping
added logic for random button
Browse files- app.py +9 -5
- core_races.txt +14 -0
app.py
CHANGED
|
@@ -10,7 +10,7 @@ pipe = pipeline("text-generation", model="TinyLlama/TinyLlama-1.1B-Chat-v0.6", t
|
|
| 10 |
|
| 11 |
DESC_SYSTEM_PROMPT = (
|
| 12 |
"Write a description of a fantasy character based on the user prompt"
|
| 13 |
-
"Include only the following items;
|
| 14 |
)
|
| 15 |
BACK_SYSTEM_PROMPT = (
|
| 16 |
"Write a short synopsis of what the character has been through"
|
|
@@ -27,10 +27,14 @@ def char_description(prompt):
|
|
| 27 |
output2 = pipe(prompt2, return_full_text=False, max_new_tokens=256)
|
| 28 |
return output1, output2
|
| 29 |
|
| 30 |
-
def rand_char_description(
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
#if the prompt is blank, use random number to choose a race and class from lists. The lists will only
|
| 36 |
# include the most common of each. This will be fed in as the user prompt in leiu of a real one.
|
|
|
|
| 10 |
|
| 11 |
DESC_SYSTEM_PROMPT = (
|
| 12 |
"Write a description of a fantasy character based on the user prompt"
|
| 13 |
+
"Include only the following items; Fantasy race, height, build, eye color, hair color/cut, clothing, notable physical features"
|
| 14 |
)
|
| 15 |
BACK_SYSTEM_PROMPT = (
|
| 16 |
"Write a short synopsis of what the character has been through"
|
|
|
|
| 27 |
output2 = pipe(prompt2, return_full_text=False, max_new_tokens=256)
|
| 28 |
return output1, output2
|
| 29 |
|
| 30 |
+
def rand_char_description():
|
| 31 |
+
input_file = open(core_races.txt, 'r')
|
| 32 |
+
races = input_file.readline()
|
| 33 |
+
rand_race = random.choice(races)
|
| 34 |
+
prompt1 = f"{DESC_SYSTEM_PROMPT}\n\nCharacter Description: {rand_race}\n\nDescribe:"
|
| 35 |
+
output1 = pipe(prompt1, return_full_text=False, max_new_tokens=256)
|
| 36 |
+
prompt2 = f"{BACK_SYSTEM_PROMPT}\n\n{output1}\n\nUser prompt: {rand_race}\n\nDescribe:"
|
| 37 |
+
output2 = pipe(prompt2, return_full_text=False, max_new_tokens=256)
|
| 38 |
|
| 39 |
#if the prompt is blank, use random number to choose a race and class from lists. The lists will only
|
| 40 |
# include the most common of each. This will be fed in as the user prompt in leiu of a real one.
|
core_races.txt
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Dragonborn
|
| 2 |
+
Dwarf
|
| 3 |
+
Eladrin
|
| 4 |
+
Elf
|
| 5 |
+
Fairy
|
| 6 |
+
Firbolg
|
| 7 |
+
Gnome
|
| 8 |
+
Goblin
|
| 9 |
+
Half-elf
|
| 10 |
+
Half-orc
|
| 11 |
+
Halfling
|
| 12 |
+
Human
|
| 13 |
+
Orc
|
| 14 |
+
Tiefling
|