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