Download app.py from Hyun05/subwaybot: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/spaces/Hyun05/subwaybot/resolve/main/app.py
- Command line
-
hf download hf://spaces/Hyun05/subwaybot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Hyun05/subwaybot/resolve/main/app.py
1.18 kB
| from transformers import pipeline | |
| import gradio as gr | |
| # β KoAlpaca-Polyglot λͺ¨λΈμ νκ΅μ΄ λνμ νΉνλ λͺ¨λΈμ λλ€. | |
| generator = pipeline("text-generation", model="beomi/KoAlpaca-Polyglot-12.8B") | |
| # β κ°μ ν€λ³ λν μμ± ν¨μ | |
| def chat_with_emotion(user_input, tone="μμ°μ€λ¬μ΄"): | |
| if not user_input: | |
| return "μ λ ₯μ μ λ ₯ν΄μ£ΌμΈμ!" | |
| prompt = f"({tone} ν€μΌλ‘ μλ΅ν΄μ€)\nμ¬μ©μ: {user_input}\nAI:" | |
| response = generator(prompt, max_new_tokens=150, do_sample=True, temperature=0.7) | |
| return response[0]["generated_text"].replace(prompt, "").strip() | |
| # β Gradio μΈν°νμ΄μ€ κ΅¬μ± | |
| demo = gr.Interface( | |
| fn=chat_with_emotion, | |
| inputs=[ | |
| gr.Textbox(label="μ¬μ©μ μ λ ₯", placeholder="μ€λ νλ£¨κ° νλ€μμ΄..."), | |
| gr.Radio(["μμ°μ€λ¬μ΄", "μλ‘νλ", "곡κ°νλ", "μμ¬μν€λ", "νκΈ°μ°¬"], label="κ°μ ν€", value="μμ°μ€λ¬μ΄"), | |
| ], | |
| outputs=gr.Textbox(label="AI μλ΅"), | |
| title="κ°μ κΈ°λ° νκ΅μ΄ μ±λ΄ (KoAlpaca-Polyglot)", | |
| description="νκ΅μ΄λ‘ κ°μ ν€μ λ°λΌ 곡κ°ν λ΅λ³μ μμ±ν©λλ€." | |
| ) | |
| demo.launch() | |