Spaces:
Sleeping
Sleeping
File size: 697 Bytes
f673293 7a5850e f673293 7a5850e f673293 7a5850e f673293 7a5850e f673293 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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()
|