egoing's picture
Update app.py
bbbae7e
raw
history blame contribute delete
659 Bytes
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)