Spaces:
Sleeping
Sleeping
:sparkles: Edit description and improve prompts
Browse files- README.md +1 -1
- 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 |
|