Download app.py from limuu/JILIM: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/spaces/limuu/JILIM/resolve/main/app.py
- Command line
-
hf download hf://spaces/limuu/JILIM/app.py
-
curl -L -o app.py https://huggingface.co/spaces/limuu/JILIM/resolve/main/app.py
1.29 kB
| import openai | |
| import gradio as gr | |
| # OpenAI API ํค ์ค์ | |
| openai.api_key = 'sk-proj-bVrEIXCRUgwpPGg8b5AoT3BlbkFJUNwFDqrjhlvfeak799mL' | |
| def get_medication_info(medication_name): | |
| try: | |
| # ChatGPT์ ์ฝ์ ์ด๋ฆ์ ๋ํ ์ ๋ณด๋ฅผ ์์ฒญ | |
| response = openai.ChatCompletion.create( | |
| model="gpt-3.5-turbo", # ๋ชจ๋ธ์ ํ์์ ๋ฐ๋ผ ์ต์ ๋ฒ์ ์ผ๋ก ๋ณ๊ฒฝ ๊ฐ๋ฅ | |
| messages=[ | |
| {"role": "system", "content": "You are a helpful assistant."}, | |
| {"role": "user", "content": f"์ฝ์ ์ด๋ฆ '{medication_name}'์ ๋ํ ์ ๋ณด๋ฅผ ์ค๋ช ํด์ฃผ์ธ์."} | |
| ], | |
| temperature=0.5, | |
| max_tokens=150, | |
| top_p=1.0, | |
| frequency_penalty=0.0, | |
| presence_penalty=0.0 | |
| ) | |
| return response['choices'][0]['message']['content'].strip() | |
| except Exception as e: | |
| return str(e) | |
| # Gradio ์ธํฐํ์ด์ค ์์ฑ | |
| iface = gr.Interface( | |
| fn=get_medication_info, | |
| inputs=gr.Textbox(lines=2, placeholder="์ฝ์ ์ด๋ฆ์ ์ ๋ ฅํ์ธ์..."), | |
| outputs="text", | |
| title="์ฝ ์ ๋ณด ๊ฒ์๊ธฐ", | |
| description="์ฝ์ ์ด๋ฆ์ ์ ๋ ฅํ๋ฉด ChatGPT๋ฅผ ํตํด ์ฝ์ ๋ํ ์ ๋ณด๋ฅผ ๊ฒ์ํด ๋๋ฆฝ๋๋ค." | |
| ) | |
| # ์ธํฐํ์ด์ค ์คํ | |
| iface.launch() | |