Zeta611 commited on
Commit
360c8b1
โ€ข
1 Parent(s): b51dd8f

:sparkles: Edit description and improve prompts

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. easyword_translator/run.py +12 -4
README.md CHANGED
@@ -11,7 +11,7 @@ python_version: 3.11.9
11
  ## ์‹คํ–‰ ๋ฐฉ๋ฒ•
12
 
13
  ```sh
14
- dotenv poetry run python easyword_translator/run.py
15
  ```
16
 
17
  ## ์Šคํฌ๋ฆฐ์ƒท
 
11
  ## ์‹คํ–‰ ๋ฐฉ๋ฒ•
12
 
13
  ```sh
14
+ dotenv run poetry run python easyword_translator/run.py
15
  ```
16
 
17
  ## ์Šคํฌ๋ฆฐ์ƒท
easyword_translator/run.py CHANGED
@@ -14,6 +14,13 @@ warnings.filterwarnings("ignore")
14
 
15
  UPSTAGE_API_KEY = os.environ["UPSTAGE_API_KEY"]
16
 
 
 
 
 
 
 
 
17
  LIMIT_FACTOR = 2.5
18
  SCORE_CUTOFF = 60.0
19
  MAX_RETRIES = 4
@@ -100,7 +107,7 @@ def translate(sentence: str) -> str:
100
  ("ai", response),
101
  (
102
  "human",
103
- f"์ด๋ฒˆ์—๋Š” ์ฒ˜์Œ ๋ฒˆ์—ญํ–ˆ๋˜ ๋ฌธ์žฅ์„ '{sentence}'๋ฅผ ๋‹ค์‹œ ๋ฒˆ์—ญํ•ด์ฃผ๋Š”๋ฐ, ๋‹ค์Œ ๋ชฉ๋ก์— ๋‚˜์˜จ ์‰ฌ์šด ์ „๋ฌธ์šฉ์–ด ๋ฒˆ์—ญ ์˜ˆ์‹œ๋ฅผ ์ฐธ๊ณ ํ•ด์„œ ๋ฒˆ์—ญ์„ ํ•ด์ค˜: '{recommendations}' ์‚ฌ์šฉํ•˜์ง€ ์•Š์€ ์šฉ์–ด๋“ค์€ ๋ฌด์‹œํ•ด๋„ ๋ผ. ์ถ”๊ฐ€ ์„ค๋ช… ์—†์ด ๋ฌธ์žฅ๋งŒ ๋ฒˆ์—ญํ•ด.",
104
  ),
105
  ]
106
  refined_translation = chainer(messages).invoke({})
@@ -115,12 +122,13 @@ def translate(sentence: str) -> str:
115
  ("ai", refined_translation),
116
  (
117
  "human",
118
- f"์ „๋ฌธ์šฉ์–ด๋ฅผ ๋ฒˆ์—ญํ–ˆ์œผ๋ฉด ๋ฐ˜๋“œ์‹œ ์›์–ด๋ฅผ ๊ด„ํ˜ธ[]์— ๋„ฃ์–ด์„œ ๋”ฐ๋ผ ๋ถ™์—ฌ์•ผ ํ•ด. '์‹คํ–‰ํ๋ฆ„[control]'์ฒ˜๋Ÿผ. ๋ฐฉ๊ธˆ ๋ฒˆ์—ญํ•œ '{refined_translation}'์—์„œ, ์›๋ž˜ ๋ฌธ์žฅ '{sentence}'์— ์‚ฌ์šฉ๋œ ์›์–ด๋ฅผ ๊ด„ํ˜ธ์— ๋„ฃ์–ด์„œ ๋”ฐ๋ผ ๋ถ™์—ฌ์ค˜.",
119
  ),
120
  ]
121
  refined_translation = chainer(messages).invoke({})
122
  logger.info(refined_translation)
123
 
 
124
  return refined_translation
125
 
126
 
@@ -139,8 +147,8 @@ with gr.Blocks() as demo:
139
  "In computing and computer programming, exception handling is the process of responding to the occurrence of exceptions โ€“ anomalous or exceptional conditions requiring special processing โ€“ during the execution of a program.",
140
  "The term redex, short for reducible expression, refers to subterms that can be reduced by one of the reduction rules.",
141
  ],
142
- title="์‰ฌ์šด ์ „๋ฌธ์šฉ์–ด ๋ฒˆ์—ญ๊ธฐ",
143
- description="์ปดํ“จํ„ฐ๊ณผํ•™ ๋ฐ ๊ณตํ•™ ๋ถ„์•ผ์˜ ์ „๋ฌธ์šฉ์–ด๋ฅผ ์‰ฌ์šด ์ „๋ฌธ์šฉ์–ด๋กœ ๋ฒˆ์—ญํ•ด์ค๋‹ˆ๋‹ค.",
144
  )
145
 
146
 
 
14
 
15
  UPSTAGE_API_KEY = os.environ["UPSTAGE_API_KEY"]
16
 
17
+ TITLE = "์‰ฌ์šด ์ „๋ฌธ์šฉ์–ด ๋ฒˆ์—ญ๊ธฐ"
18
+ DESCRIPTION = """
19
+ ์šฐ๋ฆฌ๊ฐ€ easyword.kr์— ๋ชจ์€ ์‰ฌ์šด ์ „๋ฌธ์šฉ์–ด๋“ค์„ ์‚ฌ์šฉํ•˜์—ฌ, ์ž๋™์œผ๋กœ ๋ฌธ์žฅ์„ ๋ฒˆ์—ญํ•ด์ค๋‹ˆ๋‹ค.
20
+ ๋ฒˆ์—ญ์„ ์ž๋™์œผ๋กœ ํ•˜๊ธฐ ์œ„ํ•ด ์—…์Šคํ…Œ์ด์ง€์˜ Solar ๋Œ€ํ˜• ์–ธ์–ด ๋ชจ๋ธ (large language model, LLM)์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
21
+ ์šฐ๋ฆฌ ๋ฒˆ์—ญ๊ธฐ๋Š” ์ตœ๋Œ€ํ•œ ์‰ฌ์šด ์ „๋ฌธ์šฉ์–ด ์›์น™์„ ๋”ฐ๋ฅด๋ฉฐ, ์›๋ฌธ ์ „๋ฌธ์šฉ์–ด๋Š” ๋ฒˆ์—ญ๋œ ์‰ฌ์šด๋ง ๋‹ค์Œ ๊ด„ํ˜ธ ์•ˆ์— ๋”ฐ๋ผ๋ถ™์ž…๋‹ˆ๋‹ค.
22
+ """.strip()
23
+
24
  LIMIT_FACTOR = 2.5
25
  SCORE_CUTOFF = 60.0
26
  MAX_RETRIES = 4
 
107
  ("ai", response),
108
  (
109
  "human",
110
+ f"์ด๋ฒˆ์—๋Š” ์ฒ˜์Œ ๋ฒˆ์—ญํ–ˆ๋˜ ๋ฌธ์žฅ์„ '{sentence}'๋ฅผ ๋‹ค์‹œ ๋ฒˆ์—ญํ•ด์ฃผ๋Š”๋ฐ, ๋‹ค์Œ ๋ชฉ๋ก์— ๋‚˜์˜จ ์‰ฌ์šด ์ „๋ฌธ์šฉ์–ด ๋ฒˆ์—ญ ์˜ˆ์‹œ๋ฅผ ์ฐธ๊ณ ํ•ด์„œ ๋ฒˆ์—ญ์„ ํ•ด์ค˜: '{recommendations}' ์‚ฌ์šฉํ•˜์ง€ ์•Š์€ ์šฉ์–ด๋“ค์€ ๋ฌด์‹œํ•ด๋„ ๋ผ. ์ถ”๊ฐ€ ์„ค๋ช… ์—†์ด ๋ฌธ์žฅ๋งŒ ๋ฒˆ์—ญํ•ด. ์‚ฌ์šฉ๋œ ์›์–ด๋ฅผ ์šฉ์–ด ๋ฐ”๋กœ ๋’ค์— ๊ด„ํ˜ธ []์— ๋„ฃ์–ด์„œ ๋”ฐ๋ผ ๋ถ™์—ฌ์ค˜.",
111
  ),
112
  ]
113
  refined_translation = chainer(messages).invoke({})
 
122
  ("ai", refined_translation),
123
  (
124
  "human",
125
+ f"์ „๋ฌธ์šฉ์–ด๋ฅผ ๋ฒˆ์—ญํ–ˆ์œผ๋ฉด ๋ฐ˜๋“œ์‹œ ์›์–ด๋ฅผ ๊ด„ํ˜ธ[]์— ๋„ฃ์–ด์„œ ๋”ฐ๋ผ ๋ถ™์—ฌ์•ผ ํ•ด. '์‹คํ–‰ํ๋ฆ„[control]'์ฒ˜๋Ÿผ. ๋ฐฉ๊ธˆ ๋ฒˆ์—ญํ•œ '{refined_translation}'์—์„œ, ์›๋ž˜ ๋ฌธ์žฅ '{sentence}'์— ์‚ฌ์šฉ๋œ ์›์–ด๋ฅผ ์šฉ์–ด ๋ฐ”๋กœ ๋’ค์— ๊ด„ํ˜ธ []์— ๋„ฃ์–ด์„œ ๋”ฐ๋ผ ๋ถ™์—ฌ์ค˜.",
126
  ),
127
  ]
128
  refined_translation = chainer(messages).invoke({})
129
  logger.info(refined_translation)
130
 
131
+ refined_translation = refined_translation.replace("[", "(").replace("]", ")")
132
  return refined_translation
133
 
134
 
 
147
  "In computing and computer programming, exception handling is the process of responding to the occurrence of exceptions โ€“ anomalous or exceptional conditions requiring special processing โ€“ during the execution of a program.",
148
  "The term redex, short for reducible expression, refers to subterms that can be reduced by one of the reduction rules.",
149
  ],
150
+ title=TITLE,
151
+ description=DESCRIPTION,
152
  )
153
 
154