File size: 659 Bytes
a9dda90
1730e49
62dd373
a9dda90
62dd373
a9dda90
 
62dd373
 
 
 
 
 
a9dda90
 
 
6343215
 
a9dda90
62dd373
a9dda90
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import os
import openai

openai.api_key = os.getenv("OPENAI_API_KEY")

def trans(type, word):
    msg = 'μ•„λž˜ λ‚΄μš©μ„ ν•œκ΅­μ–΄μ—μ„œ μ˜μ–΄λ‘œ λ²ˆμ—­ν•΄μ€˜\n'
    if(type == 'en2ko') :
        msg = 'μ•„λž˜ λ‚΄μš©μ„ μ˜μ–΄μ—μ„œ ν•œκ΅­μ–΄λ‘œ λ²ˆμ—­ν•΄μ€˜\n'
    msg = msg + word
    chat_completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": msg}])
    return chat_completion.choices[0].message.content
app = gr.Interface(
    fn=trans,
    inputs=[
        gr.Radio(['ko2en', 'en2ko']),
        gr.Textbox(placeholder="ν•œκ΅­μ–΄")
    ],
    outputs="text"
)
app.launch(debug=True)