Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -287,9 +287,11 @@ def randomize_character_content():
|
|
| 287 |
"A booming voice echoes, 'I’m {char}, and I’m here to fight for justice—or at least a good brawl!'",
|
| 288 |
"A soft hand touches your shoulder. 'I’m {char}, here to heal your wounds—don’t worry, I’ve got you.'"
|
| 289 |
]
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
|
|
|
|
|
|
| 293 |
|
| 294 |
def save_character(character_data):
|
| 295 |
characters = st.session_state.get('characters', [])
|
|
@@ -563,7 +565,7 @@ with tab_pdf_process:
|
|
| 563 |
combined_img.paste(img1, (0, 0))
|
| 564 |
combined_img.paste(img2, (img1.width, 0))
|
| 565 |
st.image(combined_img, caption=f"{pdf_file.name} Pages {i+1}-{i+2}")
|
| 566 |
-
gpt_text = process_image_with_prompt(combined_img, "Extract the electronic text from image", model=selected_gpt_model,
|
| 567 |
combined_text += f"\n## {pdf_file.name} - Pages {i+1}-{i+2}\n\n{gpt_text}\n"
|
| 568 |
else:
|
| 569 |
pix = pages[i].get_pixmap(matrix=fitz.Matrix(2.0, 2.0))
|
|
@@ -664,25 +666,13 @@ with tab_character_editor:
|
|
| 664 |
|
| 665 |
with st.form(key="character_form"):
|
| 666 |
if st.session_state.get('char_form_reset', False):
|
| 667 |
-
default_name =
|
| 668 |
-
default_gender = "Male"
|
| 669 |
-
default_intro = ''
|
| 670 |
-
default_greeting = ''
|
| 671 |
st.session_state['char_form_reset'] = False
|
| 672 |
else:
|
| 673 |
-
default_name =
|
| 674 |
-
default_gender = "Male"
|
| 675 |
-
default_intro = 'Character_3857 is a gentle healer who speaks softly, always carrying herbs and a warm smile.'
|
| 676 |
-
default_greeting = "A soft hand touches your shoulder. 'I’m Character_3857, here to heal your wounds—don’t worry, I’ve got you.'"
|
| 677 |
|
| 678 |
if st.form_submit_button("Randomize Content 🎲"):
|
| 679 |
-
|
| 680 |
-
gender = random.choice(["Male", "Female", "Non-binary"])
|
| 681 |
-
intro, greeting = randomize_character_content()
|
| 682 |
-
default_name = name
|
| 683 |
-
default_gender = gender
|
| 684 |
-
default_intro = intro.format(char=name)
|
| 685 |
-
default_greeting = greeting.format(char=name)
|
| 686 |
|
| 687 |
name = st.text_input("Name (3-25 characters, letters, numbers, underscore, hyphen, space only)",
|
| 688 |
value=default_name,
|
|
@@ -784,4 +774,5 @@ for record in log_records:
|
|
| 784 |
st.sidebar.subheader("History 📜")
|
| 785 |
for entry in st.session_state.get("history", []):
|
| 786 |
if entry is not None:
|
| 787 |
-
st.sidebar.write(entry)
|
|
|
|
|
|
| 287 |
"A booming voice echoes, 'I’m {char}, and I’m here to fight for justice—or at least a good brawl!'",
|
| 288 |
"A soft hand touches your shoulder. 'I’m {char}, here to heal your wounds—don’t worry, I’ve got you.'"
|
| 289 |
]
|
| 290 |
+
name = f"Character_{random.randint(1000, 9999)}"
|
| 291 |
+
gender = random.choice(["Male", "Female", "Non-binary"])
|
| 292 |
+
intro = random.choice(intro_templates).format(char=name)
|
| 293 |
+
greeting = random.choice(greeting_templates).format(char=name)
|
| 294 |
+
return name, gender, intro, greeting
|
| 295 |
|
| 296 |
def save_character(character_data):
|
| 297 |
characters = st.session_state.get('characters', [])
|
|
|
|
| 565 |
combined_img.paste(img1, (0, 0))
|
| 566 |
combined_img.paste(img2, (img1.width, 0))
|
| 567 |
st.image(combined_img, caption=f"{pdf_file.name} Pages {i+1}-{i+2}")
|
| 568 |
+
gpt_text = process_image_with_prompt(combined_img, "Extract the electronic text from image", model=selected_gpt_model, detail=detail_level)
|
| 569 |
combined_text += f"\n## {pdf_file.name} - Pages {i+1}-{i+2}\n\n{gpt_text}\n"
|
| 570 |
else:
|
| 571 |
pix = pages[i].get_pixmap(matrix=fitz.Matrix(2.0, 2.0))
|
|
|
|
| 666 |
|
| 667 |
with st.form(key="character_form"):
|
| 668 |
if st.session_state.get('char_form_reset', False):
|
| 669 |
+
default_name, default_gender, default_intro, default_greeting = randomize_character_content()
|
|
|
|
|
|
|
|
|
|
| 670 |
st.session_state['char_form_reset'] = False
|
| 671 |
else:
|
| 672 |
+
default_name, default_gender, default_intro, default_greeting = randomize_character_content()
|
|
|
|
|
|
|
|
|
|
| 673 |
|
| 674 |
if st.form_submit_button("Randomize Content 🎲"):
|
| 675 |
+
default_name, default_gender, default_intro, default_greeting = randomize_character_content()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 676 |
|
| 677 |
name = st.text_input("Name (3-25 characters, letters, numbers, underscore, hyphen, space only)",
|
| 678 |
value=default_name,
|
|
|
|
| 774 |
st.sidebar.subheader("History 📜")
|
| 775 |
for entry in st.session_state.get("history", []):
|
| 776 |
if entry is not None:
|
| 777 |
+
st.sidebar.write(entry)
|
| 778 |
+
|