Spaces:
Sleeping
Sleeping
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)
|