LeenAnabtawe's picture
Update app.py
7a5850e verified
raw
history blame
697 Bytes
import gradio as gr
# Load a pre-hosted code-generation model Space (no token needed)
generator = gr.Interface.load("huggingface/HuggingFaceH4/starchat-alpha")
def generate_code(prompt, max_tokens):
return generator(prompt, max_tokens)[0]
interface = gr.Interface(
fn=generate_code,
inputs=[
gr.Textbox(label="Code Prompt", lines=5, placeholder="e.g., def add(a, b):"),
gr.Slider(20, 300, step=10, label="Max Tokens", value=100),
],
outputs=gr.Textbox(label="Generated Code"),
title="🧠 Code Generator (No Token Required)",
description="Powered by Hugging Face hosted model. No API key needed."
)
if __name__ == "__main__":
interface.launch()