Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -846,24 +846,28 @@ def process_input(prompt: str, uploaded_files):
|
|
| 846 |
|
| 847 |
# โโ โค ์ด๋ฏธ์ง ์์ฑ
|
| 848 |
if st.session_state.generate_image and full_response:
|
| 849 |
-
|
|
|
|
| 850 |
pairs = [(idea_sections[i].strip(),
|
| 851 |
idea_sections[i+1].strip() if i+1 < len(idea_sections) else "")
|
| 852 |
for i in range(1, len(idea_sections), 2)]
|
| 853 |
|
|
|
|
| 854 |
for title, text_block in pairs:
|
|
|
|
| 855 |
table_match = re.search(
|
| 856 |
-
r"\|\s
|
| 857 |
text_block, flags=re.IGNORECASE)
|
|
|
|
|
|
|
| 858 |
if not table_match:
|
| 859 |
table_match = re.search(
|
| 860 |
-
r"(?i)Image\s+Prompt\s*[
|
| 861 |
|
| 862 |
if not table_match:
|
| 863 |
-
continue
|
| 864 |
|
| 865 |
-
raw_prompt = re.sub(r"[\r\n
|
| 866 |
-
table_match.group(1).strip())
|
| 867 |
|
| 868 |
with st.spinner(f"Generating image for {title}โฆ"):
|
| 869 |
img, cap = generate_image(raw_prompt)
|
|
@@ -877,6 +881,8 @@ def process_input(prompt: str, uploaded_files):
|
|
| 877 |
"image_caption": f"{title} โ {cap}"
|
| 878 |
})
|
| 879 |
|
|
|
|
|
|
|
| 880 |
# โโ โฅ ๊ฒฐ๊ณผ ์ ์ฅ
|
| 881 |
st.session_state.messages.append(
|
| 882 |
{"role": "assistant", "content": full_response})
|
|
|
|
| 846 |
|
| 847 |
# โโ โค ์ด๋ฏธ์ง ์์ฑ
|
| 848 |
if st.session_state.generate_image and full_response:
|
| 849 |
+
|
| 850 |
+
idea_sections = re.split(r"(##\s*Idea\s*\d+\s*:?)", full_response, flags=re.IGNORECASE)
|
| 851 |
pairs = [(idea_sections[i].strip(),
|
| 852 |
idea_sections[i+1].strip() if i+1 < len(idea_sections) else "")
|
| 853 |
for i in range(1, len(idea_sections), 2)]
|
| 854 |
|
| 855 |
+
# โท ์ด๋ฏธ์ง ํ๋กฌํํธ ์ถ์ถ โ ํ/์ฝ๋ก /ํ์ดํ ๋ชจ๋ ๋ณํ ์ง์
|
| 856 |
for title, text_block in pairs:
|
| 857 |
+
# ํ ํํ | Image Prompt | ... | (๊ตต๊ฒ ํ๊ธฐ ์ /๋ฌด)
|
| 858 |
table_match = re.search(
|
| 859 |
+
r"\|\s*(?:\*\*)?Image\s+Prompt(?:\*\*)?\s*\|\s*([^|\n]+)", # โ ์์
|
| 860 |
text_block, flags=re.IGNORECASE)
|
| 861 |
+
|
| 862 |
+
# ํ
์คํธ ํํ Image Prompt : ... ๋๋ Image Prompt - ...
|
| 863 |
if not table_match:
|
| 864 |
table_match = re.search(
|
| 865 |
+
r"(?i)Image\s+Prompt\s*[:\-]\s*([^\n]+)", text_block)
|
| 866 |
|
| 867 |
if not table_match:
|
| 868 |
+
continue # ์ด ์์ด๋์ด์ ํ๋กฌํํธ ์์ โ ๊ฑด๋๋
|
| 869 |
|
| 870 |
+
raw_prompt = re.sub(r"[\r\n`\"'\\]", " ", table_match.group(1)).strip()
|
|
|
|
| 871 |
|
| 872 |
with st.spinner(f"Generating image for {title}โฆ"):
|
| 873 |
img, cap = generate_image(raw_prompt)
|
|
|
|
| 881 |
"image_caption": f"{title} โ {cap}"
|
| 882 |
})
|
| 883 |
|
| 884 |
+
|
| 885 |
+
|
| 886 |
# โโ โฅ ๊ฒฐ๊ณผ ์ ์ฅ
|
| 887 |
st.session_state.messages.append(
|
| 888 |
{"role": "assistant", "content": full_response})
|