Spaces:
Runtime error
Runtime error
Download app.py from Haider67/MODEL_SPACE: direct link, hf CLI and curl.
- Browser
- Download file 641 Bytes
-
https://huggingface.co/spaces/Haider67/MODEL_SPACE/resolve/main/app.py
- Command line
-
hf download hf://spaces/Haider67/MODEL_SPACE/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Haider67/MODEL_SPACE/resolve/main/app.py
641 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load a fast, lightweight open-source model | |
| pipe = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct") | |
| def generate_response(prompt): | |
| messages = [{"role": "user", "content": prompt}] | |
| output = pipe(messages, max_new_tokens=200) | |
| return output[0]["generated_text"][-1]["content"] | |
| # Create the Gradio web app and API | |
| demo = gr.Interface( | |
| fn=generate_response, | |
| inputs=gr.Textbox( | |
| lines=3, placeholder="Enter your prompt here...", label="Prompt" | |
| ), | |
| outputs=gr.Textbox(label="Response"), | |
| title="Open-Source Model API", | |
| ) | |
| demo.launch() | |