ginipick commited on
Commit
cf8b7b0
Β·
verified Β·
1 Parent(s): 7771ada

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -38
app.py CHANGED
@@ -3,6 +3,9 @@ import os, json, re, logging, requests, markdown, time, io
3
  from datetime import datetime
4
 
5
  import streamlit as st
 
 
 
6
  from openai import OpenAI # OpenAI 라이브러리
7
 
8
  from gradio_client import Client
@@ -312,48 +315,51 @@ def get_openai_client():
312
  )
313
 
314
  # ──────────────────────────────── New System Prompt for Idea Generation ─────────────────────
315
- def get_idea_system_prompt() -> str:
 
316
  """
317
- 아이디어 μƒμ„±μš© μ‹œμŠ€ν…œ ν”„λ‘¬ν”„νŠΈ:
318
- - 제곡된 physical_transformation_categoriesλ₯Ό ν™œμš©
319
- - 3κ°€μ§€ λ°œμƒ μ ‘κ·Ό: (1) μœ μ‚¬μ„± 기반 증강, (2) λ°˜μœ μ‚¬μ„±(λŒ€μ‘°) 기반 λ°œμƒμ˜ μ „ν™˜, (3) λ¬΄μž‘μœ„(μš°μ—°μ  μ°©μ•ˆ)
320
- - 각 아이디어λ₯Ό λ…Όλ¦¬μ μœΌλ‘œ μ„€λͺ… κ°€λŠ₯ν•˜λ„λ‘ μ§€μ‹œ
321
- - μ•„μ΄λ””μ–΄λ§ˆλ‹€ 이미지 ν”„λ‘¬ν”„νŠΈλ„ ν•¨κ»˜ μ œμ‹œν•  것
322
- """
323
- prompt = """
324
- λ°˜λ“œμ‹œ ν•œκΈ€(ν•œκ΅­μ–΄)둜 λ‹΅λ³€ν•˜λΌ. You are an advanced Idea Generation AI. Your goal is to take the user's prompt (topic, concept, or question) and create **3 distinct ideas** around it, drawing from the vast categories of **physical or conceptual transformations**. Specifically, you must produce:
325
-
326
- 1. **Similarity-based Augmentation**
327
- - Build upon the user's original concept by closely aligning to its core attributes.
328
- - Reference relevant categories or subcategories that naturally extend or amplify the original idea.
329
- - Provide a practical, logical explanation.
330
-
331
- 2. **Contrarian/Inverse Approach**
332
- - Intentionally invert or contradict the core assumptions of the original concept.
333
- - Use contrasting categories to spark unconventional thinking.
334
- - Clearly justify why this contrarian perspective might reveal novel possibilities.
335
-
336
- 3. **Random (Fortuitous Spark)**
337
- - Randomly select one or more categories or subcategories from any domain to introduce surprising or serendipitous ideas.
338
- - Show how this unexpected combination can yield fresh insights or opportunities.
339
-
340
- For each of the 3 approaches:
341
- - Provide a concise name or title for the idea.
342
- - Offer a clear, structured explanation (a few paragraphs) on how this idea works or could be realized.
343
- - Incorporate references to the relevant category or categories from the provided classification, explaining how they link to the idea.
344
- - Suggest a short, single-line **English prompt for generating an image** that best represents that idea.
345
-
346
- Finally:
347
- - Return your answer in Markdown format with headings (e.g., "## Idea 1: ...", "## Idea 2: ...", "## Idea 3: ...").
348
- - Do **not** mention that you are responding with "3 ideas" because of a prompt or instruction. Simply present them as the final structured output.
349
- - Never mention "blog," "SEO," or "prompt" instructions in your final text.
350
- - Do **not** mention that you're an AI. Present the content as a straightforward creative text for each idea.
351
-
352
- ---
353
- **Important**: You have access to a list of "physical_transformation_categories" (in Korean) and possibly an English version. Use them to anchor or inspire each idea, but do not simply copy the entire list. Instead, selectively reference a few relevant subcategories.
354
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  return prompt.strip()
356
 
 
 
357
  # ──────────────────────────────── Brave Search API ────────────────────────
358
  @st.cache_data(ttl=3600)
359
  def brave_search(query: str, count: int = 20):
@@ -635,6 +641,16 @@ def idea_generator_app():
635
  "example3": "λ―Έλž˜ν˜• ꡐ윑 μ„œλΉ„μŠ€ ꡬ상"
636
  }
637
 
 
 
 
 
 
 
 
 
 
 
638
  sb.subheader("Example Prompts")
639
  c1, c2, c3 = sb.columns(3)
640
  if c1.button("AI & λΉ„μ¦ˆλ‹ˆμŠ€", key="ex1"):
 
3
  from datetime import datetime
4
 
5
  import streamlit as st
6
+
7
+ st.set_page_config(layout="wide")
8
+
9
  from openai import OpenAI # OpenAI 라이브러리
10
 
11
  from gradio_client import Client
 
315
  )
316
 
317
  # ──────────────────────────────── New System Prompt for Idea Generation ─────────────────────
318
+ # ───────────────── System Prompt (REPORT STYLE) ─────────────────
319
+ def get_idea_system_prompt(selected_category: str | None = None) -> str:
320
  """
321
+ Return an enhanced system prompt that forces:
322
+ β–Έ Report-style output with tables
323
+ β–Έ Clear focus on NEED β–Έ VALUE β–Έ PROBLEM SOLVED β–Έ IMPLEMENTATION SNAPSHOT
324
+ β–Έ Three idea modes: Similarity-based, Contrarian, Random
325
+ β–Έ If `selected_category` is given, all ideas must chiefly reference
326
+ sub-items inside that category.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  """
328
+ cat_clause = (f"\n**Category Focus**: Concentrate on the Korean list "
329
+ f"under β€œ{selected_category}”. You *must* anchor every idea "
330
+ "to 2-3 sub-items from this category and reference them by name.\n")
331
+ prompt = f"""
332
+ λ°˜λ“œμ‹œ ν•œκΈ€(ν•œκ΅­μ–΄)둜 λ‹΅λ³€ν•˜λΌ. You are an elite innovation consultant. Your deliverable is a concise **report** in Markdown.
333
+
334
+ ### OUTPUT SPECIFICATION
335
+ Produce **exactly three ideas** (Similarity-Based, Contrarian, Random) using these sections **for *each* idea**:
336
+
337
+ | ν•­λͺ© | λ‚΄μš© |
338
+ |---|---|
339
+ | **Idea Title** | 8-12 Korean characters + 영문 κ΄„ν˜Έλ³„μΉ­ |
340
+ | **Need / Pain-Point** | μ–΄λ–€ 문제·기회 λ•Œλ¬Έμ— ν•„μš”ν•œκ°€? (1-2 λ¬Έμž₯) |
341
+ | **Core Concept** | 아이디어 κ°œμš” (2-3 문단) |
342
+ | **Key Category Links** | μ‚¬μš©ν•œ λ³€ν™˜ μΉ΄ν…Œκ³ λ¦¬/ν•˜μœ„ν•­λͺ©(3개 μ΄ν•˜) |
343
+ | **Value Proposition** | κΈ°λŒ€ νš¨κ³ΌΒ·κ°€μΉ˜ (뢈릿 3개) |
344
+ | **Potential Obstacles** | μ£Όμš” λ¦¬μŠ€ν¬Β·μ œμ•½ (뢈릿 2-3개) |
345
+ | **Image Prompt** | 영문 1μ€„λ‘œ μ‹œκ°ν™”λ₯Ό μœ„ν•œ ν”„λ‘¬ν”„νŠΈ |
346
+
347
+ - ν¬ν•¨λœ ν‘œλŠ” λ§ˆν¬λ‹€μš΄ κ·ΈλŒ€λ‘œ 좜λ ₯.
348
+ - μ„Έ 아이디어λ₯Ό β€œ## Idea 1”, β€œ## Idea 2”, β€œ## Idea 3” ν—€λ”©μœΌλ‘œ μˆœμ„œν™”.
349
+ - μ „λ¬Έμš©μ–΄ μ΅œμ†Œν™”, κ°„κ²°ν•˜μ§€λ§Œ 섀득λ ₯ 있게.
350
+
351
+ ### IDEA MODES
352
+ 1. **Similarity-Based Augmentation** – κΈ°μ‘΄ μ£Όμ œμ™€ κ°€μž₯ κ°€κΉκ²Œ ν™•μž₯.
353
+ 2. **Contrarian / Inverse** – 주제의 μ „μ œλ₯Ό λ’€μ§‘μ–΄ μƒˆλ‘œμš΄ μ‹œκ° μ œμ‹œ.
354
+ 3. **Random Spark** – λ¬΄μž‘μœ„ ν•˜μœ„ν•­λͺ©(μΉ΄ν…Œκ³ λ¦¬ 뢈문)을 κ²°ν•©ν•œ μ˜μ™Έμ˜ 톡찰.
355
+
356
+ {cat_clause if selected_category else ""}
357
+ Always think step-by-step but **show only the final report**.
358
+ """
359
  return prompt.strip()
360
 
361
+
362
+
363
  # ──────────────────────────────── Brave Search API ────────────────────────
364
  @st.cache_data(ttl=3600)
365
  def brave_search(query: str, count: int = 20):
 
641
  "example3": "λ―Έλž˜ν˜• ꡐ윑 μ„œλΉ„μŠ€ ꡬ상"
642
  }
643
 
644
+ sb.subheader("Category Focus (Optional)")
645
+ category_keys = ["(None)"] + list(physical_transformation_categories.keys())
646
+ sb.selectbox(
647
+ "Generate ideas mainly using this category",
648
+ options=category_keys,
649
+ key="category_focus",
650
+ index=0 # κΈ°λ³Έκ°’ "(None)"
651
+ )
652
+
653
+
654
  sb.subheader("Example Prompts")
655
  c1, c2, c3 = sb.columns(3)
656
  if c1.button("AI & λΉ„μ¦ˆλ‹ˆμŠ€", key="ex1"):