Download app.py from igortech/sandbox: direct link, hf CLI and curl.
- Browser
- Download file 442 Bytes
-
https://huggingface.co/spaces/igortech/sandbox/resolve/main/app.py
- Command line
-
hf download hf://spaces/igortech/sandbox/app.py
-
curl -L -o app.py https://huggingface.co/spaces/igortech/sandbox/resolve/main/app.py
442 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| generator = pipeline("text-generation", model="distilgpt2") | |
| def chat_fn(message, history=None): | |
| try: | |
| response = generator(message, max_length=100, pad_token_id=50256) | |
| bot_reply = response[0]['generated_text'].strip() | |
| return bot_reply, history or [] | |
| except Exception as e: | |
| return f"Error: {e}", history or [] | |
| gr.ChatInterface(fn=chat_fn).launch() |