Hyeonseo commited on
Commit
f2262cd
β€’
1 Parent(s): 3c287db

update: revise korean to english prompt

Browse files
presentation_assistant/presentation_assistant.py CHANGED
@@ -8,20 +8,20 @@ import sys
8
 
9
  sys.path.append("/home/user/app")
10
 
11
- # text2ppt ν”„λ‘¬ν”„νŠΈ 생성 ν•¨μˆ˜
12
  def generate_text2ppt_input_prompt(input_type, input_value, input_pages):
13
  header = """
14
- λ„ˆκ°€ markdown λ¬Έλ²•μœΌλ‘œ PPTλ₯Ό μ œμž‘ν•˜λŠ” λ””μžμ΄λ„ˆλΌκ³  κ°€μ •ν•˜κ³ , %sμž₯의 PPTλ₯Ό μž‘μ„±ν•΄.
15
- +++ μ•„λž˜ λ‚΄μš© λ˜λŠ” 링크λ₯Ό μš”μ•½ν•΄μ„œ markdown μ–Έμ–΄λ‘œ μž‘μ„±ν•˜λŠ”λ°, === μ•„λž˜ κ·œμΉ™κ³Ό 지킀고, ~~~ μ•„λž˜ μŠ¬λΌμ΄λ“œ μ˜ˆμ‹œλ₯Ό μ°Έκ³ ν•΄.
16
  +++
17
  """ % input_pages
18
 
19
  summary_value = ""
20
 
21
- if input_type == "링크":
22
  summary_value += input_value
23
  summary_value += "\n"
24
- elif input_type == "ν…μŠ€νŠΈ":
25
  summary_value += input_value
26
  summary_value += "\n"
27
  elif input_type == "PDF":
@@ -29,7 +29,7 @@ def generate_text2ppt_input_prompt(input_type, input_value, input_pages):
29
  pdf_reader = PyPDF2.PdfReader(pdf_file)
30
  num_pages = len(pdf_reader.pages)
31
 
32
- # 각 νŽ˜μ΄μ§€μ˜ λ‚΄μš©μ„ λ¬Έμžμ—΄λ‘œ λ³€ν™˜ν•©λ‹ˆλ‹€.
33
  text = ""
34
  for page_num in range(num_pages):
35
  page = pdf_reader.pages[page_num]
@@ -37,31 +37,31 @@ def generate_text2ppt_input_prompt(input_type, input_value, input_pages):
37
  summary_value += text
38
  summary_value += "\n"
39
  else:
40
- print("ERROR: 잘λͺ»λœ μž…λ ₯")
41
 
42
  rule_value = """
43
  ===
44
- - μ œμ‹œν•œ λ‚΄μš© λ˜λŠ” 링크의 λ‚΄μš©μ— λŒ€ν•΄μ„œλ§Œ μ‚¬μ‹€μ μœΌλ‘œ μž‘μ„±ν•΄μ€˜.
45
- - μŠ¬λΌμ΄λ“œ κ΅¬λΆ„μžλ‘œ ---λ₯Ό 무쑰건 μ‚¬μš©ν•΄μ€˜.
46
- - μ£Όμ œμ— μ μ ˆν•œ λ„ν˜•, 이미지(![이미지](이미지링크), https://unsplash.com/ko/images/stock/non-copyrighted μ—μ„œ μ‹€μ œλ‘œ μ‚¬μš© κ°€λŠ₯ν•œ), ν‘œ(|-|), 인용(>), κ°•μ‘°(bold, ``), 이λͺ¨μ§€(https://kr.piliapp.com/twitter-symbols/), μ•„μ΄μ½˜ (https://kr.piliapp.com/symbol/#popular) 등이 λ‹€μ–‘ν•˜κ²Œ μŠ¬λΌμ΄λ“œλ₯Ό λ””μžμΈν•˜κ³  λ°°μΉ˜ν•΄μ€˜.
47
- - 이λͺ¨μ§€λŠ” μ΅œλŒ€ 2 νŽ˜μ΄μ§€μ— ν•œ 번만 μ‚¬μš©ν•˜κ³ , λ‹€λ₯Έ λ””μžμΈμ„ λ‹€μ–‘ν•˜κ²Œ μ‚¬μš©ν•΄μ€˜.
48
- - 이미지와 ν‘œλ₯Ό μ‚¬μš©ν•  λ•Œ, νŽ˜μ΄μ§€ 크기와 κ³ λ €ν•΄μ„œ κΈ€ λ‚΄μš©μ΄ λͺ¨λ‘ λ‚˜νƒ€λ‚˜λ„λ‘ 크기λ₯Ό μ§€μ •ν•΄μ€˜.
49
- - Slide 1λ₯Ό 제λͺ©μœΌλ‘œ ν•΄μ„œ 총 %sμž₯이야.
50
- - PPT의 λ‚΄μš©μ„ ν’λΆ€ν•˜κ²Œ λ§ˆν¬λ‹€μš΄μœΌλ‘œ μž‘μ„±ν•΄μ€˜.
51
- - μŠ¬λΌμ΄λ“œ λ³„λ‘œ μ„€λͺ…ν•˜μ§€λ§κ³ , μ½”λ“œλ§Œ μž‘μ„±ν•΄μ€˜.
52
- - μ˜ˆμ‹œμ˜ λ‚΄μš©μ„ μ‚¬μš©ν•΄μ„œ μž‘μ„±ν•˜μ§€λ§κ³ , ν˜•μ‹λ§Œ μ°Έκ³ ν•΄.
53
  ~~~
54
- <!-- Slide 0. μŠ¬λΌμ΄λ“œ 주제 -->
55
- # μŠ¬λΌμ΄λ“œ 제λͺ©
56
- ![이미지링크](https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo-with-title.png)
57
- - ChatGPTλ₯Ό ν™œμš©ν•œ πŸ€—**TEXT2PPT μ„œλΉ„μŠ€ PA!**μž…λ‹ˆλ‹€.
58
- - `링크`,`ν…μŠ€νŠΈ`, `PDF`λ₯Ό μž…λ ₯ λ˜λŠ” μ—…λ‘œλ“œν•˜λ©΄, PPT둜 λ³€ν™˜ν•©λ‹ˆλ‹€.
59
  """ % input_pages
60
 
61
  return header + summary_value + rule_value
62
 
63
 
64
- # text2ppt μ‹€ν–‰ ν•¨μˆ˜
65
  def text2ppt(token_key, input_prompt, input_theme):
66
  openai.api_key = token_key
67
 
@@ -106,7 +106,7 @@ def ppt2script(token_key, input_file, input_type):
106
  pdf_reader = PyPDF2.PdfReader(pdf_file)
107
  num_pages = len(pdf_reader.pages)
108
 
109
- # 각 νŽ˜μ΄μ§€μ˜ λ‚΄μš©μ„ λ¬Έμžμ—΄λ‘œ λ³€ν™˜ν•©λ‹ˆλ‹€.
110
  text = ""
111
  for page_num in range(num_pages):
112
  page = pdf_reader.pages[page_num]
@@ -128,12 +128,12 @@ def ppt2script(token_key, input_file, input_type):
128
  text += run.text
129
 
130
  header = """
131
- λ„ˆλŠ” PPT λ°œν‘œμ— 도움을 μ£ΌλŠ” μ‘°λ ₯μžμ•Ό.
132
- ~~~μ•„λž˜ κ·œμΉ™μ„ 지킀고, --- μ•„λž˜ PPT λ‚΄μš©μ— λŒ€ν•΄ λ°œν‘œ 슀크립트λ₯Ό ν•œκΈ€λ‘œ μž‘μ„±ν•΄.
133
  ~~~
134
- - [PAGE_NUM 1] 일 λ•Œ, μ—¬κΈ°μ„œ 1은 νŽ˜μ΄μ§€ 번호인데, νŽ˜μ΄μ§€ λ²ˆν˜Έλ§ˆλ‹€ λ°œν‘œ 슀크립트λ₯Ό μž‘μ„±ν•΄.
135
- - λ§ˆν¬λ‹€μš΄ μ–Έμ–΄λ₯Ό μ“°μ§€μ•Šκ³ , ν…μŠ€νŠΈλ‘œλ§Œ μž‘μ„±ν•΄.
136
- - PPT λ‚΄μš©μ— 좔가적인 μ„€λͺ…μ΄λ‚˜ 사둀λ₯Ό λ§λΆ™μ—¬μ€˜.
137
  ---
138
  """
139
 
@@ -156,4 +156,4 @@ def ppt2script(token_key, input_file, input_type):
156
  reply = chat.choices[0].message.content
157
  messages.append({"role": "assistant", "content": reply})
158
 
159
- return reply
 
8
 
9
  sys.path.append("/home/user/app")
10
 
11
+ # Function to generate text2ppt input prompt
12
  def generate_text2ppt_input_prompt(input_type, input_value, input_pages):
13
  header = """
14
+ Assume you are a designer creating a PPT using markdown syntax, and write a PPT of %s pages.
15
+ +++ Summarize the content or link below in markdown language, adhering to the rules in ===, and refer to the slide examples in ~~~.
16
  +++
17
  """ % input_pages
18
 
19
  summary_value = ""
20
 
21
+ if input_type == "Link":
22
  summary_value += input_value
23
  summary_value += "\n"
24
+ elif input_type == "Text":
25
  summary_value += input_value
26
  summary_value += "\n"
27
  elif input_type == "PDF":
 
29
  pdf_reader = PyPDF2.PdfReader(pdf_file)
30
  num_pages = len(pdf_reader.pages)
31
 
32
+ # Convert the content of each page to a string.
33
  text = ""
34
  for page_num in range(num_pages):
35
  page = pdf_reader.pages[page_num]
 
37
  summary_value += text
38
  summary_value += "\n"
39
  else:
40
+ print("ERROR: Invalid input")
41
 
42
  rule_value = """
43
  ===
44
+ - Write factually only about the content or link provided.
45
+ - Always use --- as a slide divider.
46
+ - Design and arrange the slides diversely with appropriate shapes, images(![Image](Image link), https://unsplash.com/ko/images/stock/non-copyrighted for actual use), tables(|-|), quotes(>), emphasis(bold, ``), emojis(https://kr.piliapp.com/twitter-symbols/), icons (https://kr.piliapp.com/symbol/#popular).
47
+ - Use emojis only once in every two pages, and use various other designs.
48
+ - When using images and tables, specify the size considering the page size so that all the text content appears.
49
+ - Make Slide 1 the title, for a total of %s pages.
50
+ - Write the content of the PPT richly in markdown.
51
+ - Don't explain slide by slide, just write the code.
52
+ - Don't write using the content of the example, just refer to the format.
53
  ~~~
54
+ <!-- Slide 0. Slide Topic -->
55
+ # Slide Title
56
+ ![Image link](https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo-with-title.png)
57
+ - This is πŸ€—**TEXT2PPT service PA!** using ChatGPT.
58
+ - Converts `link`,`text`, `PDF` input or upload into PPT.
59
  """ % input_pages
60
 
61
  return header + summary_value + rule_value
62
 
63
 
64
+ # Function to execute text2ppt
65
  def text2ppt(token_key, input_prompt, input_theme):
66
  openai.api_key = token_key
67
 
 
106
  pdf_reader = PyPDF2.PdfReader(pdf_file)
107
  num_pages = len(pdf_reader.pages)
108
 
109
+ # Convert the content of each page to a string.
110
  text = ""
111
  for page_num in range(num_pages):
112
  page = pdf_reader.pages[page_num]
 
128
  text += run.text
129
 
130
  header = """
131
+ You are an assistant helping with PPT presentations.
132
+ ~~~Follow the rules below and write a presentation script for the PPT content below.
133
  ~~~
134
+ - When [PAGE_NUM 1], where 1 is the page number, write a presentation script for each page number.
135
+ - Write only in text without using markdown language.
136
+ - Add additional explanations or examples to the PPT content.
137
  ---
138
  """
139
 
 
156
  reply = chat.choices[0].message.content
157
  messages.append({"role": "assistant", "content": reply})
158
 
159
+ return reply