Download app.py from rupaak/reply: direct link, hf CLI and curl.
- Browser
- Download file 506 Bytes
-
https://huggingface.co/spaces/rupaak/reply/resolve/main/app.py
- Command line
-
hf download hf://spaces/rupaak/reply/app.py
-
curl -L -o app.py https://huggingface.co/spaces/rupaak/reply/resolve/main/app.py
506 Bytes
| from transformers import pipeline | |
| import gradio as gr | |
| # Load the open-source model | |
| generator = pipeline("text-generation", model="gpt2") | |
| # Define a function to interact with the model | |
| def generate_text(prompt): | |
| results = generator(prompt, max_length=50, num_return_sequences=1) | |
| return results[0]['generated_text'] | |
| # Create a Gradio interface | |
| interface = gr.Interface( | |
| fn=generate_text, | |
| inputs="text", | |
| outputs="text", | |
| title="Text Generator" | |
| ) | |
| # Launch the app | |
| interface.launch() | |