Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
|
|
3 |
|
4 |
-
|
5 |
-
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "dae-gu-ai-5th-preview")
|
6 |
|
7 |
-
dict = {
|
8 |
-
"ko2en" : {
|
9 |
-
"μ¬κ³Ό" : "apple",
|
10 |
-
"μ¬μ" : "tiger",
|
11 |
-
"μ¬λ" : "love"
|
12 |
-
},
|
13 |
-
"en2ko" : {
|
14 |
-
"apple" : "μ¬κ³Ό",
|
15 |
-
"lion" : "μ¬μ",
|
16 |
-
"love" : "μ¬λ"
|
17 |
-
}
|
18 |
-
}
|
19 |
def trans(type, word):
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
21 |
app = gr.Interface(
|
22 |
fn=trans,
|
23 |
inputs=[
|
24 |
gr.Radio(['ko2en', 'en2ko']),
|
25 |
gr.Textbox(placeholder="νκ΅μ΄")
|
26 |
],
|
27 |
-
outputs="text"
|
28 |
-
allow_flagging="auto",
|
29 |
-
flagging_callback=hf_writer
|
30 |
)
|
31 |
app.launch(debug=True)
|
32 |
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
import openai
|
4 |
|
5 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
|
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
def trans(type, word):
|
8 |
+
msg = 'μλ λ΄μ©μ νκ΅μ΄μμ μμ΄λ‘ λ²μν΄μ€\n'
|
9 |
+
if(type == 'en2ko') :
|
10 |
+
msg = 'μλ λ΄μ©μ μμ΄μμ νκ΅μ΄λ‘ λ²μν΄μ€\n'
|
11 |
+
msg = msg + word
|
12 |
+
chat_completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": msg}])
|
13 |
+
return chat_completion.choices[0].message.content
|
14 |
app = gr.Interface(
|
15 |
fn=trans,
|
16 |
inputs=[
|
17 |
gr.Radio(['ko2en', 'en2ko']),
|
18 |
gr.Textbox(placeholder="νκ΅μ΄")
|
19 |
],
|
20 |
+
outputs="text"
|
|
|
|
|
21 |
)
|
22 |
app.launch(debug=True)
|
23 |
|