Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -688,11 +688,11 @@ def idea_generator_app():
|
|
688 |
|
689 |
sb.subheader("Example Prompts")
|
690 |
c1, c2, c3 = sb.columns(3)
|
691 |
-
if c1.button("
|
692 |
process_example(example_topics["example1"])
|
693 |
-
if c2.button("
|
694 |
process_example(example_topics["example2"])
|
695 |
-
if c3.button("
|
696 |
process_example(example_topics["example3"])
|
697 |
|
698 |
# Download the latest ideas
|
@@ -880,42 +880,46 @@ def process_input(prompt: str, uploaded_files):
|
|
880 |
status.update(label="Ideas created!", state="complete")
|
881 |
|
882 |
# โโ โค ์ด๋ฏธ์ง ์์ฑ
|
|
|
883 |
if st.session_state.generate_image and full_response:
|
884 |
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
r"\|\s*(?:\*\*)?Image\s+Prompt(?:\*\*)?\s*\|\s*([^|\n]+)",
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
raw_prompt = re.sub(r"[\r\n`\"'\\]", " ",
|
905 |
-
|
906 |
-
|
|
|
907 |
img, cap = generate_image(raw_prompt)
|
908 |
|
909 |
if img:
|
910 |
-
st.image(img, caption=f"
|
|
|
911 |
st.session_state.messages.append({
|
912 |
"role": "assistant",
|
913 |
"content": "",
|
914 |
"image": img,
|
915 |
-
"image_caption": f"
|
916 |
})
|
|
|
|
|
917 |
|
918 |
-
|
919 |
|
920 |
# โโ โฅ ๊ฒฐ๊ณผ ์ ์ฅ
|
921 |
st.session_state.messages.append(
|
|
|
688 |
|
689 |
sb.subheader("Example Prompts")
|
690 |
c1, c2, c3 = sb.columns(3)
|
691 |
+
if c1.button("๋์ ๋ฌผ ๋ถ์กฑ ๋ฌธ์ ", key="ex1"):
|
692 |
process_example(example_topics["example1"])
|
693 |
+
if c2.button("๋
ธ์ธ ๋๋ด ์๋น์ค", key="ex2"):
|
694 |
process_example(example_topics["example2"])
|
695 |
+
if c3.button("์ง์๊ฐ๋ฅํ ์ํ ํฌ์ฅ", key="ex3"):
|
696 |
process_example(example_topics["example3"])
|
697 |
|
698 |
# Download the latest ideas
|
|
|
880 |
status.update(label="Ideas created!", state="complete")
|
881 |
|
882 |
# โโ โค ์ด๋ฏธ์ง ์์ฑ
|
883 |
+
# โโ โค ์ด๋ฏธ์ง ์์ฑ (๊ธฐ์กด ๋ธ๋ก ์ ๋ถ ๊ต์ฒด) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
884 |
if st.session_state.generate_image and full_response:
|
885 |
|
886 |
+
# 1๏ธโฃ โถ CCM ์คํ์ผ: "### ์ด๋ฏธ์ง ํ๋กฌํํธ" ํค๋ฉ ์๋ ์ค
|
887 |
+
ccm_match = re.search(
|
888 |
+
r"###\s*์ด๋ฏธ์ง\s*ํ๋กฌํํธ\s*\n+([^\n]+)",
|
889 |
+
full_response, flags=re.IGNORECASE)
|
890 |
+
|
891 |
+
# 2๏ธโฃ โท ์ด์ ์คํ์ผ: ํ
์ด๋ธ or "Image Prompt:"
|
892 |
+
legacy_match = None
|
893 |
+
if not ccm_match:
|
894 |
+
legacy_match = re.search(
|
895 |
+
r"\|\s*(?:\*\*)?Image\s+Prompt(?:\*\*)?\s*\|\s*([^|\n]+)",
|
896 |
+
full_response, flags=re.IGNORECASE)
|
897 |
+
if not legacy_match:
|
898 |
+
legacy_match = re.search(
|
899 |
+
r"(?i)Image\s+Prompt\s*[:\-]\s*([^\n]+)",
|
900 |
+
full_response)
|
901 |
+
|
902 |
+
# 3๏ธโฃ ์ต์ข
ํ๋กฌํํธ ์ถ์ถ
|
903 |
+
match = ccm_match or legacy_match
|
904 |
+
if match:
|
905 |
+
raw_prompt = re.sub(r"[\r\n`\"'\\]", " ",
|
906 |
+
match.group(1)).strip()
|
907 |
+
|
908 |
+
with st.spinner("์์ด๋์ด ์ด๋ฏธ์ง ์์ฑ ์คโฆ"):
|
909 |
img, cap = generate_image(raw_prompt)
|
910 |
|
911 |
if img:
|
912 |
+
st.image(img, caption=f"์์ด๋์ด ์๊ฐํ โ {cap}")
|
913 |
+
# ๋ํ ๊ธฐ๋ก์ ์ด๋ฏธ์ง๋ ์ ์ฅ
|
914 |
st.session_state.messages.append({
|
915 |
"role": "assistant",
|
916 |
"content": "",
|
917 |
"image": img,
|
918 |
+
"image_caption": f"์์ด๋์ด ์๊ฐํ โ {cap}"
|
919 |
})
|
920 |
+
|
921 |
+
|
922 |
|
|
|
923 |
|
924 |
# โโ โฅ ๊ฒฐ๊ณผ ์ ์ฅ
|
925 |
st.session_state.messages.append(
|