File size: 659 Bytes
64f613e
bbbae7e
 
64f613e
bbbae7e
64f613e
 
bbbae7e
 
 
 
 
 
 
 
64f613e
 
 
 
 
bbbae7e
64f613e
 
 
 
 
bbbae7e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import gradio as gr
import openai
import os

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


def trans(word):
    msg = "λ‹€μŒμ€„μ˜ ν…μŠ€νŠΈμ— λŒ€ν•΄μ„œ ν•œκΈ€μ€ μ˜μ–΄λ‘œ, μ˜μ–΄λŠ” ν•œκΈ€λ‘œ λ²ˆμ—­ν•΄μ€˜. \n" + word
    print(msg)
    chat_completion = openai.ChatCompletion.create(
        model="gpt-3.5-turbo", messages=[{"role": "user", "content": msg}]
    )
    result = chat_completion["choices"][0]["message"]["content"]
    return result


app = gr.Interface(
    fn=trans,
    inputs=[
        gr.Textbox(),
    ],
    outputs="text",
    examples=[["ko2en", "μ‚¬λž‘"], ["en2ko", "love"]],
    allow_flagging="manual",
)
app.launch(debug=True)