mannchauhan's picture
Upload 2 files
3d94df2 verified
raw
history blame
839 Bytes
import gradio as gr
from transformers import pipeline
# Load a lightweight test-case generation model
generator = pipeline("text2text-generation", model="Salesforce/codet5p-770m", max_length=512)
def generate_tests(code, instruction):
prompt = f"Input:\n{code}\n\nInstruction:\n{instruction}"
result = generator(prompt)[0]["generated_text"]
return result
gr.Interface(
fn=generate_tests,
inputs=[
gr.Textbox(label="Your Code", lines=10, placeholder="Paste your function here..."),
gr.Textbox(label="Instruction", placeholder="e.g., Generate unit tests using Python unittest.")
],
outputs=gr.Code(language="python"),
title="🧪 Unit Test & Test Case Generator",
description="🔧 Paste your function and get auto-generated test cases using a free model from Hugging Face."
).launch()