ginipick commited on
Commit
1e4825e
ยท
verified ยท
1 Parent(s): 15955aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -28
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("AI & ๋น„์ฆˆ๋‹ˆ์Šค", 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,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
- idea_sections = re.split(r"(##\s*Idea\s*\d+\s*:?)", full_response, flags=re.IGNORECASE)
886
- pairs = [(idea_sections[i].strip(),
887
- idea_sections[i+1].strip() if i+1 < len(idea_sections) else "")
888
- for i in range(1, len(idea_sections), 2)]
889
-
890
-
891
- for title, text_block in pairs:
892
-
893
- table_match = re.search(
894
- r"\|\s*(?:\*\*)?Image\s+Prompt(?:\*\*)?\s*\|\s*([^|\n]+)", # โ† ์ˆ˜์ •
895
- text_block, flags=re.IGNORECASE)
896
-
897
- if not table_match:
898
- table_match = re.search(
899
- r"(?i)Image\s+Prompt\s*[:\-]\s*([^\n]+)", text_block)
900
-
901
- if not table_match:
902
- continue # ์ด ์•„์ด๋””์–ด์—” ํ”„๋กฌํ”„ํŠธ ์—†์Œ โ†’ ๊ฑด๋„ˆ๋œ€
903
-
904
- raw_prompt = re.sub(r"[\r\n`\"'\\]", " ", table_match.group(1)).strip()
905
-
906
- with st.spinner(f"Generating image for {title}โ€ฆ"):
 
907
  img, cap = generate_image(raw_prompt)
908
 
909
  if img:
910
- st.image(img, caption=f"{title} โ€“ {cap}")
 
911
  st.session_state.messages.append({
912
  "role": "assistant",
913
  "content": "",
914
  "image": img,
915
- "image_caption": f"{title} โ€“ {cap}"
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(