File size: 787 Bytes
5b30d83 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | """
Minimal Gradio app for docstring generation.
Run: python app.py
"""
import gradio as gr
from inference import generate_docstring
def summarize_code(code: str) -> str:
if not code or not code.strip():
return "Paste a Python code snippet above."
return generate_docstring(code, model_name="t5-small", max_length=128, num_beams=4)
demo = gr.Interface(
fn=summarize_code,
inputs=gr.Textbox(
label="Python code",
placeholder="def add(a, b):\n return a + b",
lines=8,
),
outputs=gr.Textbox(label="Generated docstring"),
title="Python Docstring Generator",
description="Paste a Python function or snippet to get a short docstring summary.",
)
if __name__ == "__main__":
demo.launch()
|