Spaces:
Runtime error
Runtime error
Download app.py from Sayan567/sayanoX-coder: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/Sayan567/sayanoX-coder/resolve/main/app.py
- Command line
-
hf download hf://spaces/Sayan567/sayanoX-coder/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Sayan567/sayanoX-coder/resolve/main/app.py
1.15 kB
| import gradio as gr | |
| from transformers import pipeline | |
| # CPU only - fast startup | |
| pipe = pipeline( | |
| "text-generation", | |
| model="Qwen/Qwen2.5-Coder-1.5B-Instruct", | |
| device="cpu" | |
| ) | |
| def coding_ai(prompt, language, task): | |
| response = pipe( | |
| f"You are a expert coder. Language: {language}. Task: {task}. Request: {prompt}\n\nAnswer:", | |
| max_new_tokens=1024, | |
| temperature=0.7, | |
| do_sample=True | |
| ) | |
| return response[0]['generated_text'] | |
| with gr.Blocks(title="Sayanox AI Coder", theme=gr.themes.Soft()) as demo: | |
| gr.Markdown("# 🔥 Sayanox AI Coder\n**Sayanox Private Limited**") | |
| language = gr.Dropdown(["Python", "JavaScript", "Java", "C++", "Go"], value="Python", label="Language") | |
| task = gr.Dropdown(["Generate", "Fix Bug", "Explain"], value="Generate", label="Task") | |
| prompt = gr.Textbox(lines=6, placeholder="Type your request here...", label="Prompt") | |
| btn = gr.Button("Generate Code", variant="primary") | |
| output = gr.Textbox(lines=15, label="AI Response") | |
| btn.click(coding_ai, inputs=[prompt, language, task], outputs=output) | |
| demo.launch(server_name="0.0.0.0", server_port=7860) |